Skip to content

feat: introduce the circuit verification key registry - #3513

Open
jpraynaud wants to merge 5 commits into
mainfrom
jpraynaud/3148-introduce-circuit-key-registry
Open

feat: introduce the circuit verification key registry#3513
jpraynaud wants to merge 5 commits into
mainfrom
jpraynaud/3148-introduce-circuit-key-registry

Conversation

@jpraynaud

@jpraynaud jpraynaud commented Sep 2, 2026

Copy link
Copy Markdown
Member

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:

  • Add CircuitVerificationKeyDigest (Poseidon hash of the canonical verification key bytes) and a requires_certified_circuit_verification_keys predicate on AggregateSignatureType in mithril-stm, with golden tests pinning the digests
  • Add the registry types with revocation check semantics in mithril-common, signed over the exact registry JSON bytes with a domain-separation prefix so the schema stays evolvable after publication
  • Add the registry retriever trait with a file implementation and test doubles
  • Add the certifier trait with a caching decorator

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

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 stacked on this one.

Issue(s)

Relates to #3148

Add 'requires_certified_circuit_verification_keys' on AggregateSignatureType,
true for the SNARK proof systems and false for concatenation.
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs Fixed
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs Fixed
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs Fixed
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs Fixed
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs Fixed
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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) in mithril-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.

Comment thread mithril-common/src/crypto_helper/circuit_key_registry/certifier.rs
Comment thread mithril-common/src/crypto_helper/circuit_key_registry/retriever.rs Outdated
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Results

     5 files  ± 0     221 suites  ±0   33m 57s ⏱️ - 25m 27s
 3 536 tests +40   3 536 ✅ +40  0 💤 ±0  0 ❌ ±0 
11 626 runs  +49  11 626 ✅ +49  0 💤 ±0  0 ❌ ±0 

Results for commit d71b4d5. ± Comparison against base commit e07de33.

♻️ This comment has been updated with latest results.

@jpraynaud
jpraynaud force-pushed the jpraynaud/3148-introduce-circuit-key-registry branch 2 times, most recently from d971416 to 36ef087 Compare September 2, 2026 13:55
@jpraynaud
jpraynaud deployed to testing-preview September 2, 2026 14:19 — with GitHub Actions Active
@jpraynaud
jpraynaud deployed to testing-2-preview September 2, 2026 14:19 — with GitHub Actions Active
…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.
@jpraynaud
jpraynaud force-pushed the jpraynaud/3148-introduce-circuit-key-registry branch from 36ef087 to d71b4d5 Compare September 2, 2026 14:33
@jpraynaud
jpraynaud marked this pull request as ready for review September 2, 2026 14:36
@jpraynaud
jpraynaud deployed to testing-preview September 2, 2026 14:56 — with GitHub Actions Active
@jpraynaud
jpraynaud deployed to testing-2-preview September 2, 2026 14:56 — with GitHub Actions Active
/// revoked entry covers the epoch, and with
/// [NotWhitelisted](CircuitVerificationKeyRegistryError::NotWhitelisted) when no allowed
/// entry covers it.
pub fn check(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only return the first digest that is not allowed. Could it be interesting to get the list of all rejected digests that fails?

@damrobi damrobi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants