Skip to content
Proofs and circuits

Formal verification

What the machine-checked proofs about Nimbus's circuits and on-chain code establish, why the circuits are built as they are, and the assumptions the proofs rest on.

Nimbus's circuits and its most critical on-chain code carry mathematical proofs, checked by machine, that hold for every input rather than for the inputs a test happened to try.

How it works

The proofs are written in Lean 4, a proof assistant whose small trusted checker verifies every step. Each circuit's constraints are written out as a Lean model, and theorems about the model state what any accepted proof must satisfy. Hash functions enter the models as abstract functions, so the results hold for any hash that meets the stated assumptions rather than depending on Poseidon's internals.

There are over 1,500 machine-checked theorems in all, more than 1,000 of them about the circuits for Solana and Robinhood Chain, and none is left incomplete. The circuit models follow the transaction circuit constraint group by constraint group and the escape-hatch circuit constraint by constraint, and a shared library models the building blocks every circuit uses: field arithmetic and bit decomposition, Merkle and indexed trees, secret sharing, fee rates and rounding, batch append and registration.

What is proved

The transaction circuit

Under the range bounds the circuit enforces, every accepted transaction satisfies these properties.

No value is created. For each token, the new notes cannot hold more than the spent notes and deposits brought in.

Every withdrawal is funded. A withdrawal is always covered by spent notes or deposits of the same token.

Fees are paid from the transaction. Protocol fees and the relayer's tip come out of the transaction's own value, never from nowhere.

No nullifier repeats. Each nullifier a transaction publishes appears exactly once among its three.

A spend stays in one zone. Real inputs share one zone, and the zone's signature is required unless the transaction is in the default zone, which opts out of it.

The sender record is faithful. Two accepted transactions with the same sender record have the same inputs and outputs, so the record pins down what the transaction moved, slot by slot.

Honest transactions are possible. The proofs also show that the real circuit shape admits honest transactions, for user-owned, program-owned and mixed spends. Without this, a set of constraints that nothing could satisfy would make every other guarantee trivially true.

The escape hatch

The payout is backed by one real, unspent note, and the details the escape discloses are that note's. The note's version is not disclosed, and the proofs show it is still tied to that same note.

Why the circuits are built this way

Some theorems explain the circuits' design: they show which checks carry each guarantee, so every one of them is kept in place.

Range checks keep amounts exact. The 64-bit range checks are what make value conservation hold in field arithmetic, where an unchecked amount could wrap around. The circuit enforces them on every amount.

Token addresses come from real accounts. The shielded pool program supplies the token address of every deposit and withdrawal from real accounts, so the circuit takes it as given rather than range-checking it.

Fees have a proved range. When one destination is funded by several owners, the fee depends on how the sources are allocated to it. It always lies between the two rates that could apply, and a prover may always pay more.

Values are compared in canonical pieces. Comparing full-size field values directly could let a value pass as less than itself, or let a gap check pass over a spent nullifier. Every circuit therefore splits values into smaller, canonical pieces before comparing them.

The on-chain side

The Rust code behind the shielded pool's trees and double-spend checks is model-checked with Kani, which runs the real code on every input up to a stated size and checks that its assertions hold for all of them. Lean models of the same code prove the central properties for inputs of any size.

Double-spend protection

Nullifiers, registrations and fee nullifiers pass through a staging buffer before they are committed. The checks establish that a key cannot be staged twice, in one buffer or across both; that a stale root is refused once its buffer retires; that the commit watermark only rises; that a commit with the wrong root or batch chain is refused; that a malformed key is refused and writes nothing; and that bounded operations never fail unexpectedly. In every reachable state, no key is staged twice.

The filter that answers "has this key been staged?" is proved exact: a held key is always found and an absent key never is, through every sequence of inserts and wipes. A poor choice of filter positions can cost compute, but it can never let a staged key through.

The note tree

The append-only tree behind the note, identity and fee trees is checked to give the same root incrementally as a full recomputation, to assign positions in sequence, to refuse new leaves once full, to accept every honest path and refuse malformed ones, and to keep exactly its window of recent roots. Appending a batch of leaves is proved to give the same tree as appending them one at a time.

The batched proof check

A private transaction is checked with one pairing that covers its transaction proof, its nullifier-freshness proof and the combined attester signature, each weighted by a random value derived from everything the submitter supplied. The proofs show the combined check passes whenever all three individual checks would, and that if any one of them would fail, a forged batch passes with probability at most 2⁻²⁵³.

The shielded pool program

The pool's fast check of its fixed accounts is proved to accept exactly the accounts the full derivation would. The cached committee key is proved always to equal the sum of the four keys it stores, so using it never changes the key the combined attester signature is checked under. Fee commitments staged by transactions are proved to reach the fee tree in the order they were staged, at the positions they were staged for, without the store ever exceeding its capacity.

Governance and the verifiers

The shared governance timelock is proved to enforce its rules for authorities, delays, expiry and cancellation. The guardian node registry, the enclave attestation verifier and the signature verifiers carry Lean models of their own.

Checks on the compiled circuits

Alongside the Lean models, every production circuit is checked on what it actually compiles to: for outputs a prover could choose freely, for signals no constraint touches, and for constraints no test would notice missing. Audits and verification describes these checks.

Assumptions

The proofs rest on the following assumptions, which are stated explicitly. Every build checks that the main transaction theorems rely on these and no others.

Each model matches its circuit. The Lean models are written from the circuits, and that each matches its compiled circuit is assumed. The compiled-circuit checks above support it.

Poseidon is collision-resistant. Poseidon is treated as collision-free on inputs of equal length, the standard idealisation of collision resistance.

Standard cryptographic hardness. Pseudorandomness of Poseidon, hardness of discrete logarithms on Baby Jubjub and collision resistance of Keccak are taken as standard assumptions, as are the cryptographic primitives the protocol builds on.

The field is prime. The order of the BN254 scalar field is taken to be prime.

The proofs cover the core; the rest is tested. The proofs cover the circuits and the on-chain components above. The shielded pool program's instruction handlers are assured by simulation testing, and the off-chain services (guardian nodes, screener, fee enclave, data endorser, relayer and indexer) by testing and audits.

Last updated

On this page