← All posts

What Miden’s audit says about transaction kernel design

OpenZeppelin’s Miden transaction kernel audit highlights a broader engineering problem: transaction kernels fail at boundaries, encodings, and composition points. Here is what to inspect in your own protocol design, and where validation logic often breaks.

OpenZeppelin recently published an audit of the Miden transaction kernel. One short fact stands out. The report notes issues around note execution and transaction validation logic. For anyone building account-based or note-based systems, this matters beyond one codebase.

A transaction kernel is where protocol rules turn into executable constraints. If the kernel accepts an invalid state transition, every layer above it inherits the mistake. If the kernel is too rigid, upgrades and app logic become fragile. You should treat kernel design as part cryptography, part systems engineering, and part failure containment.

For practitioners, the useful question is not whether one audit found bugs. Audits usually do. The useful question is what classes of failure appear in transaction kernels, how to inspect them, and how to test your own design before mainnet users do it for you.

Inspect the boundary between intent and state transition

Most transaction systems have a gap between what a user intends and what the protocol proves. Bugs live in this gap.

In a note-based design, the user intent often includes:

  • which notes to consume
  • which assets or data fields to create
  • who is allowed to authorize the action
  • which scripts or predicates govern spend conditions
  • which contextual data the kernel reads during validation

The kernel then reduces this to a state transition. It checks nullifiers, membership proofs, signatures, script outputs, and conservation rules. If any part of this reduction is underspecified, you get room for inconsistent execution.

What to inspect:

  • Whether every user-controlled field feeds into the authenticated transcript.
  • Whether script outputs are bound to the final transaction commitment.
  • Whether note metadata, asset type, amount, and recipient fields are all covered by one canonical hash.
  • Whether the transaction context includes any values which differ across proving, mempool admission, and final execution.

A common failure is partial binding. For example, a script proves one statement about a note, but the kernel later interprets a wider set of fields than the proof committed to. Another is duplicate semantics, where the same business rule is enforced partly in script code and partly in the kernel. When those checks drift apart, edge cases appear.

You want one rule, one place, one commitment path.

Treat note consumption as a concurrency problem

Kernel logic often looks pure and mathematical. In practice, note consumption has the shape of a distributed systems race.

If two transactions try to consume the same note, your nullifier scheme is the first line of defense. Yet the implementation details matter:

  • When is the nullifier derived?
  • Which fields are included?
  • Is derivation domain-separated by note type or spend path?
  • Does the kernel reject duplicate consumption across all internal execution branches?
  • Are batched transactions checked for intra-batch collisions?

Designers often focus on double spend in the global ledger sense. They spend less time on local replay and aliasing. A note with multiple valid spend paths, or a script with conditional branches, needs a clear rule for how one spend path invalidates all others.

Look for these test cases:

  • the same note referenced twice in one transaction
  • the same logical asset represented through two serialization forms
  • a note spent through one path while another path still passes prechecks
  • nullifier derivation collisions across note versions
  • transactions which reorder note inputs without changing visible semantics

Property tests help here. Define invariants such as, “one consumed note yields one unique nullifier,” and, “no accepted transaction leaves an alternative valid witness for the same spent object.” Then fuzz serialization, branch order, and witness shape.

This is where many teams go wrong. They prove cryptographic soundness of a spend condition, but they do not prove uniqueness of the state transition induced by that spend.

Make serialization boring and canonical

Transaction kernels fail in quiet ways when equivalent data admits multiple byte encodings. This is not a cosmetic issue. Hashes, signatures, Merkle leaves, and proof statements all depend on exact bytes.

You should assume every ambiguous encoding turns into one of four problems:

  • mismatched hashes between components
  • replay through alternate encoding
  • inconsistent verification across languages
  • proof statements bound to one representation while execution reads another

Canonical encoding rules need to be explicit.

Check these points:

  • fixed field order
  • fixed integer width and endianness
  • one encoding for optional fields
  • one normalization rule for empty values
  • rejection of trailing bytes and duplicate keys
  • version tags included in the committed message

If your protocol spans Rust, Go, TypeScript, and proving circuits, cross-implementation test vectors are mandatory. Generate a corpus of valid and invalid transactions, then verify byte-for-byte agreement across every parser and serializer.

A simple discipline helps. Treat decoded structs as untrusted until they are re-encoded and matched against the original byte string. This catches permissive decoders early.

In kernel work, flexible parsing is usually a bug.

Separate local validity from global validity

A transaction kernel often mixes checks from two domains:

  • local validity, such as signature correctness, script satisfaction, note ownership, and arithmetic constraints
  • global validity, such as nullifier freshness, root membership against current state, fee rules, and block-level resource limits

Mixing them without a clear contract creates edge cases for mempools, sequencers, provers, and light clients. A transaction might be locally valid under one state root but globally invalid under another. If the kernel API does not distinguish these states, upstream components guess.

You should define, in code and in docs, which claims hold after each validation stage.

For example:

  • parsing stage guarantees canonical bytes and structural well-formedness
  • local validation guarantees witness correctness against declared inputs
  • stateful validation guarantees freshness and membership against a specific root
  • inclusion guarantees resource accounting under block rules

This separation matters for zero-knowledge systems. A proof often attests to local correctness over committed inputs. The chain still needs a stateful gate around freshness and ordering. If developers blur the two, they risk proving something true but insufficient.

Where teams slip:

  • mempool acceptance rules differ from block acceptance rules
  • cached transaction checks outlive the state root they depend on
  • fee logic is enforced outside the proved statement
  • block builders assume scripts are deterministic across all environments

Write tests which mutate only the global context. Keep transaction bytes fixed. Then confirm which validation stage changes from pass to fail, and why. If the answer is hard to state, the boundary is weak.

Design for hostile composition, not isolated correctness

A kernel rarely fails on a single happy-path transaction. It fails when many valid pieces interact.

Think in compositions:

  • nested calls or chained note creation and consumption
  • account code interacting with custom predicates
  • fee payment logic interacting with asset constraints
  • upgrade hooks interacting with old note formats
  • batched execution interacting with rollback rules

The hard bugs sit in these joins. A subsystem is correct alone, then unsafe in composition because assumptions were implicit.

A good review method is to list every trust boundary:

  • user input to parser
  • parser to kernel representation
  • kernel to proving system
  • proving output to verifier
  • verifier result to state transition
  • state transition to event or receipt generation

Then ask one question at each boundary. What information is lost here? Lost information often becomes an exploit path later.

You should also inspect failure behavior. When one internal step fails, does the whole transaction revert, or do partial outputs survive? Are receipts emitted before all constraints finalize? Do side channels, such as gas use or error codes, expose data which note privacy aimed to hide?

These are protocol questions, not only implementation details.

What to watch next

Expect more audits to focus on transaction kernels, proving interfaces, and state-transition edge cases. As zk-heavy systems move from research to production, the core risk shifts from primitive selection to integration correctness.

If you build on a custom kernel, spend less time on headline features and more time on invariants. Write them down. Bind every field. Make encodings canonical. Separate local from global validity. Test compositions until they get boring. That is where transaction systems become dependable.