the blockchain

48
Cryptocurrency Cabal cs4501 Fall 2015 David Evans and Samee Zahur University of Virginia Class 7: The Blockcha in

Upload: david-evans

Post on 09-Jan-2017

10.343 views

Category:

Economy & Finance


1 download

TRANSCRIPT

Page 1: The Blockchain

Cryptocurrency Cabalcs4501 Fall 2015David Evans and Samee ZahurUniversity of Virginia

Class 7:The

Blockchain

Page 2: The Blockchain

2

Page 3: The Blockchain

3

Plan for TodayTrustDistributed ConsensusProof-of-WorkBlockchain

Next Wednesday: Checkup 2Classes through next MondayCheckup 1, PS1Readings:

Satoshi paperAntonopoulos book: Ch 6 and 7Princeton book: Ch 2 and 5

Page 4: The Blockchain

4

Where does trust come from?

Page 5: The Blockchain

5http://www.jdsurvey.net/jds/jdsurveyMaps.jsp

Page 6: The Blockchain

6Image credit: https://howveryromanian.wordpress.com/2013/09/15/bag-wrapping/

Queuing for cooking oil (Bucharest, 1986) Scott Edelman

Page 7: The Blockchain

7Image: Queerbubbles CC BY-SA

Page 8: The Blockchain

8

Page 9: The Blockchain

9

Sources of TrustYourself (super trustworthy!)Mathematics and Science

Trustworthy because of logic, verified experimentsOrganizations and People

Trustworthy because of what they have to lose (reputation)Trustworthy because of trusted oversight (law, police)Trustworthy because incentives are alignedTrustworthy because of processes they follow

Page 10: The Blockchain

10

Bitcoin’s solution: a public ledgerTrust in resources

Page 11: The Blockchain

11

Public Ledger

Node A Node B Node C

M = transfer X to BobSignKRA[H(M)] Bob wants to verify:1. Alice hasn’t already transferred X2. The coin will be valuable for Bob

Page 12: The Blockchain

12

Public Ledger: Distributed Trust (?)

Node A Node B Node C

M = transfer X to Bob Bob wants to verify:1. Alice hasn’t already transferred X2. The coin will be valuable for Bobtb

tb tb tb

SignKRA[H(M)]

Page 13: The Blockchain

13

Node A Node B Node C

M = transfer X to Bob Bob wants to verify:1. Alice hasn’t already transferred X2. The coin will be valuable for Bobtb

tb tb tbok!

ok!

t

Transactions

1 tb (X->Bob)Transactions

1 tb (X->Bob)

SignKRA[H(M)]

Page 14: The Blockchain

14

Node A Node B Node C

Bob wants to verify:1. Alice hasn’t already transferred X2. The coin will be valuable for Bob

tb

tb tb tbok!

ok!

t

Transactions

1 tb (X->Bob)Transactions

1 tb (X->Bob)

Page 15: The Blockchain

15

Node A Node B Node C

M = transfer X to Cathytc

tc tc tcBAD!

t

Transactions

1 tb (X->Bob)Transactions

1 tb (X->Bob)Transactions

1 tc (X->Cathy)

SignKRA[H(M)]

Page 16: The Blockchain

16

Scaling the Network

Node A Node B Node C

ta

tb tb

Node D Node E Node F Node G

Page 17: The Blockchain

17

Blockchain

Public ledger without fixed set of nodes – decentralized, distributed trustRequires coalition with majority of computing power to collude to cheat

Page 18: The Blockchain

18

Blockchain

B0H(B0) Nonce

Transactions

H(B1) Nonce

Transactions

H(B2) Nonce

Transactions

Page 19: The Blockchain

19

Inconsistent Blockchains

Node A Node B Node C

Node D Node E Node F Node G

How do we know which blockchain is “correct”?

Page 20: The Blockchain

20

CRYPTO 1992

Cynthia Dwork(now at MSR)

Moni Naor(Weizmann Institute)

Page 21: The Blockchain

21

Page 22: The Blockchain

22

Idea: Proof-of-WorkPricing Function: (f)

- moderately easy to compute- cannot be amortized computing f(m1),…, f(ml) costs l times asmuch as computing f(mi). - easily verified: given x, y easy to check y = f(x)

Page 23: The Blockchain

23

Proposed Pricing Function

Extracting Square Rootsindex: pfind x, y such that y2 = x mod p

Dwork and Naor proposed two other pricing functions, designed to have “shortcuts” (backdoors) to allow administrators to compute them efficiently.

Page 24: The Blockchain

24

Hashcash

Adam Back 1997

Page 25: The Blockchain

25

Interactive Hashcash

mail sender mail recipient’s server

Hello

Challenge: rr random nonce

Everyone agrees on one-way function f

Page 26: The Blockchain

26

Interactive Hashcash

mail sender mail recipient’s server

Hello

Challenge: rr random nonce

search for x such thatf(x) = r

Everyone agrees on one-way function f

(x, Mail)

Page 27: The Blockchain

27

Interactive Hashcash

mail sender mail recipient’s server

Hello

Challenge: rr random nonce

search for x such thatf(x) = r

Everyone agrees on one-way function f

(x, Mail) Verify f(x) = r

Page 28: The Blockchain

28

Interactive Hashcash

mail sender mail recipient’s server

Hello

Challenge: rr random nonce

search for x such thatf(x) = r

Everyone agrees on one-way function f

(x, Mail) Verify f(x) = r

Can we make this non-interactive?

Page 29: The Blockchain

29

Non-Interactive Hashcash

mail sender mail recipient’s server

Everyone agrees on one-way function f

Verify

Page 30: The Blockchain

30

Non-Interactive Hashcash

mail sender mail recipient’s server, s

Everyone agrees on one-way function f

How well would this work if f is SHA-256?

msg || x

Verify f(msg || x) = s

Page 31: The Blockchain

31

Pre-image Attack on SHA-256search for x such thatf(msg || x) = s

Page 32: The Blockchain

32

Estimated hash rate of entire bitcoin network:441,695,290 GH/s

Page 33: The Blockchain

33

Page 34: The Blockchain

34

Variable-Difficulty fChallenge: r, Difficulty: d

Find an x such that: SHA-256(msg || x) < T/d T is some set “target”.

If the difficulty doubles, how much more work is expected?

Page 35: The Blockchain

35

Bitcoin’s Proof-of-Work

Find an x such that: SHA-256(SHA-256(r + x)) < T/d

Why use double SHA-256?

Page 36: The Blockchain

36http://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security

Page 38: The Blockchain

38https://bitcoinwisdom.com/bitcoin/difficulty

Difficulty adjusts (every 2016 blocks) to keep block-finding time around 10 minutes

Page 39: The Blockchain

39https://bitcoinwisdom.com/bitcoin/difficulty

Page 40: The Blockchain

40

Finding the Next Block

B0H(B0) Nonce

Transactions

H(B1) Nonce

Transactions

H(B2) Nonce

Transactions

Find a nonce x such that: SHA-256(SHA-256(r + x)) < T/d

Page 41: The Blockchain

41

Finding the Next Block

B0H(B0) Nonce

Transactions

H(B1) Nonce

Transactions

H(B2) Nonce

Transactions

Find a nonce x such that: SHA-256(SHA-256(r + x)) < T/dr = header + transactions (including mining fee)header = H(previous block)

Page 42: The Blockchain

42

Actual Bitcoin Block

https://en.bitcoin.it/wiki/Protocol_documentation#Block_Headers

Page 43: The Blockchain

43

Inconsistent Blockchains

Node A Node B Node C

Node D Node E Node F Node G

The longest blockchain is the “right” one.

Page 44: The Blockchain

44

Page 45: The Blockchain

45

Page 46: The Blockchain

46

What happened to proof-of-work for sending email?

Page 47: The Blockchain

47

Instead of making computers do inane, repetitive work to prevent mass automation, we make humans do inane, soul-killing work!

Page 48: The Blockchain

48

ChargeReadings:

Satoshi paperAntonopoulos book: Chapters 6 and 7Princeton book: Chapters 2 and 5

Wednesday: Checkup 2