Three .zkasm files, verbatim from examples/. Every one of them is deployed to a live server and proved plus verified on every pull request -- see CI.
examples/fibonacci_like.zkasmThe simplest case: straight-line accumulator arithmetic, no branches, no registers.
# ((5 + 3) * 2) - 4 = 12 INIT 5 ADD 3 MUL 2 SUB 4
This is the exact program cmd_demo hardcodes to walk through prove/verify/tamper -- see the CLI Reference.
examples/branching.zkasmExercises JZ -- a forward-only conditional jump -- with two genuinely different control-flow paths depending on the initial value.
# If (initial - 5) == 0, skip the multiply and just add 1. # Otherwise, multiply by 100 before adding 1. # # initial=5 => ((5-5)=0, jump taken) => 0 + 1 = 1 # initial=8 => ((8-5)=3, jump not taken) => (3 * 100) + 1 = 301 INIT 5 SUB 5 JZ skip MUL 100 skip: ADD 1
The AIR has to prove which branch actually ran, not just that some valid branch exists -- see the transition constraints on the Architecture page.
examples/counter.zkasmExercises STORE and LOAD -- proves the register file holds state across other instructions, not just "the last computed value."
# Stash the starting value in r0, add 100 to the accumulator, then bring the # original value back to prove the register file actually holds state across # other instructions (not just "the last thing computed"). # # initial=7 => STORE r0 (r0=7), ADD 100 (acc=107), LOAD r0 (acc=7) => 7 INIT 7 STORE r0 ADD 100 LOAD r0
r0 is one of four fixed registers -- LOAD/STORE address a literal register number, not a computed memory address. See the .zkasm Spec for the full register model.
zkvm run examples/branching.zkasm zkvm prove examples/branching.zkasm out.proof zkvm verify examples/branching.zkasm out.proof
Or skip local proving entirely with zkvm deploy examples/branching.zkasm against a running zkvm-host-server -- see the CLI Reference for every subcommand.