Bitcoin
CS 161 Fall 2023 - Lecture 27
Computer Science 161
Today: Bitcoin
Computer Science 161
Bitcoin: Identity and Transactions
Textbook Chapter 16.1–16.5
Computer Science 161
Problem Statement: The Decentralized Bank
Computer Science 161
Identity Management
Alice
PKA
Bob
PKB
PKC
PKD
Carol
Dave
Computer Science 161
Transactions
Computer Science 161
Transactions
The Ledger v1
How many coins does PKA have right now?
8 coins! 10 - 4 + 2 = 8, for transactions 1, 2, and 4 on the ledger.
Computer Science 161
Transactions
Computer Science 161
Transactions
The Ledger v2
TX2 (by PKB) | |
Inputs | TX1 (5 coins) |
Outputs | PKD (5 coins) |
TX3 (by PKC) | |
Inputs | TX1 (5 coins) |
Outputs | PKD (5 coins) |
TX4 (by PKD) | |
Inputs | TX2 (5 coins) |
TX3 (5 coins) | |
Outputs | PKA (3 coin) |
PKB (4 coins) | |
PKD (3 coins) |
TX5 (by PKA) | |
Inputs | TX4 (3 coin) |
Outputs | PKC (3 coin) |
TX6 (by PKB) | |
Inputs | TX4 (4 coins) |
Outputs | PKD (4 coins) |
Computer Science 161
Transactions
In each transaction, the total input currency is equal* to the total output currency.
In TX 4, 5 + 5 = 3 + 4 + 3
Each transaction must identify a valid source of currency by referencing a past transaction.
We must also verify that no other transaction has already claimed this input.
Leftover money is returned to the sender. PKD spent 7 coins and sent the remaining 3 back to himself.
TX2 (by PKB) | |
Inputs | TX1 (5 coins) |
Outputs | PKD (5 coins) |
TX3 (by PKC) | |
Inputs | TX1 (5 coins) |
Outputs | PKD (5 coins) |
TX4 (by PKD) | |
Inputs | TX2 (5 coins) |
TX3 (5 coins) | |
Outputs | PKA (3 coin) |
PKB (4 coins) | |
PKD (3 coins) |
TX5 (by PKA) | |
Inputs | TX4 (3 coin) |
Outputs | PKC (3 coin) |
TX6 (by PKB) | |
Inputs | TX4 (4 coins) |
Outputs | PKD (4 coins) |
Computer Science 161
Bitcoin: The Public Ledger
Textbook Chapter 16.6–16.9
Computer Science 161
Recall: Hash Functions
Computer Science 161
Hash Chains
prev_hash: NULL |
data: ... |
B0
prev_hash: H(B0) |
data: ... |
B1
prev_hash: H(B1) |
data: ... |
B2
prev_hash: H(B2) |
data: ... |
B3
Computer Science 161
Hash Chains
prev_hash: NULL |
data: ... |
B0
prev_hash: H(B0) |
data: ... |
B1
prev_hash: H(B1) |
data: ... |
B2
prev_hash: H(B2) |
data: ... |
B3
Computer Science 161
Merkle Trees
Data: ...
Data: ...
Data: ...
Data: ...
B0
B1
B2
B3
Data: H(B0) || H(B1)
Data: H(B2) || H(B3)
B01
B23
Data: H(B01) || H(B23)
B03
Hash: H(B03)
Computer Science 161
Merkle Trees
Data: ...
Data: ...
Data: ...
Data: ...
B0
B1
B2
B3
Data: H(B0) || H(B1)
Data: H(B2) || H(B3)
B01
B23
Data: H(B01) || H(B23)
B03
Hash: H(B03)
Computer Science 161
The Public Ledger
Computer Science 161
Forking Attacks
PKM spent 100,000 coins
PKM did not spend 100,000 coins
Computer Science 161
Proof of Work
19
nonce: 0x0000
prev_hash: ...
data: ...
nonce: 0x0001
prev_hash: ...
data: ...
nonce: 0x0002
prev_hash: ...
data: ...
nonce: 0x0017
prev_hash: ...
data: ...
Hash: 0b11100011
Hash: 0b01001000
Hash: 0b00011010
Hash: 0b00000101
✗
✗
✗
✓
Computer Science 161
Proof of Work
20
nonce: 0x0000
prev_hash: ...
data: ...
nonce: 0x0001
prev_hash: ...
data: ...
nonce: 0x0002
prev_hash: ...
data: ...
nonce: 0x0017
prev_hash: ...
data: ...
Hash: 0b11100011
Hash: 0b01001000
Hash: 0b00011010
Hash: 0b00000101
✗
✗
✗
✓
Computer Science 161
Proof of Work
Computer Science 161
Proof of Work: Examples
Computer Science 161
Incentivizing Mining
Computer Science 161
Attacks on Proof-of-Work
Computer Science 161
The Trouble with Bitcoin
Computer Science 161
The Trouble with Bitcoin: Centralization of Power
The four largest mining pools combined control 55% of all Bitcoin hash power
Computer Science 161
The Trouble with Bitcoin: Centralization of Power
Computer Science 161
The Trouble with Bitcoin: Pseudonymity
Computer Science 161
The Trouble with Bitcoin: Inefficiency
Computer Science 161
The Trouble with Bitcoin: Power Consumption
Today, Bitcoin consumes more electricity than entire countries (measured in terawatt-hours)
Computer Science 161
The Trouble with Bitcoin: Irreversibility
Computer Science 161
Bitcoin in Practice
Computer Science 161
Breaking Proof-of-Work
Computer Science 161
Proof-of-Work Alternatives
Computer Science 161
Blockchain: Marketing and Buzzwords
Computer Science 161
Blockchain: Marketing and Buzzwords
Computer Science 161
Blockchain: Marketing and Buzzwords
Computer Science 161
Bitcoin Enables Censorship Resistance
Computer Science 161
Bitcoin Enables Crime
Computer Science 161
Economics of Bitcoin: Volatility
Computer Science 161
Economics of Bitcoin: Speculation
Computer Science 161
Economics of Bitcoin: Currency Exchange
Computer Science 161
Economics of Bitcoin: Volatility
Computer Science 161
Other Cryptocurrencies
Computer Science 161
Other Cryptocurrencies
45
Computer Science 161
Cryptocurrency Scams
Computer Science 161
Bitcoin: Summary
47
Computer Science 161
The Trouble with Bitcoin: Summary
Computer Science 161