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

recursive proofs · proof aggregation

ZeekaVSThe Collision
Zeeka saysRecursive proofs verify other proofs inside a circuit, so N proofs collapse into one — turning O(N) verification into O(1) and letting rollups settle thousands of proofs at once.

A proof can include, as part of its statement, the claim that other proofs verified correctly. That is recursion: wrap N proofs inside one, and a verifier only checks the single outer proof. Verification cost drops from O(N) to roughly O(1), and you can build proof trees or prove a long-running computation incrementally.

This is the backbone of rollup scaling — thousands of transaction proofs aggregate into one proof posted to L1 — and of cross-proof composition. The demo aggregates 64 proofs under a single root and compares the one-check cost to verifying all 64 separately. (A real recursive proof replaces the root with a proof asserting every inner proof verified.)

Power-ups you unlock

The Collision attacks — common mistakes

Boss battleAggregate 64 proofs under one root and compare the verification cost to checking all 64 separately.

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>
// recursive aggregation: N proofs → ONE. verify cost O(N) → O(1).
const H=(s)=>{ let h=2166136261>>>0; for(const c of(''+s)){ h^=c.charCodeAt(0); h=Math.imul(h,16777619); } return (h>>>0).toString(16).padStart(8,'0'); };
const root=(leaves)=>{ let l=leaves.map(H); while(l.length>1){ const nx=[]; for(let i=0;i<l.length;i+=2) nx.push(H(l[i]+(l[i+1]||''))); l=nx; } return l[0]; };
const N=64, proofs=Array.from({length:N},(_,i)=>'proof#'+i+':verified');
document.getElementById('o').textContent = [
  'aggregating ' + N + ' proofs:',
  'verify each separately → ' + N + ' verifications',
  'verify ONE recursive proof → 1 verification (root ' + root(proofs) + ')',
  'speedup ≈ ' + N + '×  → rollups settle thousands of proofs as one',
  'recursion: a proof asserting "all N inner proofs verified"'
].join('\n');
</script></body></html>
▶ Open the interactive comic issue
‹ Fri · Low-Degree TestingZkvms · Risc Zero · Sp1 · Cairo ›