SpectreImplementation

Design choices

Implementation · the three design choices behind Spectre, and why we made each.

ChoiceWhat it isEffect
Static circuit with dynamic bucketsA fixed gnark / Groth16 circuit, compiled at a set of fixed signer-count sizesMuch faster proving than a zkVM program
Hybrid designOnly the heavy ed25519 verification runs in ZK, while logic that is cheap on-chain stays in SoliditySmaller circuit, faster proving time
ICS-02 / ICS-07 splitupdateClient split into update consensus state and update application stateCut gas consumption on unnecessary operations

Static circuit

We build the prover on a static gnark circuit with Groth16. We choose gnark and Groth16 because the stack is stable and gives us powerful optimizations and useful gadgets to build on. A static circuit is purpose-built for exactly one computation, so it carries none of the general-purpose overhead of a zkVM and needs far fewer constraints. That is why it proves far faster than a zkVM program running the same computation.

The downside is flexibility. A static circuit is fixed at compile time, so it allows only a pre-defined, fixed-size witness and static logic. Signature verification, though, does vary in size, because the number of validators that sign a header changes from one update to the next. So we compile the circuit at a fixed ladder of sizes that we call buckets, at N ∈ {4, 8, 16, 32, 64, 128} signers. For a given update, the prover selects the smallest bucket that fits the number of signatures it must prove and pads the remaining slots with dummy entries, which are excluded from the on-chain quorum. The circuit stays static, and the proving cost tracks the number of quorum signers rather than the chain's full validator count.

Hybrid design

We do not put everything into the ZK circuit. Anything cheap enough to run directly on-chain stays in Solidity. sha256, for example, has an EVM precompile, so hashing costs very little gas and there is no reason to prove it in a circuit. As a result, receive/ack/timeout packet and misbehaviour logic is just plain Solidity.

Only the part that is heavy and impossible on-chain goes into ZK, namely the ed25519 verification of the signed header. Ethereum has no ed25519 precompile, so verifying a whole validator set's signatures directly in the EVM would be prohibitively expensive. That is the one piece we have to prove in ZK. Everything else in the update flow stays Solidity, including the basic header validation in UpdateClient and the finality check (the ⅔ voting-power quorum).

ICS-02 / ICS-07

We re-design ICS-02 so that the single updateClient API is split into two calls, update consensus state and update application state. ICS-07, the Tendermint client, follows by implementing the two split methods instead of a single updateClient.

We split them because a chain's validator set rarely changes meaningfully. Its voting power drifts often as stake moves, but the set's membership and power distribution stay effectively the same, and only a major update requires updating the valset. Valset update is the expensive path, because it requires re-hashing the whole valset, so we do not want to run update consensus state for every minor drift. Update application state, by contrast, only advances the block state, the header's appHash, and it is needed for every IBC transaction, so it runs frequently and cheaply.

On this page