CS 3700 Networks and Distributed Systems: Bitcoin
CS 3700 Networks and Distributed Systems: Bitcoin
CS 3700 Networks and Distributed Systems: Bitcoin
• Medium of exchange
• May or may not have intrinsic value (e.g. gold)
• Value is based on future exchanges
• Trust is essential
• Store of value
• Allows one to store “value” rather than objects
• Facilitates lending, debt, investing, and other financial innovations
Ancient Coinage
Advantages Disadvantages
• Easily portable • Easy to steal
• Cannot double-spend • Paper is a bearer token
• Spend the same piece of paper >1 • Hard to monitor/tax transactions
times
• Again, paper is semi-anonymous
• Cannot repudiate payment
• Once you’ve given the paper, you
• Requires trust in the centralized
can’t get it back issuing authority
• Semi-anonymous • Doesn’t work online
• Modulo tracking serial numbers • I can’t email you a scan of the
• Issuing authority can inflate/deflate paper :(
as necessary
What About Electronic Currency?
• The rise of telecommunications networks gives rise to a need for
electronic forms of currency
• Credit cards, Paypal, bank e-checks
• Computers store the amount of money held by each individual/company
• Transactions move money between parties
• Why do we trust the electronic money system?
• Denominated in a physical, fiat currency
• Rules are enforced by strict regulation and audits
• E.g. Paypal can’t just decide to mint a trillion dollars for themselves
• Again, trust is centralized in the issuing authority, i.e. the government
• What is the incentive to participate in the electronic money system?
• Transaction fees
• E.g. Visa charges 1.51% of each transaction plus $0.10
Electronic Currency
Advantages Disadvantages
• Works online • Requires trust in the issuing authority and
• Easy for issuing authority to third-parties
monitor/tax/control • E.g. Visa, Paypal
• Strict regulations and auditing • Manual oversight and auditing
Requirements Expectations
• No centralized control • Clear ownership of each neucoin
• Central banks, governments, police • Cannot generate money you don’t
have
• No “strong identities”
• Cannot double spend
• ID cards, passports
• Cannot steal arbitrarily
• Impossible to enforce without
centralized control • No repudiation
• Ideally, we would like anonymity
(like physical paper cash)
• Entirely electronic
• Not backed by commodities
Motivating Example
I, Alice, transfer 1 neucoin to Bob.
Alice Bob
1 neucoin 1 neucoin
I, Alice, transfer 1 neucoin to Charlie.
Pa Pb
Pa transfers 1 neucoin to Pb
Alice Sa Sa Sb Bob
1 neucoin 1 neucoin
Pa Pa transfers 1 neucoin to Pc Pb
Sa
Mallory Sm Sc Charlie
Pm 10238
Pc B
• What if the trusted bank also tracked who owns each neucoin?
• Bank would have a ledger, serve as official record of ownership
• Charlie can contact the bank, verify that Alice owns a given coin
• Problems?
• Centralized ledger totally defeats the purpose of neucoin
• Instead, the network is the bank
• Participants in neucoin collectively keep track of all transactions
• Known as the public ledger
• To verify that Alice isn’t double spending, Charlie can check the public ledger
Example v4
neucoin Network
Is the signature in this
Pa transfers 10238 to Pbc transaction valid?
Alice Sa Sa Does Pa own 10238?
10238 Pa
Public Ledger
Bob Sb • Pa owns 10238
• 10238 from Pa to Pb
10238
Pb
Charlie Sc
Pc
Brief History of Currency
Towards Decentralized, Online
Currency
Bitcoin
Bitcoin in Practice
Bitcoin at a High-Level
• Key idea: a node can only add an entry to the blockchain if it solves a
cryptopuzzle
• Other nodes can easily validate new blocks to ensure the puzzle has been solved
• Changes “one node/one vote” to “one CPU/one vote”
• To dominate the network, Mallory must control significant CPU resources
Prev. Block Hash Nonce Y Block Hash Prev. Block Hash Nonce X Block Hash Prev. Block Hash No
Transaction L Transaction I Transaction F
Transaction M Transaction J Transaction G
Transaction N Transaction K Transaction H
• At any given time, all nodes are searching for the next block
• Searching == trying different nonces to solve the puzzle
• Hoping to get lucky, identify nonce X such that block hash < target
• Hashing power of the network grows over time
• More peers join the network, CPUs get faster
• Bitcoin automatically adjusts target over time
• Attempts to maintain 1 block/10 minutes on average
• Once a node discovers a block, it broadcasts it to other peers
• Other nodes validate (easy, simply recompute the hash)
• Nodes begin working on the next block (with the new block as Prev)
Forking the Blockchain
• What happens if two nodes find different block simultaneously?
• Let’s call them Dave and Edgar
• Both Dave and Edgar broadcast
• Some fraction of the network will start working on Dave’s fork, others on
Edgar’s
• This is bad. Who is right? Dave and Edgar’s blocks may contain different
transactions
• In Bitcoin, nodes always accept the longest chain
• The longest chain represents the most work
• Eventually, either Dave or Edgar’s fork will find the next block first
• When this is broadcast, all nodes will switch to the longer chain
Forking Example