kartikeya sharma
AI Verification · Applied Cryptography · AI Safety

What Your Zero Knowledge Proof Does Not Prove

Monday, August 24, 2026

Zero Knowledge ProofsFormal VerificationTrust Boundaries

Your proof can be valid, your verifier contract can be correct, the two of them can agree on every piece of mathematics between them, and the transaction still reverts.

Mine did, for seven weeks. On 3 July I generated a RISC Zero proof of a satellite computation and pushed the on-chain verification to a to-do item, where it sat. The proof verified locally on every run I ever did. The chain rejected it. I assumed the wrap was half finished, because that is the boring explanation and the boring explanation is usually right.

It was not the wrap. The proof had been valid the entire time. Eight 32-bit words were written to the calldata in the wrong byte order, and nothing in the stack is built to notice that.

The two verifiers disagreed and both were correct

The setup is ordinary. A RISC Zero guest re-executes a residual check over a satellite certificate. The host proves it, wraps the STARK into a Groth16 SNARK, and writes out the three arguments a Solidity verifier needs: the seal, the image ID, and the digest of the journal.

Local verification is one line in the host, and it passes.

[host] PROVED + VERIFIED in 2618.7s
[host] VERIFY_MS 5.0582
[host] JOURNAL_BYTES 432

Five milliseconds, receipt accepted, journal decoded, all fields as expected. Every signal on my machine said healthy.

On Base Sepolia the same seal, against the RISC Zero verifier router at 0x0b144e07a0826182b6b59788c34b32bfa86fb711, returned this.

execution reverted, data: 0x439cc0cd

My first guess was that the router had no verifier registered for my seal version, which is the common failure and has a distinctive error. So I decoded the selector instead of guessing. 0x439cc0cd is VerificationFailed(). Then I asked the router directly which contract it had registered for my seal's selector 0x73c457ba, and it answered 0x724d375b5b622e15f0e64e9deb76a4cb17877797.

So the routing worked. The right verifier received the proof, ran the pairing check, and rejected it.

At that point there are only two possibilities. The proof is invalid, or the statement I handed the verifier is not the statement the proof is about. The local verifier had already ruled out the first one.

Eight words, backwards

Here is the line, in the host.

let image_id = CERT_VERIFY_ID
    .iter()
    .map(|w| format!("{w:08x}"))
    .collect::<Vec<_>>()
    .join("");

CERT_VERIFY_ID is a [u32; 8]. Formatting each word with {:08x} prints it big-endian, most significant byte first. The canonical byte string of a RISC Zero digest is the little-endian serialisation of each word. Same eight words, same 32 bytes, with the four bytes inside every word reversed.

Toggle the two encodings below and watch what moves.

Image ID encoding
bytes sent to verify()
$ cast call 0x0b144e07…b711 "verify(bytes,bytes32,bytes32)" $SEAL $IMG $JOURNAL
execution reverted, data: 0x439cc0cd  VerificationFailed()
Same seal. Same journal. Same 32 bytes, regrouped. One of these settles on chain for 249,749 gas and the other one does not settle at all.

Nothing about the proof changed. The seal is the same 260 bytes, the journal is the same 432 bytes, the digest of the journal is the same 0xee0444bb…. Only the statement moved, and only inside each word.

I want to be careful about what kind of bug this is, because I filed it in my head under the wrong heading at first.

This is a completeness failure, which is why nobody was looking for it

Write down what soundness actually quantifies over. For a proof system Π = (Prove, Verify) with security parameter λ, soundness says that for every probabilistic polynomial-time prover P*,

Pr[ Verify(x, π) = 1  ∧  x ∉ L ]  ≤  negl(λ)

Read the quantifier. x is handed to Verify. The statement is an input to the security definition, not an output of it. Everything the proof system promises is conditional on both parties already agreeing on what x is.

In a deployment there is no such agreement. There is a map.

Setup: The challenger fixes a program identity I (here a [u32; 8] image ID) and a journal J. The honest encoding E* produces the canonical statement bytes x* = E*(I, J). The deployed encoding E produces x = E(I, J).

The deployed check: The prover computes π ← Prove(x*), and the chain computes Vchain(E(I, J), π).

Encoding fault: E ≠ E*.

Grade it.

Completeness: An honest prover with a correct proof is rejected whenever E ≠ E*. That is exactly what happened, for seven weeks. Fails.

Soundness: Untouched. The verifier rejected a statement it had no proof for, which is precisely the behaviour soundness demands. The system was never insecure. Perfect.

Zero-knowledge: Untouched. Nothing leaked. Perfect.

So my bug lived in the one property whose failure mode looks like a stuck ticket rather than a breach. Completeness failures get triaged as "the deploy isn't finished". They do not get security review, they do not get a postmortem, and they can sit in a backlog for two months while everybody assumes the missing piece is somewhere else.

Now flip the direction, because that is the part that should worry you. Suppose E is not injective, so two distinct statements collide onto the same bytes. Truncate the image ID, or pack a length field ambiguously, or hash a struct without domain separation. Then a proof about statement x₁ is accepted as a proof about x₂, and the same silence applies. That is a soundness break, delivered by the same class of defect, and the proof system will not see it because E was never inside the quantifier.

The property that needs stating out loud, and that neither the proof system nor the verifier contract checks, is this. E must be canonical and injective, and both sides must implement the same E.

Where the trust actually sits

I found this useful to draw. Click a link in the chain to see what carries a proof and what carries an assumption.

covered by a proof trusted, unproven
Pick a link
The zkVM covers exactly one of these five. The other four are engineering you have to get right by hand, and two of mine were wrong.

The middle link is the only one the zkVM is about. It says the guest with image ID I executed and produced journal J, and it says it with a soundness error negligible in λ. Every other link is ordinary software.

The second hole in the same boundary

While I had the prover up I rebuilt the guest from unchanged source to check something else, and got a different image ID.

The July build identifies as 7403d550c2a6…. Today's build of the same source, same repository, same machine, identifies as c48992463c2a…. The journals are byte-identical, the residual is the same to the last digit, the computation did not move. Only the program's name for itself did.

That matters more than it sounds. The image ID is the on-chain claim about which program ran. If a reader cannot rebuild the guest and arrive at the ID that is published, then the published ID is an assertion by me rather than a fact they can check, and the whole point of putting it on a chain evaporates. RISC Zero ships a fix for this, a containerised guest build that pins the toolchain, and I had not turned it on.

So the same boundary has two defects. The encoding of the program identity was wrong, and the derivation of the program identity was not reproducible. Both live in the gap between "the proof is valid" and "you and I agree on what it is a proof of".

What the corrected call actually costs

With the byte order fixed, the call returns empty, which is how the RISC Zero interface says yes. Here is where the money goes.

Show
276,389gas, whole transaction
249,749gas, the pairing check itself
$0.0042at 0.006 gwei, ETH $2,512
Hover a segment. Gas price read from Base mainnet and ETH spot from Coinbase on 24 August 2026, both stated so you can redo the arithmetic when they move.

Two proving runs sit behind that one call. The STARK and its recursion took 1,501 seconds before failing, and the successful wrap took 2,618.7 seconds with a peak resident set of 9.61 GB. The receipt shrinks from 2,251,496 bytes to 1,361 across that pipeline, and the seal that actually travels is 260 bytes.

That first failure is worth one paragraph on its own, because it wasted 25 minutes and it will waste yours. The wrap runs inside a container, so the prover process needs to reach the Docker socket. Mine could not.

thread 'main' panicked at host/src/main.rs:72:10:
  called `Result::unwrap()` on an `Err` value: docker returned failure exit code: Some(1)

The user was not in the docker group. The STARK and the recursion both completed first, so the run burns its full compute before dying on a permission check that could have been made in the first second. A groups check at startup would have cost nothing.

The rule I took away

I have written before about grading protocols on completeness, soundness, and zero-knowledge. What this cost me is that I had been grading Π, and shipping Vchain ∘ E.

So the question I ask now, before wiring any proof to any verifier I did not write, is which bytes both sides think the statement is, and who wrote each of the two functions that produce them. If the answer is "two different implementations in two different languages by two different authors", that map deserves a test vector of its own, checked in, with the canonical bytes pinned. It is three lines of test and it would have saved me seven weeks.

There's a broader version of this that I believe and will defend. Cryptographic assurance ends at the edge of the security definition, and the security definition starts after the statement exists. Everything upstream of that, the build that produces the program identity, the serialisation that produces the statement, the ABI that carries it, is unverified plumbing wearing the reputation of the proof it carries. Most of the code in a deployed proof system lives there.

The mathematics was never the risky part.

← Back to all articles