Bitcoin
CS 161 Fall 2022 - Lecture 11
Computer Science 161
Fall 2022
Today: Bitcoin
Computer Science 161
Fall 2022
Bitcoin: Identity and Transactions
Textbook Chapter 16.1–16.5
Computer Science 161
Fall 2022
Problem Statement: The Decentralized Bank
Computer Science 161
Fall 2022
Identity Management
Alice
PKA
Bob
PKB
PKC
PKD
Carol
Dave
Computer Science 161
Fall 2022
Transactions
Computer Science 161
Fall 2022
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
Fall 2022
Transactions
Computer Science 161
Fall 2022
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
Fall 2022
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 3 coins and sent the remaining 7 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
Fall 2022
Bitcoin: The Public Ledger
Textbook Chapter 16.6–16.9
Computer Science 161
Fall 2022
Recall: Hash Functions
Computer Science 161
Fall 2022
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
Fall 2022
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
Fall 2022
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
Fall 2022
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
Fall 2022
The Public Ledger
Computer Science 161
Fall 2022
Forking Attacks
PKM spent 100,000 coins
PKM did not spend 100,000 coins
Computer Science 161
Fall 2022
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
Fall 2022
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
Fall 2022
Proof of Work
Computer Science 161
Fall 2022
Proof of Work: Examples
Computer Science 161
Fall 2022
Incentivizing Mining
Computer Science 161
Fall 2022
Attacks on Proof-of-Work
Computer Science 161
Fall 2022
The Trouble with Bitcoin
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Centralization of Power
The four largest mining pools combined control 55% of all Bitcoin hash power
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Centralization of Power
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Pseudonymity
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Inefficiency
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Power Consumption
Today, Bitcoin consumes more electricity than entire countries (measured in terawatt-hours)
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Irreversibility
Computer Science 161
Fall 2022
Bitcoin in Practice
Computer Science 161
Fall 2022
Breaking Proof-of-Work
Computer Science 161
Fall 2022
Proof-of-Work Alternatives
Computer Science 161
Fall 2022
Blockchain: Marketing and Buzzwords
Computer Science 161
Fall 2022
Blockchain: Marketing and Buzzwords
Computer Science 161
Fall 2022
Blockchain: Marketing and Buzzwords
Computer Science 161
Fall 2022
Bitcoin Enables Censorship Resistance
Computer Science 161
Fall 2022
Bitcoin Enables Crime
Computer Science 161
Fall 2022
Economics of Bitcoin: Volatility
Computer Science 161
Fall 2022
Economics of Bitcoin: Speculation
Computer Science 161
Fall 2022
Economics of Bitcoin: Currency Exchange
Computer Science 161
Fall 2022
Economics of Bitcoin: Volatility
Computer Science 161
Fall 2022
Other Cryptocurrencies
Computer Science 161
Fall 2022
Other Cryptocurrencies
45
Computer Science 161
Fall 2022
Cryptocurrency Scams
Computer Science 161
Fall 2022
Bitcoin: Summary
47
Computer Science 161
Fall 2022
The Trouble with Bitcoin: Summary
Computer Science 161
Fall 2022