payments channels and - law program · 2019-06-02 · • payment channels: potential to resolve...

45
Regulation of Cryptocurrencies - HUJI – May 2019 Ittay Eyal Technion EE and IC3 Payments Channels and Performance in Blockchain Systems

Upload: others

Post on 06-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

Regulation of Cryptocurrencies - HUJI – May 2019

Ittay EyalTechnion EE and IC3

Payments Channels and Performance in Blockchain Systems

Page 2: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

2

Cryptocurrency Key Challenges

A

B

C

1. No stealing: Only Alice can move her money 2. Minting: Fair money creation 3. No double-spending: Alice cannot duplicate her money

Page 3: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

3

Cryptocurrency Key Challenges

A

B

C

1. No stealing: Only Alice can move her money 2. Minting: Fair money creation 3. No double-spending: Alice cannot duplicate her money

Page 4: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

4

Cryptocurrency Key Challenges

A

B

C

1. No stealing: Only Alice can move her money 2. Minting: Fair money creation 3. No double-spending: Alice cannot duplicate her money

Page 5: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

5

1. No stealing: Only Alice can move her money 2. Minting: Fair money creation 3. No double-spending: Alice cannot duplicate her money

Cryptocurrency Key Challenges

A

B

C

Page 6: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

6

Cryptocurrency Key Challenges

𝐴 → 𝐵

Log

A B C

Page 7: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

7

Cryptocurrency Key Challenges

𝐴 → 𝐵

Log

A B C

𝐴 → 𝐶

Page 8: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

8

Nakamoto’s Solution

Reach consensus on all transactions

Widely adopted • Cryptocurrencies: Bitcoin, Ethereum, Zcash, … • DLTs: Corda, Ripple, Hyperledger, …

Page 9: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

9

Nakamoto’s Solution

Reach consensus on all transactions

Implication: • Low throughput • High latency

Page 10: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

10

Payment Channels

• Each side places a deposit amount on blockchain

• Payments via direct communication

• Each can unilaterally terminate channel • Place settlement transaction on blockchain• Receive its current balance

Page 11: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

11

Toy Example: Unidirectional Channel

RefundTime-

Locked

Alice Bob

SetupIn blockchain:

$100

Page 12: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

12

Toy Example: Unidirectional Channel

Alice Bob

SetupIn blockchain:

$100

Payment$97

$3

$3

RefundTime-

Locked

Page 13: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

13

Toy Example: Unidirectional Channel

Alice Bob

SetupIn blockchain:

$100

$97

$3

Payment$95

$5

$3

$2

RefundTime-

Locked

Payment

Page 14: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

14

Toy Example: Unidirectional Channel

Alice Bob

SetupIn blockchain:

$100

$97

$3

Settlement$95

$5

$3

$2

RefundTime-

Locked

Payment

Page 15: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

15

Bidirectional Channel

Each party can settle channel

But

No party can roll back channel state.

Page 16: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

16

Bidirectional Channel

Simple solution: 2 unidirectional channels

Deposit: $100

Deposit: $100

Page 17: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

17

Bidirectional Channel

Simple solution: 2 unidirectional channels

But: redundant resets on depletion

Deposit: $100 $100

$50 Deposit: $100

Page 18: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

The Lightning Network

Page 19: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

19

Lightning Network

Poon and Dryja. 2016

Coordinated state updates. Payment is:

1. Capability to close channel at current state

2. Capability to take all if other side settles at older state

Page 20: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

20

Lightning Network

Poon and Dryja. 2016

Coordinated state updates. Payment is:

1. Capability to close channel at current state• A signed transaction settling current state

2. Capability to take all if other side settles at older state

Page 21: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

21

Lightning Network

Poon and Dryja. 2016

Coordinated state updates. Payment is:

1. Capability to close channel at current state• A signed transaction settling current state

2. Capability to take all if other side settles at older state • A secret nullifying deprecated settlement transaction

Page 22: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

22

Lightning Network

Poon and Dryja. 2016

Coordinated state updates. Payment is:

1. Capability to close channel at current state• A signed transaction settling current state • Abortable with a secret

2. Capability to take all if other side settles at older state • A secret nullifying deprecated settlement transaction

Page 23: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

23

Multihop Payments

Page 24: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

24

Multihop with HTLC

HTLC: Hash Time-Lock Contract

HTLC (𝐻(𝑆),𝑇,𝐵): Can only claim by knowing S and

B’s signature before time T

Page 25: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

25

Payment Chain – Lightning (HTLC)

𝑆

𝐻(𝑆)

Page 26: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

26

Lightning Network and similar solutionsRequire real-time blockchain access

Page 27: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

Teechain

Page 28: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

28

Software Guard Extensions (SGX)

Untrusted Operating System & Hypervisor

Untrusted Application Code

Code & Data

Untrusted Hardware

TrustedProcessor

1. Confidentiality (including SRNG)2. Integrity 3. Remote attestation

Resilient to software attacks(OS, BIOS, viruses etc.)

Resilient to Physical attacks (ram, disk, bus, peripherals)

Resilient to software attacks(OS, BIOS, viruses etc.)

Page 29: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

29

Software Guard Extensions (SGX)

Untrusted Operating System & Hypervisor

Untrusted Application Code

Code & Data

Untrusted Hardware

TrustedProcessor

Attestation: • Output • Fingerprint • signature

1. Confidentiality (including SRNG)2. Integrity 3. Remote attestation

output

Page 30: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

30

Strawman: single TEE

Page 31: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

31

Strawman: single TEE

Can prevent parties from settling

Page 32: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

32

TEEChain Crux

• TEEs share a secret key, unknown to Alice and Bob • TEE only produces settlement transaction once, then stops

participating

TEEBTEEA

[1] Joshua Lind, Ittay Eyal, Florian Kelbert, Oded Naor, Peter Pietzuch, Emin Gun Sirer. TR. 2017.

Page 33: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

33

Channel Setup

• TEEs form secure channel • Each creates public/private keypair (DH) • Use attestations (Teechain running in sgx)

TEEBTEEA

[1] Joshua Lind, Ittay Eyal, Florian Kelbert, Oded Naor, Peter Pietzuch, Emin Gun Sirer. TR. 2017.

Page 34: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

34

Deposits

• Alice sends money to TEE address • Notifies TEE of deposit

TEEA

deposit a1$100

deposit a2$30

deposit a3$150

Page 35: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

35

Deposit Association

deposit a1$100

deposit a2$30

deposit a3$150

TEEBTEEA

• Alice associates deposit with channel • Instruction to her TEE • TEE produces message for Bob

• Bob verifies that deposit on blockchain

Red channel

Page 36: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

36

Payment

deposit a3$150

TEEBTEEA

Red channel

deposit b3$80deposit b1

$30

• Alice instructs TEE to pay • TEE produces payment confirmation • Alice sends confirmation to Bob (one message)

Page 37: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

37

Deposit Dissociation

TEEBTEEA

• Alice can dissociates unused deposits after confirmation from Bob

• (She can settle channel if dissociation fails)

Red channel

deposit a3$150

deposit b3$80deposit b1

$30

Page 38: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

38

Settlement

deposit a3$150

TEEBTEEA

Red channel

deposit b3$80deposit b1

$30

• Each TEE can settle channel using associated deposits on both sides

• Then stops, no more state updates

Page 39: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

39

Asynchronous Blockchain Access

After deposits are in the blockchain: • Payments without blockchain appends • Parties need not monitor blockchain

Instant Blockchain Payment

Page 40: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

40

Crash Fault Resilience – Persistent Storage

• Naively: store state and reload after failure • Replay attack

• Use monotonic counters• Increment on each store • Only load if count matches

• But: slow… (10/sec)

Page 41: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

41

Crash Fault Resilience – Chain Replication

commandcmd cmd

Output

Can settle But nothing else

Chain broken, no more payments

• But: requires much more resources

withattestation

withattestations

withattestations

Page 42: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

42

AtlanticOcean

Satoshi’s across The Atlantic

Protocol Throughput (no batching)

[k tx/sec]

Throughput (batching) [k tx/sec]

Latency (no batching)

[msec]

Latency (batching)

[msec]

Lightning - 1 - 400

Teechain: no FT 130 150 90 200

Teechain: chain replication

35 135 300 500

Page 43: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

43

Payment Chain - TEEChain

• No blockchain access or monitoring (beyond deposits)

• Any party can settle at any time• Either pre-payment or

post-payment

locklock

lock

signsign

sign

promise Apromise A

promise A

promise Bpromise B

promise B

updateupdate

update

idle idle idle idle

lockedlocked

locked

signedsigned

signed

Promised APromised A

Promised A

Promised BPromised B

Promised B

updatedupdated

updatedrelease

releaserelease

idleidle

idleidle

Page 44: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

44

Conclusion

• Payment channels: potential to resolve scalability issues • Assume either

• synchronous blockchain access (Lightning) or • TEEs (Teechain)

• Middlemen allow multi-hop

₪ ₪

Page 45: Payments Channels and - Law Program · 2019-06-02 · • Payment channels: potential to resolve scalability issues • Assume either • synchronous blockchain access (Lightning)

45

Conclusion

• Payment channels: potential to resolve scalability issues • Assume either

• synchronous blockchain access (Lightning) or • TEEs (Teechain)

• Middlemen allow multi-hop

₪ ₪

Much more, like state channels and

virtual channels