SLIDE 1 CS 683 - Security and Privacy Spring 2018
Instructor: Karim Eldefrawy
University of San Francisco
http://www.cs.usfca.edu/~kelde frawy/teaching/spring2018/cs6 83/cs683_main.htm (https://goo.gl/t396Fw)
1
SLIDE 2 Ba Basi sics s of
Bloc
based d Cr Cryptoc
rrencies s and Systems
SLIDE 3
A A good d so sour urce for more information
Slides of this lecture are largely based on those presented in accompanying videos (for lectures 1 and 2) at: http://bitcoinbook.cs.princeton.edu/
SLIDE 4
Crypto Back ckground: Hash Funct ctions, Hash Po Pointers, and Hash Po Pointer-ba based d Data Struct ctures
SLIDE 5 Has Hash h Func Functio tions ns
- Functional requirements:
- Takes any string or arbitrary length as input
- Fixed-size output (we will use 256 bits as an example)
- Efficiently computable
- Security requirements:
- Collision-free
- Hiding
- Puzzle-friendly
SLIDE 6 Pr Property 1 of Hash Functions: Collision-fr free
- No adversary can find x and y such that
x ≠ y and H(x) = H(y)
X H(X) = H(y) Y
SLIDE 7 Ho How w to find ind a a collis llisio ion? n?
- Try 2130 randomly chosen inputs
(for a 256 bit hash output)
- 99.8% chance two of them will
collide This works no matter how H is constructed … but takes long to be a serious attack that matters
SLIDE 8
Appl Application: n: ha hash sh as s messa ssage di digest
SLIDE 9
Pr Property 2 of Hash Functions: Hiding
SLIDE 10
Pr Property 2 of Has Hash h Func Functio tions ns: Hiding Hiding
SLIDE 11 Appl Application: n: Co Commitment
X X
Commit Open
SLIDE 12
Co Commi mmitme ment AP API 1/ 1/3
SLIDE 13
Co Commi mmitme ment AP API 2/ 2/3
SLIDE 14
Co Commi mmitme ment AP API 3/ 3/3
SLIDE 15 Pr Property 3 3 of
Hash F Function
: Pu Puzzle-fr friendly
SLIDE 16
Appl Application: n: Search h puz puzzle
SLIDE 17
SH SHA-256 256
SLIDE 18
Has Hash h Poin inter ers
SLIDE 19
Ka Kay Idea
Utilize hash pointers to build efficient integrity ensuring data-structures
SLIDE 20
Has Hash h po poin inter er chaining haining
SLIDE 21
Has Hash h po poin inter er chaining haining
SLIDE 22
Has Hash h po poin inter er chaining haining
SLIDE 23 Tr Tree using hash pointers
Root Hash
We have seen this before; in what context?
SLIDE 24
Adv Advantages s of f Merkel Trees
SLIDE 25 Mo More generally …
Can use hash pointer in any pointer-based data structure that has no cycles
- Hash pointers will ensure integrity of
information stored/used in the data structure
SLIDE 26 Dig Digit ital S al Sig ignatures in in t the C Context o
Cr Cryp yptocurr rrencies
SLIDE 27
Re Requirements of a digital signature scheme
SLIDE 28
AP API for di digi gital si signa gnatur ures
SLIDE 29
Re Requirements for signatures
SLIDE 30
Se Securi rity game me for r a signature scheme me
SLIDE 31
Se Securi rity game me for r a signature scheme me
SLIDE 32
Se Securi rity game me for r a signature scheme me
SLIDE 33
Se Securi rity game me for r a signature scheme me
SLIDE 34
Se Securi rity game me for r a signature scheme me
SLIDE 35
Addi Additiona nal issue ssues
SLIDE 36 Wha What si signa gnatur ure sc sche heme is s use used d in n Bitcoin
ECDSA is the elliptic curve version of the DSA standard which is similar to El-Gamal signature scheme.
SLIDE 37
Us Useful l tr tric ick: use e public lic key as as an an id iden entity tity
SLIDE 38 Ho How w to gener enerate e a a ne new w iden identity tity
In practice: use H(pk) as identity as it is smaller than pk
SLIDE 39
De Dece centraliz alized id identit ity m man anag agement
SLIDE 40
Pr Privacy is complicate ated
Addresses not directly connected to real-world identity. (Un)linkability: But observer can link together an address’s activity over time, and make inferences.
SLIDE 41
Si Simp mple Examp mples of Cr Cryptocurr rrency Designs
SLIDE 42
At Attempt #1: Goofy Coin
SLIDE 43 Op Operation of f Goofy y Co Coin 1/3
Rule #1:
SLIDE 44 Op Operation of f Goofy y Co Coin 2/3
Rule #2:
SLIDE 45 Op Operation of f Goofy y Co Coin 3/ 3/3
Rule #3:
SLIDE 46 Bi Big se securi rity y issu ssue with Goofy y Co Coin
Double-Spending
Double-spending is one of the hardest security challenges to solve when developing a cryptocurrency
SLIDE 47
At Attempt #2: Scrooge Coin
SLIDE 48
Op Operation of f Scrooge Co Coin 1/3
SLIDE 49 Op Operation of f Scrooge Co Coin 2/ 2/3
Transaction Type #1:
SLIDE 50 Op Operation of f Scrooge Co Coin 3/3 /3
Transaction Type #2:
SLIDE 51
Im Immut utable able Coins ins
SLIDE 52 Th The main problem with Scrooge Coin
Crucial question: Can we descroogify the currency, and
- perates without any central, trusted
party?
SLIDE 53
Ho How w Bit itcoin in solv lves es the the dec decen entr traliz alizatio tion n is issue ue
SLIDE 54 Bi Bitcoin’s s Peer-to to-Pe Peer Network
- A peer-to-peer network without any “central” authority for
ensuring integrity of transactions and keeping track of
- wnership of (Bit)coins (and minting them)
- Ledger and history of ALL transactions are public and
available for anyone to inspect
SLIDE 55 Ce Centralizations s vs s Decentralizations
- Competing paradigms that underlie many digital technologies
Sir Tim Berners-Lee (inventor of the Web)
SLIDE 56 De Dece centraliz alizatio ion is is n not all all-or
nothi hing ng
Decentralized protocol, but dominated by centralized webmail services.
SLIDE 57 Aspe Aspects s of f de decentralization n in n Bi Bitcoin
- Who maintains the ledger?
- Who has authority over which transactions are valid?
- Who creates new bitcoins?
- Who determines how the rules of the system change?
- How do bitcoins acquire exchange value?
- Beyond the protocol:
Exchanges, wallet software, service providers …
SLIDE 58
Aspe Aspects s of f de decentralization n in n Bi Bitcoin
SLIDE 59
Bi Bitcoin’s s key y challenge: distri ributed conse sensu sus
SLIDE 60 Wh Why y conse nsensus nsus pr protocols? s?
- Traditional motivation: reliability in distributed systems.
- Distributed key-value store enables various applications:
DNS, public-key directory, stock trades, databases … etc.
Good target for Altcoins!
SLIDE 61 De Defin inin ing d dis istrib ibuted c consensus
- Assume N servers/processors/processes.
- The protocol terminates and all correct nodes decide on the same
value (V).
- The value V must have been proposed by some correct node.
- Typically assume honest majority, e.g., less than N/3 or N/2 are
misbehaving.
SLIDE 62 Bi Bitcoin is s a peer-to to-peer peer system em
Note: Bob’s computer is not in the picture
coin’s history Alice’s transaction is broadcast/flooded throughout the Bitcoin network
SLIDE 63 Ho How w cons nsens ensus us co could wo work in Bitcoin
At any given time:
- All nodes have a sequence of blocks of transactions they’ve reached
consensus on
- Each node has a set of outstanding transactions it’s heard about (but
consensus has not happened for them yet)
SLIDE 64 Ho How w cons nsens ensus us co could wo work in Bitcoin
Consensus reached on these blocks
SLIDE 65
How consensus could work in Bitcoin
SLIDE 66
Ho How w cons nsens ensus us co could wo work in Bitcoin
SLIDE 67 Ho How w cons nsens ensus us co could wo work in Bitcoin
The green block is chosen as a result of consensus and is added to the agreed-upon blockchain. This is close to how Bitcoin cloud work, but not exactly. Why? Consensus reached on these blocks
SLIDE 68 Wh Why y conse nsensus nsus is s ha hard
No notion of global time!
SLIDE 69 Ma Many imp mpossibility results
- Byzantine generals problem:
https://en.wikipedia.org/wiki/Byzantine_fault_tolerance#B yzantine_Generals'_Problem
- Fischer-Lynch-Paterson (deterministic nodes): consensus
impossible with a single faulty note
SLIDE 70 So Some me well-kn known conse sensu sus s protocols
http://www.cs.yale.edu/homes/aspnes/pinewiki/Paxos.html
SLIDE 71
Un Under erstan andin ing im impossib ibility ility res esults lts
SLIDE 72
Bi Bitcoin conse sensu sus: s: theory y vs s practice
SLIDE 73 So Some me things Bi Bitcoin does differently
Bitcoin does not solve the (large-scale) consensus problem in the general sense, but only in the context of a digital currency system.
SLIDE 74 Wh Why y ide dentity? y?
Why don’t Bitcoin nodes have identities?
- Identity is hard in a P2P system – Sybil attack
- Pseudonymity is a goal of Bitcoin
SLIDE 75
We Weaker assumption: select random nodes
SLIDE 76
Ke Key idea: implicit consensus
SLIDE 77
Bi Bitcoin conse sensu sus s algori rithm m (si (simp mplifi fied)
SLIDE 78
Wha What can n a malicious us no node de do do?
SLIDE 79
Wha What can n a malicious us no node de do do?
SLIDE 80
Wha What can n a malicious us no node de do do?
SLIDE 81
Wha What can n a malicious us no node de do do?
SLIDE 82
Wha What can n a malicious us no node de do do?
SLIDE 83 Wha What can n a malicious us no node de do do?
Honest nodes will extend the longest valid branch.
SLIDE 84
Fr From Bob b the the mer erchan hant’s po poin int t of vie view
SLIDE 85
Fr From Bob b the the mer erchan hant’s po poin int t of vie view
SLIDE 86
Fr From Bob b the the mer erchan hant’s po poin int t of vie view
SLIDE 87
Fr From Bob b the the mer erchan hant’s po poin int t of vie view
SLIDE 88
Fr From Bob b the the mer erchan hant’s po poin int t of vie view
SLIDE 89
Fr From Bob b the the mer erchan hant’s po poin int t of vie view
SLIDE 90
Re Recap
SLIDE 91
Assum Assumption n of f ho hone nesty y is s pr probl blematic
SLIDE 92
Assum Assumption n of f ho hone nesty y is s pr probl blematic
SLIDE 93 Pr Proof-of
Work (Po PoW) ) and Incentives s in Bi Bitcoin
- PoW in Bitcoin is finding a value that when hashed (SHA-256)
the hash begins with a certain number of zeros (control of difficulty level)
- Incentive for Mining/Ensuring Integrity of Blockchain: The first
transaction in a block is a special transaction that starts a new coin owned by the creator of the block.
Block Tx Tx … Previous Hash Nonce (to be found) Block Tx Tx … Previous Hash Nonce (to be found)
SLIDE 94
Assum Assumption n of f ho hone nesty y is s pr probl blematic
SLIDE 95 Su Summa mmary of Operation of
Bitcoi
Networ
1) New transactions are broadcast to all nodes 2) Each node collects new transactions into a block 3) Each node works on finding a solution to a (somewhat) difficult proof-of-work puzzle for its block 4) When a node finds a solution to the proof-of-work puzzle, it broadcasts the block to all nodes 5) Nodes accept block only if all transactions in it are valid and not already spent 6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash
SLIDE 96 Exploring recent Bitcoin blocks/transactions 1/4
https://blockchain.info/block/00000000000000000042e9d461887fbfcd65d70d436f9c825031f8fc7ce09809
SLIDE 97
Exploring recent Bitcoin blocks/transactions 2/4
SLIDE 98
Exploring recent Bitcoin blocks/transactions 3/4
SLIDE 99
Exploring recent Bitcoin blocks/transactions 4/4