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

zkvms · risc zero · sp1 · cairo

ZeekaVSThe Collision
Zeeka saysA zkVM proves the correct execution of an ordinary program, not a hand-built circuit: it proves every step of a virtual machine, so you write normal code and get a proof.

Writing circuits by hand is brutal. A zkVM moves the abstraction up: it proves the correct execution of a general-purpose virtual machine, instruction by instruction. You write a normal program (RISC-V for RISC Zero and SP1, Cairo for Starknet), run it, and the zkVM emits a proof that every step transition was valid.

The cost is some prover efficiency versus a hand-tuned circuit, but the developer win is enormous — provable computation in a language people already know. The demo runs a tiny stack VM for (3 + 4) × 2, builds its execution trace, and confirms the output is 14, which is exactly the kind of step-by-step trace a real zkVM proves.

Power-ups you unlock

The Collision attacks — common mistakes

Boss battleRun a tiny stack VM for (3 + 4) × 2, build its execution trace, and confirm the output is 14.

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>
// zkVM: prove correct execution of a PROGRAM by proving every step transition.
const prog=[['PUSH',3],['PUSH',4],['ADD'],['PUSH',2],['MUL']];   // (3 + 4) × 2 = 14
function run(p){ const trace=[], st=[]; for(const [op,a] of p){
  if(op==='PUSH') st.push(a);
  if(op==='ADD'){ const y=st.pop(), x=st.pop(); st.push(x+y); }
  if(op==='MUL'){ const y=st.pop(), x=st.pop(); st.push(x*y); }
  trace.push({ op, top: st[st.length-1], depth: st.length });
} return { trace, out: st[st.length-1] }; }
const { trace, out } = run(prog);
document.getElementById('o').textContent = [
  'program: (3 + 4) × 2',
  ...trace.map((t,i)=> '  step ' + i + ' ' + t.op.padEnd(5) + ' → top=' + t.top + ' depth=' + t.depth),
  'output = ' + out + '   (== 14 ? ' + (out===14) + ')',
  'a zkVM proves every step transition is valid → trustless off-chain compute'
].join('\n');
</script></body></html>
▶ Open the interactive comic issue
‹ Recursive Proofs · Proof AggregationZkevm Types · Type 1 Through Type 4 ›