
Eighteen chapters. No libraries. From a single byte to a network running across several machines.
Everything uses only the Python standard library. No Bitcoin libraries, no black-box APIs, no “just copy this for now, you’ll understand later.” Every term you’ve heard (hash, public key, signature, block, mining, consensus, UTXO, Merkle tree, Script) becomes code you wrote yourself before it is allowed to carry that name.
This book argues one thing¶
The genuinely original part of Bitcoin is not the cryptography. It is everything else.
Satoshi’s building blocks were almost all borrowed: digital signatures (Diffie–Hellman / RSA, 1976–77), proof-of-work (Adam Back, 1997), hash time-stamp chains (Haber–Stornetta, 1991), the idea of a decentralized ledger (Wei Dai / Nick Szabo, 1998), and the first serious attempt at digital cash (David Chaum, 1982).
What he invented was how to build a bank with no manager out of those bricks.
That claim is easy to say and hard to prove, so this book counts it. Every chapter ends with a ledger: of the code you just wrote, which lines are cryptography, and which are systems design, consensus, game theory, or economics. By chapter 18 the tally speaks for itself.
The bricks are borrowed. The house is original.
Start here: Prologue: Borrowed Bricks, an Original House
Contents¶
Part I · Bricks: the cryptographic floor¶
| Ch | Title | What you build by hand |
|---|---|---|
| 1 | Bytes, Hashes, Commitments | sha256(), and commit() / verify(): a guessing game nobody can cheat |
| 2 | Finite Fields, Elliptic Curves, Public Keys | Hop around a curve mod 97, derive a public key, then brute-force it back |
| 3 | Digital Signatures | Real ECDSA, then count how many times priv appears inside verify |
Part II · Retracing the ancestors¶
| Ch | Title | What you build by hand |
|---|---|---|
| 4 | The Hash Time-Stamp Chain | Haber–Stornetta’s chain; edit one old block and watch everything after it break |
| 5 | Proof-of-Work | Hashcash-style mining, and a lesson about luck that most books skip |
Part III · The house: building a chain¶
| Ch | Title | What you build by hand |
|---|---|---|
| 6 | Transactions and Double-Spending | A UTXO ledger, and your first problem cryptography cannot solve |
| 7 | Blocks and Longest-Chain Consensus | The rule that settles double-spends: this chapter contains zero cryptography |
| 8 | Incentives and Issuance | Block rewards, halving, 21 million: making the machine run itself |
| 9 | Forks and Upgrades | Changing the rules with nobody in charge |
Part IV · Surviving the long run¶
| Ch | Title | What you build by hand |
|---|---|---|
| 10 | Fees and Difficulty Adjustment | Two negative-feedback loops that keep the system steady |
| 11 | Merkle Trees and Efficient Verification | Prove a transaction is in a block without downloading the block |
| 12 | Mempool, Fee Market, Confirmations | RBF, CPFP, reorgs: why your transaction is stuck |
| 13 | Switching to the Real Curve | Swap the toy curve for the one Bitcoin actually uses |
Part V · Toward real engineering¶
| Ch | Title | What you build by hand |
|---|---|---|
| 14 | The Script VM | Spending conditions are not a database field; they are a running program |
| 15 | Wallets and HD Key Trees | How twelve words grow a thousand addresses |
| 16 | Hardware Signing | Why the private key lives in a room with no network cable |
| 17 | A Multi-Node Network | Run your chain across several machines and watch them converge |
| 18 | Why Script Is Deliberately Weak | How loops, global state, and one bad opcode could kill every node |
Appendices¶
| A | The cryptography map: roads this book does not take (encryption, zero-knowledge proofs, MPC) |
| B | Why a quantum computer breaks public keys but not hashes |
| C | CHECKSIG vs CSFS: same lamp, different piece of paper |
One thread¶
bytes → hash → commitment → finite field → elliptic curve → public key → signature → chain → mining → transactions → consensus → incentives → upgrade coordination → efficient verification → the real curve → mempool and confirmations → Script → wallets → hardware signing → a real network → the limits of the script engine
Later chapters reuse functions you wrote in earlier ones. Read in order.
Other ways to read it¶
PDF / EPUB: Leanpub. Buying a copy is the best way to support the book.
Code only: bitcoin
-from -scratch -code on GitHub.