Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Bitcoin has probabilistic finality, not absolute. One confirmation reduces reorg probability; six is the canonical 'final enough' threshold. The math: probability of a deeper reorg falls exponentially with depth, given honest hashrate majority. Exchanges, custodians, and on-chain settlement systems all calibrate confirmation requirements based on transaction size.
Confirmation math.
Use these three in order. Each builds on the one before.
In one paragraph, explain confirmations and probabilistic finality.
Walk me through the math of reorg probability.
Design a deposit-policy table for an exchange: required confirms vs deposit size. What's the calculus?
# Probability that an attacker with q < 0.5 fraction of hashrate
# successfully replaces N confirmations (Nakamoto's whitepaper formula):
import math
def reorg_probability(q: float, n: int) -> float:
"""Probability attacker controlling fraction q (< 0.5) of hashrate
replaces n confirmations. From Bitcoin whitepaper."""
p = 1 - q
lam = n * (q / p)
total = 0.0
for k in range(n + 1):
# Poisson PMF
pk = (lam ** k) * math.exp(-lam) / math.factorial(k)
# Conditional probability of catching up
if k >= n:
qk = 1.0
else:
qk = (q / p) ** (n - k)
total += pk * qk
return total
# Example: 10% attacker
for n in [1, 2, 6, 10]:
p = reorg_probability(0.10, n)
print(f"q=10%, n={n}: P(success) = {p:.6f}")
# Output (approx):
# q=10%, n=1: P(success) = 0.205
# q=10%, n=2: P(success) = 0.051
# q=10%, n=6: P(success) = 0.00059
# q=10%, n=10: P(success) = 0.0000122
# For 30% attacker, even 10 confirms is risky (~5% reorg probability).
# For 1% attacker, 1 confirm is fine for small amounts.
# Standard exchange rule: 6 confirms (about 1 hour) for safety against
# any realistic adversary.