Bitcoin
Satoshi Nakamoto's white paper, Bitcoin: A Peer-to-Peer Electronic Cash System, section by section: transactions, timestamp server, proof-of-work, network, incentive, reclaiming disk space, SPV, combining and splitting value, privacy and the attacker success probability.
The white paper at a glanceSearch on YouTube
Satoshi Nakamoto published Bitcoin: A Peer-to-Peer Electronic Cash System in 2008. It is a reference text for the course. Its goal is online payments sent directly from one party to another without a financial institution.
| Section | Idea in one line |
|---|---|
| 1 Introduction | Trust-based payments are costly and reversible; replace trust with cryptographic proof |
| 2 Transactions | A coin is a chain of digital signatures; the problem is double spending |
| 3 Timestamp server | Hash blocks of items and publish the hash; each timestamp includes the previous one |
| 4 Proof-of-work | Scan for a nonce so the block hash starts with zero bits; one CPU one vote |
| 5 Network | Six steps nodes follow; longest chain is the correct one |
| 6 Incentive | Block reward and transaction fees pay miners and keep them honest |
| 7 Reclaiming disk space | Merkle tree lets old spent transactions be pruned |
| 8 Simplified payment verification | Verify payments with block headers and a Merkle branch |
| 9 Combining and splitting value | Multiple inputs and at most two outputs (payment and change) |
| 10 Privacy | Keep public keys anonymous; a new key pair per transaction |
| 11 Calculations | Probability an attacker catches up drops exponentially with z |
| 12 Conclusion | Electronic transactions without relying on trust |
IntroductionSearch on YouTube
Internet commerce relies on financial institutions as trusted third parties. This trust-based model has weaknesses:
- Completely non-reversible transactions are not possible, because institutions must mediate disputes.
- Mediation increases transaction costs and limits the minimum practical transaction size. Small casual payments become impractical.
- Because reversal is possible, merchants must distrust customers and ask for more information than needed. A certain percentage of fraud is accepted as unavoidable.
The paper proposes an electronic payment system based on cryptographic proof instead of trust. Transactions that are computationally impractical to reverse protect sellers from fraud. Escrow can protect buyers. The double-spending problem is solved with a peer-to-peer distributed timestamp server that generates computational proof of the chronological order of transactions. The system is secure as long as honest nodes collectively control more CPU power than any cooperating group of attacker nodes.
TransactionsSearch on YouTube
An electronic coin is defined as a chain of digital signatures.
Each owner transfers the coin to the next by:
- Digitally signing a hash of the previous transaction and the public key of the next owner.
- Adding these to the end of the coin.
A payee can verify the signatures to verify the chain of ownership.
The double-spending problemSearch on YouTube
The payee cannot verify that a previous owner did not double-spend the coin. The usual fix is a trusted central authority, a mint, that checks every transaction. After each transaction the coin returns to the mint, which issues a new coin. Only coins issued directly by the mint are trusted. The problem: the fate of the whole money system depends on the company running the mint, just like a bank.
To work without a trusted party:
- Transactions must be publicly announced.
- Participants need a system to agree on a single history of the order in which transactions were received.
- The payee needs proof that, at the time of each transaction, the majority of nodes agreed it was the first received.
For Bitcoin, only the earliest transaction counts. Later attempts to double-spend are ignored.
Timestamp serverSearch on YouTube
The solution begins with a timestamp server.
- Take a hash of a block of items to be timestamped.
- Widely publish the hash (like a newspaper or Usenet post).
- The timestamp proves the data existed at that time, since it went into the hash.
- Each timestamp includes the previous timestamp in its hash, forming a chain.
Each additional timestamp reinforces the ones before it.
Proof-of-workSearch on YouTube
A distributed timestamp server on a peer-to-peer basis needs a proof-of-work system similar to Adam Back's Hashcash.
- Proof-of-work means scanning for a value that, when hashed (for example with SHA-256), gives a hash that begins with a number of zero bits.
- The average work required is exponential in the number of zero bits required.
- The result can be verified by executing a single hash.
- Bitcoin implements it by incrementing a nonce in the block until a value gives the block's hash the required zero bits.
Once CPU effort has been spent to satisfy the proof-of-work, the block cannot be changed without redoing the work. Later blocks are chained after it, so changing a block means redoing the work of that block and all blocks after it.
One-CPU-one-voteSearch on YouTube
Proof-of-work also solves majority decision making.
- If the majority were based on one-IP-address-one-vote, anyone able to allocate many IPs could subvert it.
- Proof-of-work is essentially one-CPU-one-vote.
- The majority decision is the longest chain, which has the greatest proof-of-work effort invested in it.
- If a majority of CPU power is controlled by honest nodes, the honest chain grows fastest and outpaces any competing chain.
To modify a past block, an attacker must redo the proof-of-work of that block and all blocks after it, then catch up with and surpass the honest nodes. Section 11 shows the probability of a slower attacker catching up falls exponentially as more blocks are added.
DifficultySearch on YouTube
To compensate for faster hardware and varying interest in running nodes, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If blocks are generated too fast, the difficulty increases.
In Bitcoin today the target is one block per 10 minutes. Difficulty is recalculated every 2016 blocks (about 2 weeks): new target = old target × (actual time for the last 2016 blocks / 20,160 minutes). This was asked in the 2026 mid sem; see Exam questions.
NetworkSearch on YouTube
The steps to run the network are:
- New transactions are broadcast to all nodes.
- Each node collects new transactions into a block.
- Each node works on finding a difficult proof-of-work for its block.
- When a node finds a proof-of-work, it broadcasts the block to all nodes.
- Nodes accept the block only if all transactions in it are valid and not already spent.
- 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.
Big Cats Work, But Always Eat: Broadcast transactions, Collect into a block, Work on PoW, Broadcast the block, Accept if valid, Extend the chain.
Further rules:
- Nodes always consider the longest chain to be the correct one and keep working on extending it.
- If two nodes broadcast different versions of the next block at the same time, some nodes receive one first. They work on the first one they received but save the other branch in case it becomes longer.
- The tie breaks when the next proof-of-work is found and one branch becomes longer. Nodes on the other branch switch to the longer one.
- New transaction broadcasts do not need to reach all nodes. Once they reach many nodes, they get into a block before long.
- Block broadcasts tolerate dropped messages. A node that misses a block requests it when it receives the next block and sees it missed one.
IncentiveSearch on YouTube
- By convention, the first transaction in a block is a special transaction that starts a new coin owned by the block's creator. This is the coinbase transaction.
- This gives nodes an incentive to support the network. It also distributes coins into circulation, since there is no central authority to issue them.
- The steady addition of a constant amount of new coins is like gold miners spending resources to add gold to circulation. Here the resources are CPU time and electricity.
- The incentive can also be funded with transaction fees. If the output value of a transaction is less than its input value, the difference is a fee added to the block's incentive.
- Once a predetermined number of coins have entered circulation, the incentive can move entirely to transaction fees and be completely inflation free.
The incentive also encourages nodes to stay honest. A greedy attacker who has more CPU power than all honest nodes must choose: defraud people by stealing back his payments, or use the power to generate new coins. He ought to find it more profitable to play by the rules, which give him more new coins than everyone else combined, than to undermine the system and the validity of his own wealth.
Reclaiming disk spaceSearch on YouTube
Once the latest transaction in a coin is buried under enough blocks, the spent transactions before it can be discarded to save disk space.
- Transactions are hashed in a Merkle tree. Only the root is included in the block's hash.
- Old blocks can be compacted by stubbing off branches of the tree. Interior hashes do not need to be stored.
- This does not break the block's hash, because the header only commits to the root.
Size estimate:
- A block header with no transactions is about 80 bytes.
- With a block every 10 minutes: per year.
- Computers in 2008 typically had 2 GB of RAM, and Moore's Law predicted growth of 1.2 GB per year, so storage is not a problem even if headers are kept in memory.
Simplified payment verificationSearch on YouTube
Simplified Payment Verification (SPV) lets a user verify payments without running a full network node.
- The user keeps only a copy of the block headers of the longest proof-of-work chain. He gets them by querying network nodes until convinced he has the longest chain.
- He obtains the Merkle branch linking the transaction to the block it is timestamped in.
- He cannot check the transaction himself, but by linking it to a place in the chain he sees that a network node accepted it.
- Blocks added after it further confirm that the network accepted it.
SPV is reliable only while honest nodes control the network. It is more vulnerable if an attacker overpowers the network: the attacker's fabricated transactions could fool an SPV user. Defence: accept alerts from network nodes when they detect an invalid block, prompting the user's software to download the full block and alerted transactions to confirm the inconsistency. Businesses that receive frequent payments will probably still run their own nodes for more independent security and quicker verification.
Combining and splitting valueSearch on YouTube
Handling every cent as a separate coin would be unwieldy. To allow value to be split and combined, a transaction contains multiple inputs and outputs.
- Normally there is either a single input from a larger previous transaction, or multiple inputs combining smaller amounts.
- There are at most two outputs: one for the payment, and one returning the change, if any, to the sender.
Fan-out, where a transaction depends on several transactions and those depend on many more, is not a problem. There is never a need to extract a complete standalone copy of a transaction's history.
PrivacySearch on YouTube
The traditional banking model achieves privacy by limiting access to information to the parties involved and the trusted third party. Bitcoin must announce all transactions publicly, so privacy comes from a different place:
- Keep public keys anonymous. The public can see that someone is sending an amount to someone else, but without information linking the transaction to anyone.
- This is like the level of information released by stock exchanges: the time and size of individual trades (the "tape") is public, but not who the parties were.
As an additional firewall, a new key pair should be used for each transaction to keep them from being linked to a common owner.
Some linking is still unavoidable with multi-input transactions: they reveal that their inputs were owned by the same owner. The risk is that if the owner of one key is revealed, linking could reveal other transactions that belonged to the same owner.
| Model | Who sees what |
|---|---|
| Traditional | Identities and transactions go to the trusted third party only; the public sees nothing |
| Bitcoin | The public sees all transactions, but identities are separated from them by anonymous keys |
Calculations: attacker success probabilitySearch on YouTube
Scenario: an attacker tries to generate an alternate chain faster than the honest chain. Even if he succeeds, he cannot create value out of thin air or take money that never belonged to him. Nodes will not accept an invalid transaction. The attacker can only try to change one of his own transactions to take back money he recently spent.
The race between the honest chain and the attacker chain is a Binomial Random Walk. Success is the honest chain extending by one block (lead +1). Failure is the attacker extending by one block (gap −1). The chance of the attacker catching up from a deficit is like the Gambler's Ruin problem.
Catch-up probabilitySearch on YouTube
- = probability an honest node finds the next block
- = probability the attacker finds the next block
- = probability the attacker ever catches up from blocks behind
With , the probability drops exponentially as grows.
How long should the recipient waitSearch on YouTube
The recipient generates a new key pair and gives the public key to the sender shortly before signing. This stops the sender from preparing a chain of blocks ahead of time. Once the transaction is sent, the dishonest sender works in secret on a parallel chain with an alternate version of his transaction.
The recipient waits until the transaction is in a block and blocks have been linked after it. Assuming honest blocks took the average expected time, the attacker's progress follows a Poisson distribution with expected value:
Multiply the Poisson density for each amount of progress by the probability he can catch up from there:
Rearranged to avoid summing the infinite tail:
C code from the paperSearch on YouTube
#include <math.h>
double AttackerSuccessProbability(double q, int z)
{
double p = 1.0 - q;
double lambda = z * (q / p);
double sum = 1.0;
int i, k;
for (k = 0; k <= z; k++)
{
double poisson = exp(-lambda);
for (i = 1; i <= k; i++)
poisson *= lambda / i;
sum -= poisson * (1 - pow(q / p, z - k));
}
return sum;
}ResultsSearch on YouTube
The probability drops exponentially with .
| z | P (q = 0.1) | z | P (q = 0.3) |
|---|---|---|---|
| 0 | 1.0000000 | 0 | 1.0000000 |
| 1 | 0.2045873 | 5 | 0.1773523 |
| 2 | 0.0509779 | 10 | 0.0416605 |
| 3 | 0.0131722 | 15 | 0.0101008 |
| 4 | 0.0034552 | 20 | 0.0024804 |
| 5 | 0.0009137 | 25 | 0.0006132 |
| 6 | 0.0002428 | 30 | 0.0001522 |
| 7 | 0.0000647 | 35 | 0.0000379 |
| 8 | 0.0000173 | 40 | 0.0000095 |
| 9 | 0.0000046 | 45 | 0.0000024 |
| 10 | 0.0000012 | 50 | 0.0000006 |
Blocks needed for :
| q | 0.10 | 0.15 | 0.20 | 0.25 | 0.30 | 0.35 | 0.40 | 0.45 |
|---|---|---|---|---|---|---|---|---|
| z | 5 | 8 | 11 | 15 | 24 | 41 | 89 | 340 |
Step 1. Attacker has 10% of the hash power: , .
Step 2. Catch-up from 6 blocks behind (ignoring progress): .
Step 3. With the Poisson correction the paper gets for . It is larger than because the attacker may already have mined some blocks in secret.
Step 4. This is why 6 confirmations is the common rule: below 0.1% for needs only .
ConclusionSearch on YouTube
The paper proposes a system for electronic transactions without relying on trust.
- Coins made from digital signatures give strong control of ownership but cannot prevent double spending alone.
- A peer-to-peer network using proof-of-work records a public history of transactions. It quickly becomes computationally impractical for an attacker to change if honest nodes control most CPU power.
- The network is robust in its unstructured simplicity. Nodes work all at once with little coordination. They do not need to be identified, since messages are not routed to any particular place and only need best-effort delivery.
- Nodes can leave and rejoin, accepting the proof-of-work chain as proof of what happened while they were gone.
- They vote with their CPU power: they accept valid blocks by extending them and reject invalid ones by refusing to work on them.
Quick self-testSearch on YouTube
How does the white paper define an electronic coin?
As a chain of digital signatures. Each owner signs a hash of the previous transaction and the next owner's public key and adds it to the end of the coin.
What is the double-spending problem and how does the paper solve it without a mint?
The payee cannot tell if the coin was already spent elsewhere. Bitcoin announces all transactions publicly and uses a proof-of-work timestamp chain so nodes agree on one history; only the earliest transaction counts.
Why is proof-of-work called one-CPU-one-vote?
Voting power comes from computation, not IP addresses, which are cheap to fake. The longest chain, with the most work, represents the majority decision.
List the six network steps.
Broadcast transactions; nodes collect them into a block; nodes find proof-of-work; the winner broadcasts the block; nodes accept it only if all transactions are valid and unspent; nodes show acceptance by mining the next block on top of its hash.
What two incentives does a miner receive?
The coinbase reward (new coins in the first transaction of the block) and transaction fees (input value minus output value).
How does the Merkle tree help reclaim disk space? How big are headers per year?
Only the Merkle root is in the block hash, so spent transactions can be pruned without breaking the hash. Headers are 80 bytes, so 80 × 6 × 24 × 365 = 4.2 MB per year.
How does SPV work and what is its weakness?
The user keeps only block headers of the longest chain and checks a Merkle branch linking the transaction to a block. It can be fooled if an attacker overpowers the network.
How many outputs does a normal transaction have and why?
At most two: one for the payment and one returning change to the sender.
How does Bitcoin provide privacy when all transactions are public?
Public keys are kept anonymous, like a stock exchange tape that shows trades but not the parties. A new key pair is used for each transaction.
Write the formula for and explain the result.
if , else . If honest nodes have more power, the attacker's chance of catching up falls exponentially with the number of blocks behind.
- Bitcoin replaces trust in a third party with cryptographic proof and proof-of-work.
- A coin is a chain of signatures; double spending is solved by a public, agreed history.
- Timestamp server: hash blocks and chain each hash to the previous one.
- Proof-of-work: find a nonce so the hash starts with enough zero bits; longest chain wins; difficulty follows a moving average.
- Incentive: coinbase reward plus transaction fees; honest mining pays more than attacking.
- Merkle trees allow pruning and SPV; headers are 80 bytes, 4.2 MB per year.
- Transactions combine inputs and have at most two outputs; privacy comes from anonymous, fresh keys.
- Attacker catch-up: for ; with , 5 blocks give .