freecoding.school100% FREE · NO SIGNUP
Proof PeaksISSUE #27 of 38

nakamoto consensus · longest-chain analysis

ZeekaVSThe Collision
Zeeka saysNakamoto consensus picks the chain with the most cumulative proof-of-work — the probability of an attacker reversing N confirmations falls exponentially.

Bitcoin's consensus rule is brutally simple: follow the chain with the most accumulated work. When two miners find blocks simultaneously, both honest forks coexist briefly; the next block extends one of them, and that one wins. The deep insight is that reversing a transaction buried under N confirmations requires an attacker to outpace the honest network across every one of those N blocks.

The classic Satoshi analysis derives P(reversal) ≈ (q/p)^N for attacker hashrate fraction q < honest p = 1-q. Six confirmations against a 10% attacker gives about a 1-in-50,000 chance of reversal — the origin of the "six confirmations" convention. The probability never reaches zero, just vanishingly small; that is what probabilistic finality means.

Power-ups you unlock

The Collision attacks — common mistakes

Boss battleCompute the probability an attacker with 10% hashrate reverses 1, 3, and 6 confirmations.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>
// Satoshi reorg-probability: attacker hashrate q catches up from z behind with prob (q/p)^z.
const pCatchUp = (q, z) => q >= 1-q ? 1 : Math.pow(q/(1-q), z);
const q = 0.10;
const rows = [];
for(let z = 1; z <= 6; z++){
  rows.push(z + ' confirmations → reversal probability ≈ ' + (pCatchUp(q,z)*100).toFixed(4) + '%');
}
document.getElementById('o').textContent = [
  'attacker hashrate q = ' + q + ', honest p = ' + (1-q),
  ...rows,
  'probability never reaches 0 — just vanishingly small (probabilistic finality)',
  'if q ≥ p, attacker wins eventually (51% attack)'
].join('\n');
</script></body></html>
▶ Open the interactive comic issue
‹ Zkevm Types · Type 1 Through Type 4The Ghost Protocol · Heaviest Subtree ›