37
Payment Channel Introduction 2017/10/03 blockchain.tokyo #1 @mosa_siru

Payment Channel Introduction

Embed Size (px)

Citation preview

Page 1: Payment Channel Introduction

Payment ChannelIntroduction2017/10/03 blockchain.tokyo #1 @mosa_siru

Page 2: Payment Channel Introduction

@mosa_siru ( )

• TV

• Gunosy

PO

Page 3: Payment Channel Introduction

@mosa_siru as engineer

• (DeNA)

• (Gunosy)

• (Gunosy)

Page 4: Payment Channel Introduction

1. Payment channel

2. HTLCs

Page 5: Payment Channel Introduction

bitcoin micro payment

• (API )

• bitcoin 1 1

• 2017/10 150

• ( ) 10

• 3.47

Page 6: Payment Channel Introduction

• platform

user

• platform user

Page 7: Payment Channel Introduction

• platform BTC

user 10

platform BTC

• user platform

• platform

Page 8: Payment Channel Introduction

Payment channel

• trustless ( )

• off-chain transaction(

broadcast )

• off-chain

Page 9: Payment Channel Introduction
Page 10: Payment Channel Introduction

Multisig

( ) of ( )

• 2 of 3 ( 3 2

• 1 of 2 ( )

• 2 of 2 ( )

P2SH Redeem script: OP_2 [A's pubkey] [B's pubkey] OP_2 OP_CHECKMULTISIG

Page 11: Payment Channel Introduction

CLTV(CheckLockTimeVerify)• BIP65 (Final) (OP_CHECKLOCKTIMEVERIFY)

• unspentable

( BTC )

※ nLockTime

( UTXO )

Page 12: Payment Channel Introduction

CSV(CheckSequenceVerify)• BIP112 (Final) (OP_CHECKSEQUENCEVERIFY)

• (

) unspentable

BTC (3 )

• CLTV CSV TimeLock

Page 13: Payment Channel Introduction

Payment Channel

Page 14: Payment Channel Introduction

Payment Channel • trustless(A, B )

• trustless 2 of 2 multisig(A, B

)

• fund

• off-chain

(100 )

Page 15: Payment Channel Introduction

Payment Channel (1)A → B micro payment

1. A 2 of 2(multisig) fund 1BTC deposite

broadcast

2. 1 txid 1 1BTC A

refund transaction

B CSV CLTV

3. 1 broadcast (channel open

Page 16: Payment Channel Introduction

Payment Channel (2)4. deposite address A, B

A B

(off-chain)

deposite address => B(0.01BTC), A(0.99BTC) deposite address => B(0.02BTC), A(0.98BTC)…

5. B broadcast

(channel close)

Page 17: Payment Channel Introduction

Bob => Alice

https://bitcoin.org/en/developer-guide#micropayment-channel

Page 18: Payment Channel Introduction

Trustless (1)• B

• refund transaction( ) broadcast 1 (CSV

or CLTV) A

• refund transaction B B

fund deposite

• B 1 A

Page 19: Payment Channel Introduction

Trustless (2)

• A

• B broadcast

Page 20: Payment Channel Introduction

Time Lock• refund CLTV( )

channel close (B )

CSV( )

• CLTV nLockTime(

)

• deposite txid

refund transaction

segwit

Page 21: Payment Channel Introduction

• channel

• deposite

Page 22: Payment Channel Introduction

HTLC

Page 23: Payment Channel Introduction

HTLC (Hashed TimeLock Contracts)• CSV, CTLV TimeLock HashLock

• A => B => C

• channel

• B A

• Lightning Network

Page 24: Payment Channel Introduction

HTLC (1)

A => C micro payment

1. A => B , B => C payment channel

2. C A r

hash(r)

generate rOpen channel

Open channel

Page 25: Payment Channel Introduction

HTLC (2)3. A => B 1BTC tx1 (off-chain)

IF

1. B r

2. 10 A (CLTV) ※refund .

4. Tx1 B => C 1BTC tx2 (off-chain)

1. C r

2. 5 B (CTLV) ← tx1

5. C r tx2 broadcast 1BTC

r B tx1 broadcast 1BTC

Page 26: Payment Channel Introduction

HTLC (1)

• trustless A => B => C

• tx2 tx1 refund B

CSV

CLTV tx2

Page 27: Payment Channel Introduction

HTLC (2)

• Tx1 (A => B) tx2

segwit

id

• r

pre-image

Page 28: Payment Channel Introduction

Payment Channel(Bidirectional)

Page 29: Payment Channel Introduction

Payment Channel (Bidirectional)• payment channel

• channel 2

fund

• Time Lock, Hash Lock

Page 30: Payment Channel Introduction

Payment Channel (Bidirectional)1. A, B 5BTC 2 of 2 fund

opening transaction (off-chain)

2. A secret1, B secret2( )

hash

Page 31: Payment Channel Introduction

Payment Channel (Bidirectional)3. A commitment transaction tx2 B (off-chain)

4. B commitment transaction tx1 A (off-chain)

100block secret

opening transaction broadcast.

Page 32: Payment Channel Introduction

Payment Channel (Bidirectional) A => B 1BTC

5. tx3, tx4 secret

6. Secret 1, 2 hash tx1, tx2

Page 33: Payment Channel Introduction

transaction• A => B 1BTC A tx1, tx2

secret

• A tx1 broadcast A 5BTC

100block B 5BTC

secret1 10BTC

Page 34: Payment Channel Introduction

Payment Channel (Bidirectional)7. transaction broadcast

Page 35: Payment Channel Introduction
Page 36: Payment Channel Introduction

layer2

• CTLV, CSV

trustless

• …

Page 37: Payment Channel Introduction

@mosa_siru