Blog

Proving zkWasm Sound: Inside CertiK and Delphinus Lab’s Formal Verification Research

Policy pulse
Proving zkWasm Sound: Inside CertiK and Delphinus Lab’s Formal Verification Research

A zero-knowledge proof is only as trustworthy as the constraints behind it. If a zkVM’s circuits miss a single check, a prover can convince a verifier that a program ran when it did not, and nothing in the system raises an alarm. As zkVMs take on more of the blockchain stack, making sure those constraints are complete has become a core security problem.

CertiK and Delphinus Lab took that problem on together, formally verifying the circuit soundness of zkWasm, Delphinus Lab’s zkVM for WebAssembly (Wasm). To unpack what the research achieved, CertiK’s Mihai Tempeleanu sat down with Xin Gao, founder of Delphinus Lab, and Vilhelm Sjöberg, Principal Scientist at CertiK and team lead for the zkWasm project.

Three places a zkVM can go wrong

Delphinus Lab works on real-world applications of zero-knowledge technology and formal methods, with a focus on succinct ways to prove program execution. Its main directions today are zkVMs and proving AI model inference.

Asked about the main security challenges facing zkVMs, Xin broke them into three parts:

  1. The circuit has to match the VM. The constraints must respect the semantics of the virtual machine and every instruction it supports.
  2. The encoding has to be sound. The method used to encode those constraints into a zero-knowledge proving scheme must itself be sound.
  3. Aggregation has to be sound. Because a zkVM proves a long, continuing execution, many proofs must be combined into one, and that aggregation must be sound too.

The CertiK–Delphinus Lab research targets the first of these.

What circuit soundness means

“Do the constraints in zkWasm actually represent Wasm program executions, or did anyone make a mistake so that a program that shouldn’t execute can be proven to have a particular value?” Vilhelm asked. “The result we're claiming is called circuit soundness.”

When zkWasm runs, the prover builds a witness, and the underlying ZK prover shows that the witness satisfies the constraint system. Circuit soundness means the reverse also holds: anything that satisfies the constraint system represents a real Wasm execution. In other words, there are no gaps in the constraints that could let an invalid execution through.

Proving that took three steps:

  • Formalize Wasm. The team wrote down the semantics of the Wasm bytecode language in a proof assistant, drawing on existing research that formalizes Wasm.
  • Model the circuits. They built an axiomatized version of the zkWasm constraint system.
  • Connect the two. The bulk of the proof shows that each row in the large table of numbers that makes up the zkWasm witness represents a step of a Wasm execution.

Once that proof is complete, the constraints cannot have skipped a property the semantics require. For the multiplication instruction, for example, the result really is the product of the two inputs.

The hard part: memory

According to Vilhelm, the project's most important technical contribution was how it handled memory.

Earlier efforts to verify zkVMs typically worked one instruction at a time. In a real system, though, each instruction reads data from memory, operates on it and writes the result back. Prior work could show that a multiplication instruction multiplied two values, but it simply assumed two values were read from memory and one was written back. It said nothing about the memory system itself.

That gap matters because instructions only form a program through memory. Without a model of memory, verified instructions cannot be chained into one long, verified execution. The difficulty is that zkWasm implements its memory subsystem with a completely separate set of constraints.

“I think our biggest single contribution is that we figured out a good way to specify what the memory subsystem should be doing so that it's easy to connect it to the instructions,” Vilhelm said. The result is a single theorem that covers both the instructions and the memory they write to. It shows not just that each instruction executes correctly, but that the entire program does.

How the collaboration worked

Delphinus Lab had built zkWasm's constraints iteratively: find an underconstrained part, strengthen it, and repeat. Eventually the team reached a point where it could no longer tell whether the constraints fully captured Wasm semantics or were still underconstrained.

"We didn't have the knowledge and techniques to actually verify whether all the constraints we used to describe zkWasm were sufficient," Xin said. Human code review alone would not settle the question, so Delphinus Lab asked CertiK for help, and CertiK set up a dedicated research project.

The two teams split the work by expertise. CertiK led the formalization: writing the specifications and working out how to apply them to the system. Delphinus Lab served as the zkVM experts. When CertiK's researchers were unsure how part of zkWasm worked, or thought they had found an issue, Delphinus Lab could confirm the problem or point to a constraint elsewhere in the system that already covered it.

For Xin, the outcome went beyond zkWasm itself. The project showed that formal methods are a feasible way to verify that a zkVM's constraints respect its semantics, even for a VM as complex as Wasm.

Three bugs, and one testing would never find

The verification uncovered three soundness bugs. Two were simple: single lines of constraints that were wrong. One constraint checked the wrong variable and let invalid values through. Another constrained a particular piece of data in the wrong way.

Testing or code review could have caught those two, but didn't. "Formal verification is helpful here because it really forces you to cover every single case," Vilhelm said.

The third bug was different, and it involved the call stack. zkWasm represents the call stack as a linked list stored in a set of table rows, recording the return addresses currently on the stack. Each function call adds another item to the list.

In a ZK system, every one of these tables could be built by a malicious prover, so the constraints must ensure each table is valid. zkWasm used a counting scheme for this: if the number of call instructions in the program matched the number of rows in the call-stack table, an attacker could not slip extra rows into the table.

In the version CertiK reviewed, that counting scheme was broken. Instead of counting only calls, it counted both calls and returns, on the assumption that every call is matched by exactly one return, so each call-and-return pair adds two to the count.

A malicious trace offers no such guarantee. "You can construct a very contrived trace with one call and three returns," Vilhelm said. "Because one plus three is an even number, this counting scheme still goes through."

That is exactly the kind of case conventional testing misses. A fuzzer or randomized tester would never think to generate a trace with one call and three returns. Formal verification, by contrast, requires proving that every invariant of the table holds. The team's proofs would not go through, and working out why led them to the flaw. The fix was to count only calls.

What it means for developers and zkVM builders

Most developers will not write Wasm directly. They compile to it from languages such as C. For them, Xin said, the benefit is confidence: if zkWasm generates a proof for their program, the witness trace is proven to respect WebAssembly semantics.

The research also matters for people building zkVMs. It shows they can use formal methods to back up the claim that their constraints match their VM's semantics. Xin argued that builders should think about proving their constraints from the start, rather than finishing a circuit and then asking for help to prove it. "The number of ZK applications out there exceeds the number of proven ZK constraint systems," he said. A repeatable approach to proving circuit soundness would help close that gap.

Toward a fully verified ZK stack

Both researchers see the techniques carrying well beyond zkWasm. Vilhelm pointed to the memory specification in particular as something other zkVM verification projects can reuse. CertiK is also working to optimize the proving process itself, making it both more watertight and cheaper, with partial results reported in the paper. Xin added that the same techniques could apply to other ZK workloads, including the matrix and vector multiplication at the heart of AI inference.

"I think if we did the same kind of project for a new client today, we could make it a lot faster," Vilhelm suggested.

The long-term goal, in his words, is "a fully verified ZK stack." Circuit soundness is one piece. A complete stack also needs verified zkVM frontends and verified proving backends, ideally combined in a single proof system. Vilhelm expects that goal is not far off, given how many people are working toward it, and sees it as crucial to adopting ZK more widely in blockchain without worrying about hidden soundness bugs.

For the full technical details, read the paper: Formal Verification of Circuit-Soundness in zkWasm, a General Purpose zkVM (opens in a new tab).

FAQs

What is zkWasm?

zkWasm is a zero-knowledge virtual machine (zkVM) developed by Delphinus Lab. It generates zero-knowledge proofs that a WebAssembly (Wasm) program executed correctly.

What does circuit soundness mean?

Circuit soundness means that anything satisfying a zkVM's constraint system represents a valid program execution. For zkWasm, it means a prover cannot satisfy the constraints with a trace that does not correspond to a real Wasm execution.

What did the formal verification uncover?

The verification found three soundness bugs. Two were single-line constraint errors. The third was a flaw in the counting scheme that protected zkWasm's call-stack table, which a malicious prover could exploit with a trace containing one call and three returns.

Why wouldn't conventional testing catch these bugs?

Testing only checks the cases someone thinks to try. The call-stack bug required a deliberately contrived trace that a fuzzer or randomized tester would be unlikely to generate. Formal verification forces every invariant to be proven for every possible case, so the flaw surfaced when the proofs failed to go through.

Can this approach be applied to other zkVMs?

Yes. The way the team specified zkWasm's memory subsystem is generally usable for other zkVMs, and many of the proof techniques carry over to other ZK applications.

Share

Tell us what you are building.