Study materials · photonresources.comClasses with our teachers · Photon AcademyFor IB Diploma students worldwide

Maths IA · Statistics and probability · topic 52 of 97

How many confirmations are safe? The double-spend race · IB Maths IA idea: guide, sample graph and step-by-step plan

the gap is a random walk

A shop sees your payment but waits for a few more blocks before handing over the goods. Wait for too few and a cheat with enough computing power can reverse it. Wait for too many and nobody buys anything. You are going to find the number that balances the two.

Difficulty●●● Stretch
KitA spreadsheet or short program for simulation, your GDC, the original white paper
TimeAbout 14 to 16 hours
FitsAA SL2 of 3AA HL3 of 3AI SL2 of 3AI HL3 of 3
  • ✓ you like probability that ends in a decision, such as how long to wait
  • ✓ you want to prove a result and then check it by simulation
  • ✓ you are comfortable with geometric series and a little Poisson probability

The big idea

Model two chains growing in a race. The honest miners find each next block with probability p, an attacker with probability q = 1 − p. If the attacker is z blocks behind, the chance that they ever catch up is (q/p)^z. Prove that with a recurrence, not just by quoting it: let h(n) be the catch-up chance from n behind, then h(n) = q·h(n−1) + p·h(n+1) with h(0) = 1. Next, the attacker also works while the merchant waits, so the deficit itself is random. Weight the catch-up chance by the probability of each deficit. Nakamoto's white paper uses a Poisson distribution for this step, and an exact version uses a negative binomial. Compare them, simulate the race, and say how many confirmations are enough for each share q.

Make it yours: pick one twist

Copying a classic won't show your choices. Pick one of these (or invent your own) and your IA becomes yours.

Swipe for more twists →

Prove the catch-up chance

Set up the recurrence for the catch-up probability, solve it and justify which solution is the right one.

→ A proof instead of a quoted formula. You must explain why q < p matters and what happens at q = p.
Simulate the race

Run a large number of random races for a chosen q and z, and compare the success rate with your formula.

→ Your algebra is tested by data you made yourself. Give a margin of error for the simulated rate.
Poisson against exact

Compute the success probability with the Poisson approximation and with the exact negative binomial, for the same q and z.

→ You measure an approximation error and find where it is largest. Explain why the Poisson version slightly understates the risk.
A waiting rule

For each q, find the smallest z that keeps the success probability below a chosen risk, such as 0.1%.

→ A table and a graph of z against q. Describe what happens as q approaches one half.
Value at stake

Compare the cost of waiting with the loss if the payment is reversed, and choose z for a small and a large payment.

→ A decision model: expected loss against a waiting cost. Say what the numbers assume.
Change the rules

Let blocks arrive faster, or let the attacker need to be one block ahead, and redo the race.

→ The recurrence boundary changes. Check which parts of your result survive.

Your Maths IA research question: run the check

what counts as success?

Write your own question first. Then make sure it ticks every box:

  • Names the model: two competing block-finders with fixed shares, and what counts as a successful attack.
  • Names the quantity you find: a success probability, or the waiting time for a given risk.
  • Says what the result is tested against: a simulation you wrote, or a published table.
  • Includes a derivation or proof, not only a formula taken from a paper.
  • States what you leave out: network delay, changing hash power and the cost of the attack.
Stuck on your question?Get an RQ Check: each question is scored on 5 points, with what to fix. Your first one is free.
Get an RQ Check

The model

Two chains grow from the same fork point. The merchant waits until the honest chain has z blocks. Draw your own race and mark the gap the attacker must close.

forkpointhonest chain: share p = 1 − q of the hash power1234attacker's secret chain: share qA1A2z = 4 confirmations (the honest blocks)k = 2 blocks found meanwhile; gap z − k = 2merchant waitsfor z blocksmust catch up from2 behind: chance (q/p)²

How your Maths IA could be laid out

The usual order for a topic like this, what each part needs to show, and roughly how much of your 12 to 20 pages it takes. The words are all yours.

Aim and context~1 page
What a double spend is, why waiting helps, and what you expect the success probability to do as z grows.
The race as a random walk~1.5 pages
Each block goes to the honest side with probability p or the attacker with probability q. The gap defined and the rules of the walk stated.
Catching up from n behind~2 pages
The recurrence, its solution, the boundary conditions and a proof that the chance is (q/p)^n.
The deficit while waiting~2.5 pages
The distribution of the attacker's blocks, the weighted sum, and the Poisson and exact versions side by side.
Simulation check~1.5 pages
Your simulation, the number of trials, and a table comparing simulated and calculated probabilities.
How long to wait~1.5 pages
The smallest z for each q at a chosen risk, with a graph and a comment on the shape.
Conclusion~1 page
Back to your aim: how the risk falls with z, and what waiting rule your results support.
Evaluation~2 pages, the biggest part!
Fixed hash shares, no network delay, the cost of attacking. Say which assumption matters most and what the model cannot say.
Bibliographynot counted
Where every formula, table and rule came from.

What your Maths IA graph could look like

try a log axis!

Made-up values to show the form of a strong graph, not the answer: the success probability against the number of confirmations on a log axis. Yours will use your own q. example only

0481216200.00.20.40.60.81.0Confirmations zSuccess probabilitycatch-up chance (q/p)^zsuccess with the deficit includedyour simulation (made-up)plot this on a log axis too:the curve becomes a lineILLUSTRATIVE · MADE-UP DATA
  • Theory and simulation on one set of axes, so agreement is visible.
  • Axis labels give units: confirmations are counts of blocks, probability has no unit.
  • A second graph on a log scale shows the constant fall per block as a straight line.
  • Simulated points need a margin of error. State how many trials you ran.
  • Another graph to consider: the confirmations needed for 0.1% risk against q.

The maths in action

worked through, not sketched!

The graph above was a sketch with made-up numbers. This figure works the idea through from the model itself, so you can see what a finished figure looks like. The source line under it says where every number comes from.

Two panels. Left: four falling curves on a log axis, steeper for smaller attacker shares, with a dashed line for the pure catch-up chance. Right: two nearly parallel curves rising sharply as the attacker's share approaches 0.45.
(a) Attacker's success probability against confirmations on a log scale for q = 0.1 to 0.4; the dashed line is the catch-up chance alone for q = 0.3. (b) Confirmations needed for risk below 0.1%: 89 blocks at q = 0.4 and 340 at q = 0.45.Source: Computed from the formulas in Nakamoto (2008), section 11, and the exact negative-binomial form (Rosenfeld, 2014); checked by simulation.

How long must a shop wait?

For each attacker share, how many confirmations keep the success chance below 0.1%? Compute your own table and explain why the numbers grow so fast near one half.

q = 0.15 blocksq = 0.211 blocksq = 0.324 blocksq = 0.489 blocksq = 0.45340 blocksa near-majority attacker needs hundreds of blocksConfirmations needed for risk below 0.1%ILLUSTRATIVE · MADE-UP NUMBERS

Your game plan

Tick steps off as you go. We'll remember on this device.

0 of 10 done

  1. Read and predictRead the section on calculations in the original paper. Before any algebra, guess whether the success chance falls quickly or slowly with z.
  2. Set up the raceDefine p, q, z and what counts as success. Draw the random walk of the gap between the chains.
  3. Solve the recurrenceWrite h(n) = q·h(n−1) + p·h(n+1), solve it, apply the boundary conditions and explain why the other solution is rejected.
  4. Trial run (1 lesson)Simulate 10,000 races for one q and one z and compare with a formula. Fix any mismatch now: who needs to be ahead, ties, off-by-one in z.
  5. Include the waiting timeFind the distribution of the attacker's blocks while z honest blocks arrive and weight the catch-up chance by it.
  6. Approximate and compareCompute the Poisson version and the exact version for several q and z. Measure the difference.
  7. Choose a waiting ruleFor each q find the smallest z giving your chosen risk. Graph z against q and describe the shape.
  8. Go further, with a reasonAdd the cost of waiting against the loss from a reversed payment, or change the rules of the race. HL: prove one more claim yourself.
  9. Reflect as you goAfter every result, write one line on what it means and what it assumes. These lines become your evaluation.
  10. Cut, check, then sendCheck every graph has labelled axes, every symbol is defined once and the conclusion answers your aim. Then send your teacher one draft.

The maths you'll use

  • Recurrence and boundary conditions – Solve with and show for .
  • Geometric sequences – Use the ratio to see why each extra confirmation multiplies the catch-up chance by the same factor.
  • Poisson and negative binomial models – Model the attacker's blocks while honest blocks arrive and sum probability times catch-up chance.
  • Simulation – Simulate many races, estimate the success rate and give a margin of error by the normal approximation.
  • Logarithms – Solve for the smallest with success below a target, and plot on a log axis to turn the decay into a straight line.

Key equations

Syllabus links

  • 1.3Geometric sequences and series
  • 1.8Infinite geometric series
  • 1.15Proof by induction, contradiction and counterexampleHL
  • 4.5Basic probability and expected frequency
  • 4.8Binomial distribution
  • 2.9Exponential and logarithmic functions

Read up first

Data and sources to start from

Random races generated in a spreadsheet or program, compared with the formulas and with the table in the original paper.

References to cite

  1. Nakamoto, S. (2008). Bitcoin: A peer-to-peer electronic cash system.
  2. Rosenfeld, M. (2014). Analysis of hashrate-based double spending. arXiv.
  3. Feller, W. (1968). An introduction to probability theory and its applications (Vol. 1, 3rd ed.). Wiley.

Cite what you actually use, in your own format, and say where each number came from.

Traps to avoid in this Maths IA

prove it, then simulate it
  • Quoting (q/p)^z as the final answer when the attacker also finds blocks while the merchant waits.
  • Forgetting the condition q < p. At q = p or above, the attacker catches up with probability one.
  • Not saying what counts as success: catching up to a tie, or getting ahead by one block.
  • Presenting a simulation result with no number of trials and no margin of error.
  • Reading z as 'number of blocks the attacker needs' instead of 'number of honest blocks waited for'.
  • Treating the Poisson formula as exact. It is an approximation, and you should measure its error.

More Maths IA ideas like this

Make sure it's yours

This guide shows how a topic like this is usually approached. It is not an IA. Your question, choices, data, analysis and words must be your own: change something, tell your teacher where the idea came from, and follow your school's rules on outside help.

Get your RQ checked · first one free