Skip to content

feat: add the circuit verification key registry crate and tools - #3541

Open
jpraynaud wants to merge 7 commits into
mainfrom
jpraynaud/3148-prepare-circuit-key-registry
Open

jpraynaud wants to merge 7 commits into
mainfrom
jpraynaud/3148-prepare-circuit-key-registry

Conversation

@jpraynaud

@jpraynaud jpraynaud commented Sep 15, 2026

Copy link
Copy Markdown
Member

Content

This PR includes the circuit verification key registry crate and the tools to manage a registry, prepared for its enforcement in #3514:

  • Move the circuit verification key registry introduced in feat: introduce the circuit verification key registry #3513 to its own mithril-circuit-key-registry internal crate, behind its future_snark feature (registry format, certifiers and retrievers), mithril-common keeping only the CircuitVerificationKeyCertifier trait used by the certificate verifier
  • Remove the compiled minimum registry version: the genesis signature and the cached certifier cover the registry, a compiled floor would need a release per publication
  • Keep a single entry per circuit verification key digest, either allowed over an epoch range or revoked, a revoked key being rejected for every epoch
  • Add an HTTP retriever of the signed registry with a bounded downloader (timeout, retries and size cap)
  • Keep the last verified registry in memory when a refresh fails or would lower the registry version, so an outage of the registry source does not stop a running node
  • Add the circuit-key-registry command to the aggregator: export the circuit key digests for the network protocol parameters, whitelist a key (creating the registry of a Mithril network when missing), revoke an allowed key with its revocation epoch and comment, sign a hand-authored registry, and the test-only bootstrap, the registry being updated in place and genesis-signed
  • Document the command in the aggregator CLI documentation.

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

Issue(s)

Relates to #3148

@jpraynaud
jpraynaud force-pushed the jpraynaud/3148-prepare-circuit-key-registry branch from e9cb2a8 to a285ecf Compare September 15, 2026 10:27
@jpraynaud
jpraynaud requested a lite review from Copilot September 15, 2026 10:28
@jpraynaud
jpraynaud added this pull request to stack #3542 September 15, 2026 10:31

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

Critical and moderate unresolved findings remain in the downloader, registry validation, and aggregator tooling.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a feature-gated circuit verification key registry crate with retrieval, caching, signing, and aggregator management tools.

Changes:

  • Extracts registry types, certifiers, retrievers, and bounded HTTP downloading.
  • Adds aggregator export, whitelist, revoke, sign, and bootstrap commands.
  • Updates documentation, workspace metadata, tests, and CI/release workflows.
File summaries
File Reviewed changes
README.md Documents the new crate.
mithril-common/src/test/double/mod.rs Removes the moved retriever double.
mithril-common/src/crypto_helper/mod.rs Re-exports circuit digest types.
mithril-common/src/crypto_helper/circuit_key_registry/mod.rs Removes the legacy registry module.
mithril-common/src/certificate_chain/mod.rs Exposes the certifier trait.
mithril-common/src/certificate_chain/circuit_verification_key_certifier.rs Defines the certifier interface.
mithril-aggregator/src/tools/mod.rs Registers registry tools.
mithril-aggregator/src/tools/circuit_key_registry.rs Implements registry operations. L203: Moderate, 3 votes — guard maximum-version increment overflow. L328: Moderate, 2 votes — apply inverted-range validation only to allowed entries.
mithril-aggregator/src/commands/mod.rs Registers the registry command.
mithril-aggregator/src/commands/circuit_key_registry_command.rs Implements CLI subcommands.
mithril-aggregator/Cargo.toml Adds feature-gated crate wiring.
Makefile Includes the new component.
internal/mithril-circuit-key-registry/src/test/mod.rs Adds test utilities.
internal/mithril-circuit-key-registry/src/test/double/mod.rs Exposes retriever test doubles.
internal/mithril-circuit-key-registry/src/test/double/circuit_key_registry_retriever.rs L7: Nit, 1 vote — add the standard Dummy implementation.
internal/mithril-circuit-key-registry/src/retriever.rs Adds file, HTTP, and unconfigured retrievers.
internal/mithril-circuit-key-registry/src/registry.rs Defines registry format and verification. L161: Critical, 3 votes — validate duplicate digests or ensure revocation wins.
internal/mithril-circuit-key-registry/src/lib.rs Defines crate modules and exports.
internal/mithril-circuit-key-registry/src/http_downloader.rs Adds bounded HTTP downloading and retries. L83: Critical, 3 votes — stream bodies incrementally to enforce the size cap. L33: Moderate, 2 votes — propagate client construction errors instead of falling back to a client without the timeout.
internal/mithril-circuit-key-registry/src/certifier.rs Adds verification and caching.
internal/mithril-circuit-key-registry/README.md Documents the crate.
internal/mithril-circuit-key-registry/Makefile Adds crate build and test targets.
internal/mithril-circuit-key-registry/Cargo.toml Defines crate metadata and features.
docs/website/root/manual/develop/nodes/mithril-aggregator.md Documents the CLI commands.
Cargo.toml Adds the crate to the workspace.
Cargo.lock Locks new dependencies.
.github/workflows/test-rust.yml Tests the new crate.
.github/workflows/release.yml Publishes the crate.
.github/workflows/pre-release.yml Includes pre-release publishing.
.github/workflows/nightly-dispatcher.yml Includes nightly publishing.
.github/workflows/manual-publish-crates.yml Adds manual publication support.
.github/workflows/ci.yml Updates publication and documentation coverage.
Review details

Suppressed comments (2)

internal/mithril-circuit-key-registry/src/registry.rs:165

  • This first-match lookup silently ignores later entries with the same digest. The single-entry invariant is checked only by the aggregator tools, while SignedCircuitVerificationKeyRegistry::verify accepts a signed document with duplicates; an allowed first entry followed by a revoked entry would therefore certify the revoked key. Validate uniqueness when parsing/verifying, or retain revocation-wins behavior for malformed duplicates.
    internal/mithril-circuit-key-registry/src/test/double/circuit_key_registry_retriever.rs:10
  • The moved public fake remains a test double without implementing mithril_common::test::double::Dummy, contrary to the repository's dummy test-double guideline. Add a Dummy implementation next to the type so shared tests can construct it through the standard test-double API.
  • Files reviewed: 31/32 changed files
  • Comments generated: 4
  • 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 internal/mithril-circuit-key-registry/src/http_downloader.rs Outdated
Comment thread internal/mithril-circuit-key-registry/src/http_downloader.rs Outdated
Comment thread mithril-aggregator/src/tools/circuit_key_registry.rs Outdated
Comment thread mithril-aggregator/src/tools/circuit_key_registry.rs Outdated
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

Test Results

     5 files  ± 0     222 suites  +1   59m 41s ⏱️ + 29m 29s
 3 672 tests +45   3 672 ✅ +45  0 💤 ±0  0 ❌ ±0 
11 806 runs  +39  11 806 ✅ +39  0 💤 ±0  0 ❌ ±0 

Results for commit e00d62b. ± Comparison against base commit 928b3f6.

This pull request removes 29 and adds 74 tests. Note that renamed tests count towards both.
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::cached_certifier::a_cache_refreshed_in_the_future_is_stale
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::cached_certifier::check_fails_closed_when_the_refresh_fails
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::cached_certifier::check_refreshes_the_registry_after_the_cache_time_to_live_expires
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::cached_certifier::check_rejects_a_refreshed_registry_with_a_lower_version
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::cached_certifier::check_retrieves_and_verifies_the_registry_only_once_within_the_time_to_live
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::mithril_certifier::check_fails_closed_when_retrieval_fails
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::mithril_certifier::check_propagates_registry_check_errors
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::mithril_certifier::check_rejects_a_registry_signed_by_another_genesis_key
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::mithril_certifier::check_rejects_a_registry_version_below_the_minimum
mithril-common ‑ crypto_helper::circuit_key_registry::certifier::tests::mithril_certifier::check_retrieves_and_verifies_the_registry_at_every_use
…
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::appends_the_entry_and_increments_the_version_of_an_existing_registry
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::creates_a_signed_registry_at_the_initial_version_when_missing
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::fails_on_a_digest_already_listed
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::fails_on_a_registry_version_that_cannot_be_incremented
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::fails_on_an_entry_with_an_inverted_epoch_range
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::fails_on_an_existing_registry_signed_by_another_genesis_key
mithril-aggregator ‑ tools::circuit_key_registry::tests::add_entry::preserves_the_fields_of_a_future_registry_schema
mithril-aggregator ‑ tools::circuit_key_registry::tests::bootstrap::bootstraps_a_verifiable_registry_whitelisting_the_production_circuit_keys_without_protocol_parameters
mithril-aggregator ‑ tools::circuit_key_registry::tests::bootstrap::entries_allow_each_distinct_certificate_circuit_key_then_the_ivc_circuit_key
mithril-aggregator ‑ tools::circuit_key_registry::tests::expire::expires_an_allowed_key_in_place_and_increments_the_version
…

♻️ This comment has been updated with latest results.

@jpraynaud
jpraynaud deployed to testing-2-preview September 15, 2026 10:46 — with GitHub Actions Active
@jpraynaud
jpraynaud deployed to testing-preview September 15, 2026 10:46 — with GitHub Actions Active
@jpraynaud jpraynaud self-assigned this Sep 15, 2026
@jpraynaud
jpraynaud force-pushed the jpraynaud/3148-prepare-circuit-key-registry branch from a285ecf to bceb3fd Compare September 15, 2026 13:23
@jpraynaud
jpraynaud marked this pull request as ready for review September 15, 2026 13:25
@jpraynaud
jpraynaud force-pushed the jpraynaud/3148-prepare-circuit-key-registry branch from bceb3fd to 5fd7281 Compare September 15, 2026 13:48
The crate holds the registry format, certifiers and retrievers, mithril-common keeps
only the certifier trait used by the certificate verifier.
The genesis signature and the version rollback rejection of the cached certifier
already cover the registry, a compiled floor would need a release per publication.
…verification key

A revoked circuit verification key is rejected for every epoch, so the epoch
a certificate claims cannot bypass a revocation.
The retriever downloads the signed registry from a URL with a bounded downloader,
so a node refreshes the registry itself.
… older refresh

A failed refresh, or one yielding a lower registry version, no longer fails the
check: the previously verified registry is kept until the next refresh.
Export the circuit key digests, whitelist or revoke a key with a genesis
signed registry update, sign a registry and bootstrap one for tests.
Generated with the hidden documentation subcommand of the aggregator.
@jpraynaud
jpraynaud force-pushed the jpraynaud/3148-prepare-circuit-key-registry branch from 5fd7281 to e00d62b Compare September 15, 2026 15:44
@jpraynaud
jpraynaud deployed to testing-2-preview September 15, 2026 16:03 — with GitHub Actions Active
@jpraynaud
jpraynaud deployed to testing-preview September 15, 2026 16:03 — with GitHub Actions Active
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.

2 participants