cryptocurrency and blockchain research · 2018. 3. 15. · replacing nonce with attestation suppose...

45
Cryptocurrency and Blockchain Research CHANATHIP NAMPREMPRE, PH.D. 1

Upload: others

Post on 11-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Cryptocurrency and Blockchain ResearchCHANATHIP NAMPREMPRE, PH.D.

1

Page 2: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Agenda

Recall bitcoin consensus protocol

Components of bitcoin consensus protocol

Variations on the same theme

Beware of snake oil

Solution: secure protocol design and analysis

Example from cryptography: modes of operation

Conclusion

2

Page 3: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Recall bitcoin blockchain: adding a block

Genesis block

The Times

03/Jan/2009

Chancellor

on brink of

second

bailout for

banks

nonceH(•)tx1

tx2

To add the next block, find “nonce” such that00…..0xxxxxx…xxxx = H( nonce ph tx1 tx2 … )

ph•••

txn(reward)

3

nonceH(•)tx1

tx2

ph

txn(reward)

Page 4: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Recall bitcoin blockchain: forking

Genesis block

The Times

… bailout for

banks

H(•)ph

••• H(•)

tx1

ph

H(•)

tx1’

ph

H(•)ph

H(•)ph

4

Page 5: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Bitcoin consensus protocol: GOAL

All honest participants agree on the order in which blocks are appended to the chain.

5

The Times

03/Jan/2009

Chancellor

… bailout for

banks

H(•)

tx

ph••• H(•)

tx

phH(•)

ph

tx

tx

tx

tx

Page 6: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Bitcoin consensus protocol

1. New transactions are broadcast to all nodes.

2. Each node collects new transactions into blocks.

3. In each round, a winning node gets to add its block to the chain.

4. Other nodes accept the block only if all transactions in it are valid.

5. Nodes express their approval of the block by including its hash in the next block they create.

source: Bitcoin and Cryptocurrency Technology, Narayanan, et. al. 2016

“Leader” election

Transactions record money transfers.

6

Ledger is a blockchain.

Page 7: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

TransactionBitcoin Bitcoin: money transfer

Alternatives:

• smart contracts

• medical records

• college degrees

• …

7

Transaction ID 73in:

H(•), index, signature, pkH(•), index, signature, pkH(•), index, signature, pk

out:index, value, H(pk)index, value, H(pk)index, value, H(pk)

Transaction ID 68in:

H(•), index, signature, pkH(•), index, signature, pkH(•), index, signature, pk

out:index, value, H(pk)index, value, H(pk)index, value, H(pk)

Transaction ID 42in:

H(•), index, signature, pkH(•), index, signature, pkH(•), index, signature, pk

out:index, value, H(pk)index, value, H(pk)

scriptSig

scriptPubSig

redeeming transactionreferenced transaction

referenced transaction 7

Page 8: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

LedgerBitcoin Bitcoin: chain of blocks

ledger = blockchain

Alternatives:

• individual transactions

ledger = Directed Acyclic Graph

(GHOST, SPECTRE, Meshcash, Hashgraph, etc.)

• “batched” transactions

(IOTA)

8

The Times

03/Jan/2009

Chancellor

… bailout for

banks

H(•)

tx

ph••• H(•)

tx

phH(•)

ph

tx

tx

tx

tx

Page 9: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Leader electionBitcoin Bitcoin: proof-of-work

Alternatives:

• proof-of-stake

(Ouroboros, Algorand)

• proof-of-elapsed-time

(Sawtooth Lake)

• proof-of-luck

(Berkeley)

• …9

To add a block to the chain, find “nonce” such that

00…..0xxxxxx…xxxx = H( nonce ph tx1 tx2 … )

Page 10: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Leader election via Proof-of-Elasped-Time (PoET)

Observation:

Bitcoin proof-of-work, namely the nonce, is evidence that the winning node has taken about 10 minutes to find a nonce that works.

Alternative:

A node can just wait 10 minutes then can provide a proof that it has waited.

10

00…..0xxxxxx…xxxx = H( nonce ph tx1 tx2 … )

Page 11: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Intel SGX (Software Guard eXtensions)

Attestation:

Prove to a remote party what software was loaded on my machine

Applications:

• Bank allows money transfer only if customer has patched his device.

• Gamers can join network only if their game client is unmodified.

Source: Dan Boneh’s course notes.

11

Page 12: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Replacing nonce with attestationSuppose P is the program “wait 10 minutes”

12

P

Attestation server

Intel SGX

attestation

attestation

H(•)tx1

tx2

ph

txn(reward)

Page 13: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Participation in protocolBitcoin Bitcoin: permissionless with

dynamic join/leave

Alternatives:

• permissioned with static membership

• permissioned with semi-static membership (no join/leave during each “round”, but ok between “rounds”)

• …

13

Page 14: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Participation in leader election protocolBitcoin Bitcoin: all mining nodes

Alternatives:

• a fixed subset (e.g., Honey Badger)

• a dynamic subset [e.g.,

endorsers (Ouroboros)

committee members (Algorand)

validators (Tendermint)

trusted quorums (Stellar), …]

14

Page 15: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Participation in leader election protocolBitcoin Bitcoin: all mining nodes

Alternatives:

• a fixed subset (e.g., Honey Badger)

• a dynamic subset [e.g.,

endorsers (Ouroboros)

committee members (Algorand)

validators (Tendermint)

trusted quorums (Stellar), …]

15

Page 16: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Failure modesBitcoin Bitcoin: Byzantine

Alternatives:

• fail-stop (crash only)

• honest-but-curious

• honest-but-lazy

(in this model, Algorand can tolerate failure of majority of nodes!)

• …

16

Page 17: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

ClocksBitcoin Bitcoin: loosely synchronized (NTP)

Alternatives:

• strongly synchronized

• same speed (Algorand)

• …

17

Page 18: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Message delivery modelBitcoin Bitcoin: unreliable

Alternatives:

• reliable with known delay

(msgs are delivered correctly and exactly once within a certain amount of time)

• reliable with unknown delay

18

dropped/modified/ injected

Page 19: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Timing modelBitcoin Bitcoin: asynchronous

(msgs can take arbitrarily long to arrive, and processor speeds can be vastly different)

(different from the ‘A’ in AJAX)

Alternatives:

• synchronous

(msg delays are bounded, and differences in processor speeds are bounded)

• eventually synchronous

• weakly synchronous

• strongly synchronous

• …19

fastslow

Page 20: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Timing model [Dwork and Lynch, 1988]

In a synchronous system, there is a known fixed upper bound A on the time required for a message to be sent from one processor to another and a known fixed upper bound B on the relative speeds of different processors.

In an asynchronous system, no fixed upper bounds A and B exist.

In an eventually synchronous system, the system is synchronous most of the time but may experience periods of asynchrony.

20

Page 21: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Consensus protocol example: AlgorandTransaction: any

Ledger: blockchain

Leader election: proof-of-stake

Participation: permissionless

Participation in leader election: committee

Failure modes: byzantine

Message delivery: reliable (gossip protocol)

Timing: strong synchrony (liveness)

weak synchrony (safety)

Clock: same speed

21

Page 22: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Recall Bitcoin consensus protocol

1. New transactions are broadcast to all nodes.

2. Each node collects new transactions into blocks.

3. In each round, a winning node gets to add its block to the chain.

4. Other nodes accept the block only if all transactions in it are valid.

5. Nodes express their approval of the block by extending the chain from it.

22

a. Select committee members based on stakesb. Committee members vote on winner based on stakes

Page 23: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Algorand

a. Select committee members based on stakes• Cannot be done deterministically

• Cannot be done in multiple steps

• Must be done in secret

b. Committee members vote on winner based on stakes

23

committee members may be targeted!

sortition

Page 24: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Verifiable Random Function (VRF)

VRF = (F, VF) such that, for any public-secret key pair (pk,sk),

• (h,p) = F(sk,x)

On input x, the algorithm F returns a hash and a proof.

The hash h is “random” to anyone who does not know sk.

• b = VF(pk,x,h,p)

On input pk, x, h, and p, the algorithm VF returns a bit.

The proof p lets anyone with pk verify that h corresponds to x.

24

Page 25: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Implementing VRF with digital signatures

VRF = (F, VF) such that, for any public-secret key pair (pk,sk),

• (h,p) = F(sk,x)

On input x, the algorithm F returns a hash and a proof.

The hash h is “random” to anyone who does not know sk.

• b = VF(pk,x,h,p)

On input pk, x, h, and p, the algorithm VF returns a bit.

The proof p lets anyone with pk verify that h corresponds to x.

25

p Sign( sk, x ) ; h H( p )

Vf( pk, x, p ) ˄ h == H( p )

Page 26: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Algorand (much simplified)

a. Select committee members based on stakes• Cannot be done deterministically

• Cannot be done in multiple steps

• Must be done in secret

b. Committee members vote on winner based on stakes

26

(h,p) VRF(sk, seed||role)

• seed0 agreed through distributed random number generation

• seedr = hr

Page 27: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Algorand (much simplified)

a. Select committee members based on stakes• Cannot be done deterministically

• Cannot be done in multiple steps

• Must be done in secret

b. Committee members vote on winner based on stakes

27

(h,p,j) Sortition(sk, seed,role,w,W)

Page 28: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Algorand (much simplified)

a. Select committee members based on stakes• Cannot be done deterministically

• Cannot be done in multiple steps

• Must be done in secret

b. Committee members vote on winner based on stakes

Block with highest priority wins.

28

For i in {1,…,j},block priority max(block priority, H(h||i))

(h,p,j) Sortition(sk, seed,role,w,W)

Page 29: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Algorand claims

75-page paper with tons of proofs of

• safety

• liveness

• other properties

under various timing models, message delivery models, etc.

29

Page 30: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

others?

30

Page 31: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Being able to model the system helps!

31

Summary of consensus resilience properties, some of which use statically configured nodes with a special role.

Symbols and notes: ‘✓’ means that the protocol is resilient against the fault and ‘−’ that it is not; ‘.’ states that no such special node exists in the protocol; ‘?’ denotes that the properties cannot be assessed due to lack of information; (✓) denotes the crash of other nodes, different from the special node; + MultiChain has non-final decisions; ⊕ PoET assumes trusted hardware available from only one vendor; ⊗ Ripple tolerates one of the five default Ripple-operated validators (special nodes) to be subverted.

Source: Blockchain consensus protocols in the wild. Christian Cachin and Marko Vukolic. IBM Zurich. 2017.

Page 32: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Results from distributed systems research• FLP: In an asynchronous model with reliable links, no deterministic

protocol can achieve consensus when at least one party can crash.

[ asynchronous parties, reliable links, f ≥ 1 in fail-stop model ]

• PBFT: In an eventually synchronous model with reliable links, parties running PBFT protocol can reach consensus as long as no more than one third of all parties can be malicious.

[ eventually synchronous parties, reliable links, f ≤ n/3 in byzantine model ]

[FLP]: Impossibility of Distributed Consensus with One Faulty Process, Fischer, Lynch, and Paterson, 1985.

[PBFT]: Practical Byzantine Fault Tolerance, Castro and Liskov, 1999.

32

Page 33: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Meanwhile…

We still see claims like this:

“Every transaction is replicated to every node. When a majority of nodes have replicated the transaction, the transaction is committed.” – Kadena based on ScaleableBFT

Model: asynchronous with byzantine failures

33

Page 34: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Snake oil?

Unsupported, hard to verify claims abound.

This situation has happened before!

Look at the history of modern cryptography.

34

Page 35: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Block ciphers and modes of operation

FIPS-80: DES and modes of operation

Various modes proposed: ECB, CBC, CTR, OFB, CFB

Assuming that the underlying block cipher is perfect, are these modes any good?

35

Page 36: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

ECB encryption mode: definition

36

Source: Symmetric Cryptography Basics, Chanathip Namprempre, 2011.

Page 37: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

ECB encryption mode: secure?

37

Source: Wikipedia

Page 38: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

ECB insecurity

38

Page 39: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Modeling primitives and defining security definitions

Block cipher

• What is it: family of permutations

• What it means to be secure: PRP-CPA, PRP-CCA

Symmetric encryption scheme

• What is it: three algorithms satisfying a correctness condition

• What it means to be secure: IND-CPA, IND-CCA

39

Page 40: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Results?

• ECB is not IND-CPA.

• CBC with counter IV is not IND-CPA.

• CBC with random IV is IND-CPA but not IND-CCA.

• CTR with random IV is IND-CPA but not IND-CCA.

• CTR with counter IV is IND-CPA but not IND-CCA.

• CTR with counter IV is more secure than CTR with random IV.

• etc.

40

Page 41: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Theory catching up with practice

Modern cryptography

• Block ciphers were proposed and used.

• Then, models and proofs were developed.

41

Cryptocurrencies and distributed systems

• Bitcoin is proposed and used.

• Then, models and proofs are being developed!

Page 42: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

What makes a good consensus protocol?

Efficient:

• throughput? latency? average case? worse case?

Secure:

• DOS? targeted attack?

• Prevent/eliminate forks?

• Liveness? Safety?

42

Page 43: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

Safety and LivenessSafety: Nothing bad happens.

With overwhelming probability, all nodes agree on the same order of transactions.

If one honest node accepts transaction A (i.e., it appears on the chain), then with overwhelming probability any future transactions accepted by other honest nodes will be on the chain that already contains A.

Liveness: Something good eventually happens.

With overwhelming probability, new transactions get added to the chain.

During synchronous period, with overwhelming probability honest nodes eventually add a new transaction to the chain.

43

Page 44: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

State of the art

Security models and proofs for “blockchain” systems are emerging.

But the models and security definitions are complicated and hard to work with.

Plenty of room for improvement! We can start with devising simpler, cleaner models and definitions.

44

Page 45: Cryptocurrency and Blockchain Research · 2018. 3. 15. · Replacing nonce with attestation Suppose P is the program wait minutes 12 P Attestation server Intel SGX attestation attestation

45