Grokking Bitcoin
Kalle Rosenbaum
  • MEAP began May 2017
  • Publication in April 2019 (estimated)
  • ISBN 9781617294648
  • 480 pages (estimated)
  • printed in black & white

You do not need to be a math wizard, or skilled cryptographer to follow along, yet you gain a good understanding of how the Bitcoin system works.

Christopher Bailey

If you think Bitcoin is just an alternative currency for geeks, it's time to think again. Grokking Bitcoin opens up this powerful distributed ledger system, exploring the technology that enables applications both for Bitcoin-based financial transactions and using the blockchain for registering physical property ownership. With this fully illustrated, easy-to-read guide, you'll finally understand how Bitcoin works, how you can use it, and why you can trust the blockchain. You'll discover how to accept and exchange Bitcoin, participate in the Bitcoin network, set up a digital wallet, and even how Bitcoin mining works. Along the way, you'll dive into the underlying security and distributed system concepts that power Bitcoin. Each chapter is loaded with diagrams and exercises to help you gain a true understanding of each interesting topic.

Table of Contents detailed table of contents




About this book

Who should read this book

How this book is organized

About the Code

Author online

About the author


About the cover illustration

1 Introduction to Bitcoin

1.1 What is Bitcoin?

1.2 The big picture

1.2.1 Step 1 — Transactions

1.2.2 Step 2 — The Bitcoin network

1.2.3 Step 3 — The blockchain

1.2.4 Step 4 — Wallets

1.3 Problems with money today

1.3.1 Segregation

1.3.2 Privacy issues

1.3.3 Inflation

1.3.4 Borders

1.4 The Bitcoin approach

1.4.1 Decentralized

1.4.2 Limited supply

1.4.3 Borderless

1.5 How is Bitcoin used?

1.5.1 Savings

1.5.2 Cross—​border payments

1.5.3 Shopping

1.5.4 Speculation

1.5.5 Non—​currency uses

1.5.6 How is Bitcoin valued?

1.5.7 When not to use Bitcoin

1.6 Other cryptocurrencies

1.7 Recap

2 Cryptographic hash functions and digital signatures

2.2 Cryptographic hashes

2.2.1 Why are cryptographic hash functions useful?

2.2.2 How does a cryptographic hash function work?

2.2.3 Properties of a cryptographic hash function

2.2.4 Illustration of "hard"

2.2.5 Some well known hash functions

2.2.6 Summary

2.2.7. Exercises

2.3 Digital signatures

2.3.1 Typical use of digital signatures

2.3.3 Preparation: John generates a key pair

2.3.4 Recap on key pairs

2.3.5. Where were we?

2.3.6 John signs his payment

2.3.7 Lisa verifies the signature

2.4 Private key security

2.5 Summary

2.5.1. System changes

2.6 Exercises

2.6.1 Warm up

2.6.2. Dig in

2.7 Recap

3 Addresses

3.2 Replace names with public keys

3.2.1 New payment process

3.3 Shorten the public key

3.3.1 Hash public key to 20 bytes

3.3.2 Why SHA256 and RIPEMD160?

3.4 Avoiding expensive typing errors

3.4.1 Where were we?

3.4.2 Base58check

3.4.3 Base58check decoding

3.5 Back to privacy

3.6 Summary

3.6.1. System changes

3.7 Exercises

3.7.1 Warm up

3.7.2 Dig in

3.8 Recap

4 Wallets

4.1 First Wallet version

4.2 Private key backups

4.2.1 A few words on password strength

4.2.2 Problems with password encrypted backups

4.3 Hierarchical deterministic wallets

4.3.1 Derive a master extended private key

4.3.2 Derive a child extended private key

4.4 Where were we?

4.5 Back to backup

4.5.1 Mnemonic sentences

4.5.2 Encode seed into mnemonic sentence

4.5.3 Decode mnemonic sentence into seed

4.6 Extended public keys

4.7 Hardened private key derivation

4.8 Public key multiplication

4.8.1 Why is this secure?

4.8.2 xpub derivation

4.8.3 Public key encoding

4.9 Summary

4.9.1 System changes

4.10 Exercises

4.10.1 Warm up

4.10.2 Dig in

4.11 Recap

5 Transactions

5.1 Problems with old system

5.2 Pay using a transaction

5.2.1 Create the transaction

5.2.2 Lisa confirms the transaction

5.2.3 Anyone verifies the transaction

5.2.4 Account based and value based systems

5.3 Script

5.3.1 Why use a program?

5.3.2 Why signature script and pubkey script?

5.4 Where were we?

5.5 Fancy payment types

5.5.1 Multiple signatures

5.5.2 Pay to script hash (p2sh)

5.5.3 Pay to script hash addresses

5.6 More stuff in transactions

5.7 Rewards and coin creation

5.7.1 Transition from version 4.0

5.8 Trust in Lisa

5.9 Summary

5.9.1 System changes

5.10 Exercises

5.10.1 Warm up

5.10.2 Dig in

5.11 Recap

6 The blockchain

6.1 Lisa can delete transactions

6.2 Build the blockchain

6.2.1 Lisa builds a block

6.2.2 How does this protect us from deletes?

6.2.3 Why use a blockchain at all?

6.3 Lightweight wallets

6.3.1 Bloom filters, obfuscate addresses

6.4 Where were we?

6.5 Merkle trees

6.5.1 Create the merkle root

6.5.2 Prove that a transaction is in a block

6.5.3 How it actually works

6.6 Security of lightweight wallets

6.7 Summary

6.7.1 System changes

6.8 Exercises

6.8.1 Warm up

6.8.2 Dig in

6.9. Recap

7 Proof of work

7.1 Clone Lisa

7.1.1 Block collisions

7.1.2 Draw lucky numbers

7.1.3 Probability of splits

7.2 Where were we?

7.3 Force honest lucky numbers

7.3.1 Produce a valid proof of work

7.3.2 Why is this good?

7.3.3 Comparing with lucky numbers

7.3.4 What if we run out of nonces?

7.4 Miners have to move out

7.4.1 More hashrate is added

7.4.2 Problems with high block rate

7.4.3 What’s fixed?

7.5 Difficulty adjustments

7.5.1 Rules for timestamps

7.5.2 Chain strength vs chain length

7.6 What harm can miners do?

7.6.1 Successful double spend

7.6.2 Protect against double spend attacks

7.7 Transaction fees

7.7.1 Bigger blocks are slower

7.7.2 But wasn’t this about transactions fees?

7.7.3 Block size is limited

7.7.4 When block subsidy is 0

7.8 Summary

7.8.1 System changes

7.9 Exercises

7.9.1 Warm up

7.9.2 Dig in

7.10 Recap

8 Peer to peer network

8.1 The shared folder

8.2 Let’s build a peer to peer network

8.3 How do peers talk?

8.4 The network protocol

8.4.1 John sends the transaction

8.4.2 Tom forwards the transaction

8.4.3 Cafe’s lightweight wallet is notified

8.4.4 Include the transaction in a block

8.4.5 Notify wallets

8.4.6 More confirmations

8.5.1 Bitcoin at a glance

8.6 Where were we

8.7 Bootstrapping the network

8.7.1 Step 1 — Run the software

8.7.2 Step 2 — Connect to nodes

8.7.3 Step 3 ---- Synchronize

8.7.4 Step 4 — Normal operation

8.8 Run your own full node

8.8.1 Download Bitcoin Core

8.8.2 Verify the the software

8.8.3 Unpack and start

8.8.4 Initial blockchain download

8.9 Summary

8.9.1 Part 1: Following a transaction

8.9.2 Part 2: Joining the network

8.9.3 System changes

8.10 Exercises

8.10.1 Warm up

8.10.2 Dig in

8.11 Recap

9 Transactions revisited

9.1 Time locked transactions

9.1.1 Time measurements

9.1.2 Relative time locks

9.2 Time locked outputs

9.2.1 Absolute time locked outputs

9.2.2 Relative time locked outputs

9.2.3 Atomic swaps

9.3 Storing stuff in the Bitcoin blockchain

9.3.1 Bloated UTXO set

9.3.2 Create a token in Bitcoin

9.3.3 Start the car with proof of ownership

9.4 Replace pending transactions

9.4.1 Opt—​in replace by fee

9.4.2 Child pays for parent

9.5 Different signature types

9.6 Summary

9.7 Exercises

9.7.1 Warm up

9.7.2 Dig in

9.8 Recap

10 Segregated witness

10.1 Problems

10.1.1 Transaction malleability

10.1.2 Inefficient signature verification

10.1.3 Waste of bandwidth

10.1.4 Script upgrades are hard

10.2 Solution

10.2.1 Segwit addresses

10.2.2 Spend your segwit output

10.2.3 Verify the segwit transaction

10.2.4 Including your segwit transaction in a block

10.2.5 Pay to witness script hash

10.2.6 New hashing method for signatures

10.2.7 Bandwidth savings

10.2.8 Upgradable script

10.3 Wallet compatibility

10.4 Recap of payment types

10.5 Block limits

10.5.1 Block size limit

10.5.2 Signature operations limit

10.5.3 Increasing the limits

10.6 Summary

10.6.1 Problems

10.6.2 Solution

10.7 Exercises

10.7.1 Warm up

10.7.2 Dig in

10.8 Recap

11 Bitcoin upgrades

11.1 Bitcoin forks

11.1.1 Non—​consensus—​rule changes

11.1.2 Hard forks

11.1.3 Soft forks

11.1.4 Differences between hard and soft forks

11.2 Transaction replay

11.2.1 Replay protection

11.3 Upgrade mechanisms

11.3.1 Using coinbase signaling: BIP16

11.3.2 Using incremented block version number signaling: BIP34, 66, 65

11.3.3 Using block version bits signaling, BIP9

11.3.4 Use BIP9 to deploy relative lock time

11.3.5 Use BIP9 to deploy SegWit

11.3.6 User—​activated soft forks

11.4 Summary

11.5 Exercises

11.5.1 Warm up

11.5.2 Dig in

11.6 Recap


Appendix A: Using bitcoin—​cli

A.1 Communicating with bitcoind

A.1.1 Using curl

A.2 Graphical user interface

A.3 Getting to know bitcoin—​cli

A.4 Get to work

A.4.1 Create an encrypted wallet

A.4.2 Backup the wallet

A.4.3 Receive money

A.4.4 Send money

Appendix B: Answers to exercises

B.1 Chapter 2

B.1.1 Cryptographic hash functions

B.1.2 Digital signatures

B.2 Chapter 3

B.3 Chapter 4

B.4 Chapter 5

B.5 Chapter 6

B.6 Chapter 7

B.7 Chapter 8

B.8 Chapter 9

B.9 Chapter 10

B.10. Chapter 11

Appendix C: Web Resources

About the Technology

The modern world turns on universally-accepted ideas of currency and ownership. Bitcoin, and its underlying technology, offer the potential to move control of these key institutions from change-prone governments to a secure storage system that independently records value and ownership in a distributed public ledger called "the blockchain." Data stored on the blockchain is, for all practical purposes, incorruptible; transactions are verified independently and everything is stored in the blockchain, that no single entity controls. In 2009 Bitcoin introduced the blockchain idea in combination with proof-of-work and incentive mechanisms for use as an alternative currency. Today, individuals, businesses, and institutions are using Bitcoin as the foundation for secure blockchain-based transaction systems.

What's inside

  • Send and receive Bitcoin payments
  • Bitcoin transactions
  • The blockchain
  • Bitcoin mining
  • The Bitcoin peer-to-peer network

About the reader

This book provides a jargon-free introduction to Bitcoin for any technically interested reader. Some chapters address technical concepts that require basic knowledge of networking and programming.

About the author

Kalle Rosenbaum founded Popeller, a Bitcoin consultancy, in 2015. Kalle provides expert software development services, advice, and education around Bitcoin.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $39.99 pBook + eBook + liveBook
MEAP eBook $31.99 pdf + ePub + kindle + liveBook

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks