lightning network overview - chaincode · transfer layer (bolt 02) off-chain case: - collaborative...

14
Lightning Network Overview Dr. Christian Decker Core Tech Engineer

Upload: others

Post on 10-Feb-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Lightning Network OverviewDr. Christian Decker

Core Tech Engineer

Page 2: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

The Lightning Stack

Page 3: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Layers1

Page 4: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Transport Layer (BOLT 08)

Goals

- Authenticate Node Identity

- Fingerprint Resistant

- Setup Transport Encryption

- Confidentiality

- Authentication

- Integrity

Implementation

- Persistent Identities (Node ID)

- Noise Protocol Framework (Noise_XK)

- SHA256

- ChaCha20

- Poly1305

Page 5: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Message Framing (BOLT 08)

Page 6: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Control Messages (BOLT 01)

init

- type: 16 (init)- data:

- [2:gflen]- [gflen:globalfeatures]- [2:lflen]- [lflen:localfeatures]

error

- type: 17 (error)- data:

- [32:channel_id]- [2:len]- [len:data]

Page 7: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

User Balance

Alice 5

Bob 5

Carol 5

55 4

6 19 6

4

6

4

Update Layer (BOLT 02)

Page 8: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Transfer Layer (BOLT 02)

Off-Chain Case:- Collaborative success

Recipient presents sender with the hash preimage, and both update state to remove the HTLC output.

- Uncollaborative successRecipient shows sender hash, but sender refuses to remove the HTLC output. Drop to chain to enforce success using the HTLC-success transaction before timeout expires

- TimeoutDrop to chain and eventually use HTLC-Timeout transaction, before upstream timeout expires, to avoid being out of pocket.

On-Chain Case:- Collaborative success

Too late, we’re already on-chain, HTLC output was created.

- Uncollaborative successEnforce success using the HTLC-success transaction before timeout expires.

- TimeoutUse HTLC-Timeout transaction, before upstream timeout expires, to avoid being out of pocket.

Page 9: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Transfer Layer (BOLT 02)

# To remote node with revocation key

OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL

OP_IF

OP_CHECKSIG

OP_ELSE

<remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL

OP_NOTIF

# To local node via HTLC-timeout transaction (timelocked).

OP_DROP 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG

OP_ELSE

# To remote node with preimage.

OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY

OP_CHECKSIG

OP_ENDIFOP_ENDIF

Page 10: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

A B C D E

Multihop Layer (BOLT 04)

B C D E T

Page 11: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Gossip Layer (BOLT 07)

Page 12: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Bits and Pieces2

Page 13: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Bits and Pieces

DNS Bootstrap (BOLT 10) Invoices (BOLT 11)

Please send 0.0025 BTC for a cup of nonsense (ナン

センス 1杯) to the same peer, within one minute

lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny

Page 14: Lightning Network Overview - Chaincode · Transfer Layer (BOLT 02) Off-Chain Case: - Collaborative success Recipient presents sender with the hash preimage, and both update state

Thank You

Blockstream.com

@Snyke

@Blockstream