MASTERING-BITCOIN · Unit 2 · Video 4 · Interactive Practice

168 Billion Trillion Guesses: The Computational Lottery That Secures Bitcoin

IKey Formulas

Formula Name Description
P(valid hash)=(116)kP(\text{valid hash}) = \left(\frac{1}{16}\right)^k Hash target probability Chance a random hash has kk leading hex zeros
N=16kN = 16^k Expected attempts Average guesses needed for kk leading hex zeros
P(attack)(q1q)zP(\text{attack}) \approx \left(\frac{q}{1-q}\right)^z Attack success probability Attacker with hashrate fraction qq, after zz confirmations
Block Reward=Coinbase BTC+ΣTx Fees\text{Block Reward} = \text{Coinbase BTC} + \Sigma\text{Tx Fees} Miner reward Total incentive for finding a valid block

IIVisualization 1: The Mining Lottery — How Difficulty Scales

A valid block requires its hash to start with a certain number of leading zeros. Each additional leading hex zero multiplies the difficulty by 16× because each hex digit has 16 possible values (0–F).

Explore: Drag the slider to see how the number of required leading zeros affects the expected number of hash attempts.

⚙ interactive visualization — coming to this page format soon

IIIVisualization 2: Confirmation Depth & Attack Probability

Once a transaction is buried under additional blocks, reversing it requires an attacker to secretly rebuild the entire chain from that point forward — and outpace the honest network. The probability of success decays exponentially with each confirmation.

Explore: Adjust the attacker's hashrate share and watch how quickly the attack probability collapses with each new confirmation.

⚙ interactive visualization — coming to this page format soon

IVVisualization 3: Mining Economics — Why Honesty Pays

Miners face a choice: mine honestly and collect guaranteed block rewards, or attempt a double-spend attack. The expected value of each strategy depends on block rewards, the value being reversed, and the attacker's share of hashpower.

Explore: Adjust all three parameters. Can you find any scenario where attacking beats honest mining after a few confirmations?

⚙ interactive visualization — coming to this page format soon

VQuiz Questions

Question 1 · The Core Asymmetry

The video states that approximately 168 billion trillion hash attempts are needed to find a valid block, yet anyone can verify the solution with exactly one computation.

Which property of SHA-256 makes this "easy to verify, hard to produce" asymmetry possible?

Correct! All three SHA-256 properties are essential: determinism enables one-step verification, irreversibility forces brute-force search, and unpredictability prevents any shortcut.

Not quite. That property is important, but consider: would the system still work if any of the other properties were missing?

Show solution

Solution:

All three properties are essential to the asymmetry:

  • Determinism enables verification — anyone can re-hash the block and confirm the output matches
  • Irreversibility forces miners to guess — there's no way to work backward from the desired output
  • Unpredictability prevents shortcuts — no pattern can be exploited to skip ahead

Remove any one and the system breaks:

  • Without determinism → verification is impossible
  • Without irreversibility → miners could solve instantly by working backward
  • Without unpredictability → miners could predict which inputs produce desired outputs

The answer is all three properties working together.

Question 2 · Difficulty Calculation

If the mining target requires 5 leading hex zeros in the hash output, approximately how many hash attempts are expected on average?

Recall: each hexadecimal digit has 16 possible values (0–F).

Correct! Each hex zero is a 1-in-16 event, so k zeros requires 16^k = 16^5 ≈ 1 million attempts on average.

Not quite. Each hex digit has 16 possible values, and requiring it to be 0 is a 1/16 probability. For k independent digits, probabilities multiply: (1/16)^k.

Show solution

Solution:

Each hex digit must independently be 0 (1 chance out of 16 possibilities):

P(k leading zeros)=(116)kP(k \text{ leading zeros}) = \left(\frac{1}{16}\right)^k

For k=5k = 5:

P=1165=11,048,576P = \frac{1}{16^5} = \frac{1}{1{,}048{,}576}

Expected attempts=1P=165=1,048,5761 million\text{Expected attempts} = \frac{1}{P} = 16^5 = 1{,}048{,}576 \approx \textbf{1 million}

Common mistakes:

  • 5×16=805 \times 16 = 80: Multiplying instead of exponentiating
  • 25=322^5 = 32: Using base 2 instead of base 16 (hex has 16 values, not 2)
  • 2565256^5: Confusing hex digits (16 values each) with full bytes (256 values each)

Question 3 · Attack Capabilities

True or False: An attacker who controls more than 50% of the network's total hashrate can create transactions that spend other people's Bitcoin.

Correct! Hashpower determines which blocks get added, but consensus rules — enforced by every node — determine which transactions are valid. No amount of mining power can forge someone else's cryptographic signature.

Not quite. Remember: mining determines block ordering, but consensus rules (enforced by all nodes) determine validity. Can raw computation forge a private key signature?

Show solution

Solution: False

Even with >50% hashrate, an attacker cannot:

  • Spend someone else's coins (requires their private key for a valid digital signature)
  • Create Bitcoin out of thin air (violates consensus rules)
  • Change the rules of the Bitcoin protocol

A majority attacker can only:

  • Reverse their own past transactions (double-spend attack)
  • Censor specific transactions (refuse to include them in blocks)

The critical insight: consensus rules are enforced independently by every node on the network, regardless of who mined the block. An invalid transaction is rejected by all honest nodes, no matter how much hashpower produced the block containing it. Mining power determines which valid blocks get added — not what counts as valid.

Question 4 · Confirmation Depth Calculation

An attacker controls 30% of the network hashrate (q=0.30q = 0.30). Using the approximation:

P(attack success)(q1q)z=(0.300.70)zP(\text{attack success}) \approx \left(\frac{q}{1-q}\right)^z = \left(\frac{0.30}{0.70}\right)^z

What is the approximate probability of successfully reversing a transaction after 6 confirmations?

Correct! (3/7)^6 ≈ 0.0062 ≈ 0.6%. After 6 confirmations, even an attacker with 30% of all hashpower has less than a 1% chance of reversing the transaction.

Not quite. Make sure you're raising (q/(1−q)) = (3/7) to the power z = 6 — the full number of confirmations. Each confirmation multiplies by the same factor.

Show solution

Solution:

With q=0.30q = 0.30 and z=6z = 6 confirmations:

P=(q1q)z=(0.300.70)6=(37)6P = \left(\frac{q}{1-q}\right)^z = \left(\frac{0.30}{0.70}\right)^6 = \left(\frac{3}{7}\right)^6

Step by step:

370.4286\frac{3}{7} \approx 0.4286

0.428620.1837(about 18%)0.4286^2 \approx 0.1837 \quad (\text{about 18\%})

0.428630.0787(about 8%)0.4286^3 \approx 0.0787 \quad (\text{about 8\%})

0.42866=(0.42863)20.078720.00620.4286^6 = (0.4286^3)^2 \approx 0.0787^2 \approx 0.0062

P0.62%0.6%P \approx 0.62\% \approx \textbf{0.6\%}

Why the other answers are wrong:

  • 18% uses the exponent 2, not 6
  • 8% uses the exponent 3, not 6
  • 30% confuses the hashrate share qq with the attack probability

Each confirmation multiplies the probability by 370.43\frac{3}{7} \approx 0.43, creating dramatic exponential decay.

Solved: 0 / 4