41
FLYCLIENT Loi Luu, Benedikt Bünz, Mahdi Zamani SUPER LIGHT CLIENT FOR CRYPTOCURRENCIES

FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

FLYCLIENT

Loi Luu, Benedikt Bünz, Mahdi Zamani

SUPER LIGHT CLIENT FOR CRYPTOCURRENCIES 

Page 2: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

Hash chain of blocks

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Hash tree (Merkle tree) of transactions in each block

Recall: Bitcoin blockchain format

2

Page 3: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

Hash chain of blocks

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Validity of a blockchain

✅✅✅✅

1. Transactions are valid2. Merkle tree correct

3

Page 4: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

mrkl_root: H( )

prev: H( )

mrkl_root: H( )

hash: 0x0000

nonce: 0x7a83

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

mrkl_root: H( )

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

≤ 00000000000000001FB893000000000000000000000000000000000000000000

70+ leading zeroes required...

Hash

3. Validity of a block header

4

Page 5: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Two valid blockchains?This is the

blockchain

No this is the blockchain

5

Page 6: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Longest chain rule

❗�

Take the longest chain!Harder to produce.

6

Page 7: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Proof of work conjecture

• Honest mining is a dominant equilibrium strategy • The majority of miners act rational

• Implies that longest chain follows the rules of the network

• Sleeping beauty property: You can always distinguish honest and honest chains after being offline

• Does not (necessarily) hold for proof of stake

• As long as one of the nodes you are connected to is honest you will find the best chain

7

Page 8: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Blockchain size: A growing problem

How am I going to store 150 GB

8

Page 9: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Simple Payment Verifying Client (Satoshi 2008)

Just store the block headers

9

Page 10: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

mrkl_root: H( )

prev: H( )

mrkl_root: H( )

hash: 0x0000

nonce: 0x7a83

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

mrkl_root: H( )

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

≤ 00000000000000001FB893000000000000000000000000000000000000000000

70+ leading zeroes required...

Hash

Verify block headers

10

Page 11: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Use the longest chain rule

❗�

11

Page 12: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Can’t verify all transactions (but that’s ok)

❓❓❓❓

Assumption:Longest chain is produced honestly

12

Page 13: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

transaction

Can verify specific transactions (with help)

13

Page 14: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

H( )

 

transaction

Can verify specific transactions (with help)

 

 

14

Page 15: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

15

SPV Properties and Problems• Can determine the longest chain

• Can verify transaction inclusion

• Does not grow with #transactions

• 80 bytes * #blocks (Bitcoin)

• 508 bytes * #blocks (Ethereum)

• Sufficient for sidechains and swaps

• Can’t verify all transactions

• Grows with #blocks

• Less block time-> larger SPV client

• 40 MB in Bitcoin

• 2.2 GB in Ethereum

• Especially bad for multi-chain clients

Page 16: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

• SNARK or CS-Proof/CIP/STARK (Micali 91, Ben-Sasson et al. 17)

• Constant size non-interactive proof that chain has length X

• Circuit verifies full blockchain

• Not practical for prover

• SNARKs closer to being practical but trusted setup

Sublinear SPV-Clients: SNARKs

16

Page 17: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

• Kyriasis, Miller, Zindros 17• Based on Kiayias, Lamprou, Stouka 16 and Back et al. 14

• Insight: If I want to find x such that H(x) has n 0s then I will find 2 x’ such that H(x’) has n-1 0s, 4 x’’ such that H(x’’) has n-2 0s …

• Best quality proof of work indicates quality of whole chain

• Use a skiplist to point to proofs with less proofs of work

• O(log(n)*log(log(n))) proof size

Sublinear SPV-Clients: NiPoPoWs

17

Page 18: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

• High quality blocks do not give extra reward

• But they are important for NiPoPows1

• Bribe honest rational miners to throw away super high quality blocks

• Main chain “looks” worse which makes fooling SPV client easier

• Does not violate NiPoPow’s security proof because honest mining and not rational mining is assumed

• Motivates search for different NiPoPows

NiPoPoW bribery attack

18

Page 19: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Append L2 Append L3

L0 L1

Root 0

L0L2

L1

Root 1

L1L0 L3L2

Root 3

Merkle Mountain Ranges (Todd 16)

Log(n) inclusion proofsLog(n) updatesnth tree commits to kth tree k<nLog(n) difference proofs

Page 20: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: A different approach to super-light clients

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

20

Page 21: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: A different approach to super-light clients

trans: H( )

root: H( )

trans: H( )

root: H( )trans: H( )

root: H( )

Store just the head

21

Page 22: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: A different approach to super-light clients

trans: H( )

root: H( )trans: H( )

root: H( )

Store just the head

Merkle Tree

22

Page 23: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

transaction

trans: H( )

root: H( )trans: H( )

root: H( )

Verifying Transaction

H( )

  

 

 

Chain head

23

Page 24: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: Two heads?This is the

head

No this is the head

❓ Assumption:At least one

chain is honest

Other one has at most a c fraction

of the mining power

Ex: c=1/3

24

Page 25: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 1

Give me k blocks:

7,13,210…

25

Page 26: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 1: sample constant # of blocks

Sample k blocks + Merkle inclusion proof for each

26

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Page 27: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 1: sample constant # of blocks

 

27

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Page 28: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 1: sample constant # of blocks

 

28

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Page 29: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 1: sample constant # of blocks

 

29

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Page 30: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 1 problem: Forking

30

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Page 31: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient idea: Find Fork Point

31

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Knowing this point suffices

︸Sample blocks after fork

Page 32: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 2: Interactive Binary Search

32

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Binary search to find fork point

Log(n) messages

Page 33: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Strawman 2: Interactive Binary Search

33

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Binary search to find fork point

Log(n) messages

Works but two provers may not want to interact

Page 34: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: Idea bound forking point

34

Honest chainHead 1

Head 2 

Page 35: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: Idea bound forking point

35

Honest chainHead 1

Head 2 

 

Page 36: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: Idea bound forking point

36

Honest chainHead 1

Head 2Step 3: Repeat

 

Page 37: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: Idea bound forking point

37

Honest chainHead 1

Head 2Step 3: Repeat

 

Page 38: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient: Idea bound forking point

38

Honest chainHead 1

Head 2Step 4: Check final L blocks (to prevent short forks)

Page 39: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Flyclient Analysis

• In each interval check k blocks, k independent of chain length n

• k dependent on attacker strength

• Check log(n) intervalls

• For each block do log(n) merkle inclusion proof

• O(log(n)^2) overall

• For n=1000000->

39

Page 40: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Non Interactive Flyclient

40

Page 41: FLYCLIENT - Scaling Bitcoin · • Less block time-> larger SPV client • 40 MB in Bitcoin • 2.2 GB in Ethereum • Especially bad for multi-chain clients • SNARK or CS-Proof/CIP/STARK

Thanks

bbuenz.github.io

[email protected]