feat: introduce the circuit verification key registry - #3513
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are operational/runtime concerns in the new registry plumbing (cache freshness under clock rollback and blocking file I/O in an async retriever) that should be addressed before relying on this for revocation safety.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces the foundation for a genesis-signed circuit verification key (VK) registry and certification flow, enabling runtime whitelisting and retroactive revocation of SNARK circuit VKs over epoch ranges (to be enforced in follow-up PRs).
Changes:
- Add
CircuitVerificationKeyDigest(Poseidon hash of canonical VK bytes) inmithril-stm, plus accessors to expose digests from ancillary verifier data. - Introduce registry types in
mithril-common(whitelist + revocation-wins semantics) and a signed “raw JSON bytes” container with domain-separated genesis signature verification. - Add registry retrieval + certification traits and implementations, including a cached certifier with TTL and version rollback protection.
File summaries
| File | Description |
|---|---|
| mithril-stm/src/protocol/aggregate_signature/signature.rs | Adds requires_certified_circuit_verification_keys() plus a golden test pinning semantics per aggregate signature type. |
| mithril-stm/src/protocol/aggregate_signature/ancillary_data.rs | Exposes stable-order circuit VK digests from ancillary verifier data and tests the ordering/consistency. |
| mithril-stm/src/lib.rs | Re-exports circuit VK digest types/constants behind future_snark. |
| mithril-stm/src/circuits/verification_key_digest.rs | New digest type + serde/hex round-trips and golden tests pinning digests. |
| mithril-stm/src/circuits/mod.rs | Wires the new digest module and re-exports it from circuits. |
| mithril-common/src/test/double/mod.rs | Adds a future_snark-gated test double module export for registry retrieval. |
| mithril-common/src/test/double/circuit_key_registry_retriever.rs | Implements a fake registry retriever for tests. |
| mithril-common/src/crypto_helper/mod.rs | Adds future_snark-gated circuit key registry module wiring and re-exports. |
| mithril-common/src/crypto_helper/circuit_key_registry/retriever.rs | Adds retriever trait + file-based implementation + tests. |
| mithril-common/src/crypto_helper/circuit_key_registry/registry.rs | Implements registry data model, check semantics (revocation wins), and signed raw-JSON container with signature verification. |
| mithril-common/src/crypto_helper/circuit_key_registry/mod.rs | New module root re-exporting registry/retriever/certifier pieces. |
| mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs | Adds certifier trait, Mithril certifier implementation, and cached certifier (TTL + rollback protection) with tests. |
| mithril-common/Cargo.toml | Enables serde_json raw_value feature needed to preserve exact signed JSON bytes. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
d971416 to
36ef087
Compare
36ef087 to
d71b4d5
Compare
hjeljeli32
left a comment
There was a problem hiding this comment.
Looks good but I left a couple of suggestions.
d71b4d5 to
6aa6ed4
Compare
6aa6ed4 to
b3586ac
Compare
b3586ac to
475496e
Compare
Add 'requires_certified_circuit_verification_keys' on AggregateSignatureType, true for the SNARK proof systems and false for concatenation.
…ifier data Add CircuitVerificationKeyDigest (Poseidon hash of the canonical key bytes, hex-serialized) and a digests accessor covering both SNARK variants.
Add the genesis-signed registry (whitelist entries with epoch ranges and revocation-wins semantics) under crypto_helper/circuit_key_registry.
Add the retriever trait returning the unverified signed registry, a file based implementation and a fake test double.
Lazily retrieve the signed registry, verify its genesis signature, network and minimum version, cache it, then check digests fail-closed.
… Poseidon The Poseidon hasher must absorb field elements, so the canonical key bytes are pre-hashed with SHA-256 as elsewhere in the crate.
…n keys The serialized key bytes omit the recursive circuit constraint system, so the digest covers the transcript representation that binds the gates.
Prepend a dedicated Poseidon domain separation tag (CVKD_DST) to the transcript representation, following the existing tag convention.
…oof tests Use the aggregate signature accessor instead, which also compiles cleanly without the future_snark feature.
The registry check collects all rejections with their reason in a single error variant instead of stopping at the first rejected digest.
* mithril-common from `0.7.20` to `0.7.21` * mithril-stm from `0.12.15` to `0.12.16`
475496e to
4330db7
Compare
Content
This PR includes the machinery of the genesis signed circuit verification key registry, a whitelist with epoch ranges and retroactive revocations for the circuit verification keys trusted by SNARK certificates:
CircuitVerificationKeyDigest(Poseidon hash of the transcript representation bytes) and arequires_certified_circuit_verification_keyspredicate onAggregateSignatureTypeinmithril-stm, with golden tests pinning the digestsmithril-common, signed over the exact registry JSON bytes with a domain-separation prefix so the schema stays evolvable after publicationPre-submit checklist
Comments
The enforcement in the certificate verifier, the client and the aggregator, along with the genesis tooling and the runbook, comes in a follow-up PR #3514 stacked on this one.
Issue(s)
Relates to #3148