Skip to content

feat: SNARK-friendly certificate chain - #3073

Merged
jpraynaud merged 19 commits into
mainfrom
jpraynaud/2811-snark-friendly-certificate-chain
Mar 16, 2026
Merged

feat: SNARK-friendly certificate chain#3073
jpraynaud merged 19 commits into
mainfrom
jpraynaud/2811-snark-friendly-certificate-chain

Conversation

@jpraynaud

@jpraynaud jpraynaud commented Mar 6, 2026

Copy link
Copy Markdown
Member

Content

This PR includes the implementation of the SNARK support for the aggregate verification key across the full certificate chain:

  • mithril-stm: SnarkClerk for computing SNARK AVK from closed key registration, AggregateVerificationKeyForSnark wrapper type, and extension of AggregateVerificationKey<D> to carry both concatenation and SNARK AVKs
  • mithril-common: ProtocolAggregateVerificationKeyForSnark type alias with bytes_hex_codec, NextSnarkAggregateVerificationKey protocol message part key (ungated for deserialization compatibility), SNARK AVK field on Certificate and MithrilCertificateMessage, unified AVK chaining verification dispatching by signature type, genesis protocol message enrichment, and signable builder / test infrastructure extensions
  • mithril-aggregator: database migration adding aggregate_verification_key_snark column, CertificateRecord persistence, era-gated SNARK AVK stripping in certifier service (Pythagoras strips, Lagrange requires), seed builder with era-aware SNARK AVK computation, and genesis tooling updates
  • mithril-signer: Era-gated SNARK AVK computation in seed builder and epoch service, single signer and dependency injection wiring
  • mithril-client / mithril-client-cli: future_snark feature propagation, SNARK AVK verification in message builder when present in protocol message, and test struct literal updates

Cases support

# Era Signature type Previous certificate Same epoch Result
1 Pythagoras Concatenation Old genesis No OK
2 Pythagoras Concatenation New genesis No OK
3 Pythagoras Concatenation Standard, Pythagoras Yes OK
4 Pythagoras Concatenation Standard, Pythagoras No OK
5 Pythagoras SNARK Any Any Impossible
6 Lagrange Concatenation Old genesis No OK
7 Lagrange Concatenation New genesis No OK
8 Lagrange Concatenation Standard, Pythagoras No OK
9 Lagrange Concatenation Standard, Lagrange Yes OK
10 Lagrange Concatenation Standard, Lagrange No OK
11 Lagrange SNARK Old genesis Any Impossible
12 Lagrange SNARK Standard, Pythagoras Any Impossible
13 Lagrange SNARK New genesis No OK
14 Lagrange SNARK Standard, Lagrange Yes OK
15 Lagrange SNARK Standard, Lagrange No OK
16 Lagrange SNARK Standard, Lagrange Yes OK
17 Lagrange SNARK Standard, Lagrange Yes OK
18 Lagrange SNARK Standard, Lagrange Yes OK

Distributions backward compatibility

With future_snark

Compatibility mithril-signer mithril-aggregator mithril-client
2603.1 ✔️ ✔️ ✔️
2543.1-hotfix ✔️ ⚠️ ✔️
2543.0 ✔️ ⚠️ ✔️
2537.0 ✔️ ⚠️ ✔️
2524.0 ✔️ ⚠️ ✔️

Without future_snark

Compatibility mithril-signer mithril-aggregator mithril-client
2603.1 ✔️ ✔️ ✔️
2543.1-hotfix ✔️ ⚠️ ✔️
2543.0 ✔️ ⚠️ ✔️
2537.0 ✔️ ⚠️ ✔️
2524.0 ✔️ ⚠️ ✔️

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
  • Documentation
    • No new TODOs introduced

Issue(s)

Closes #2811

@jpraynaud jpraynaud self-assigned this Mar 6, 2026
@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown

Test Results

    5 files  ± 0    190 suites  ±0   1h 6m 38s ⏱️ + 8m 34s
2 718 tests +41  2 718 ✅ +41  0 💤 ±0  0 ❌ ±0 
9 642 runs  +51  9 642 ✅ +51  0 💤 ±0  0 ❌ ±0 

Results for commit 4949549. ± Comparison against base commit ceb0c72.

This pull request removes 1 and adds 42 tests. Note that renamed tests count towards both.
mithril-common ‑ certificate_chain::certificate_genesis::tests::test_create_genesis_protocol_message_has_expected_keys_and_values
mithril-aggregator ‑ commands::genesis_command::tests::resolve_mithril_era_returns_error_when_multiple_eras_and_none_provided
mithril-aggregator ‑ commands::genesis_command::tests::resolve_mithril_era_returns_provided_era
mithril-aggregator ‑ database::record::certificate::tests::snark_aggregate_verification_key::certificate_message_preserves_snark_aggregate_verification_key
mithril-aggregator ‑ database::record::certificate::tests::snark_aggregate_verification_key::certificate_to_record_preserves_snark_aggregate_verification_key
mithril-aggregator ‑ database::record::certificate::tests::snark_aggregate_verification_key::certificate_to_record_roundtrip_with_none_snark_aggregate_verification_key
mithril-aggregator ‑ database::record::certificate::tests::snark_aggregate_verification_key::record_to_certificate_preserves_snark_aggregate_verification_key
mithril-aggregator ‑ database::repository::certificate_repository::tests::test_golden_master_with_snark_aggregate_verification_key
mithril-aggregator ‑ services::signable_builder::signable_seed_builder::tests::compute_next_snark_avk_returns_none_during_pythagoras_era
mithril-aggregator ‑ services::signable_builder::signable_seed_builder::tests::compute_next_snark_avk_returns_value_during_lagrange_era
mithril-common ‑ certificate_chain::certificate_genesis::tests::genesis_protocol_message_has_expected_keys_and_values
…

♻️ This comment has been updated with latest results.

@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch 2 times, most recently from a596cd6 to b3610e9 Compare March 9, 2026 18:35
@jpraynaud
jpraynaud requested a review from Copilot March 9, 2026 18:35

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.

Pull request overview

This PR implements SNARK support for the aggregate verification key (AVK) across the full Mithril certificate chain (#2811). It introduces a new SnarkClerk, AggregateVerificationKeyForSnark, and a new NextSnarkAggregateVerificationKey protocol message part key, then integrates these end-to-end from key registration through aggregator/signer/client logic, with Pythagoras/Lagrange era-gating at every level.

Changes:

  • mithril-stm: New SnarkClerk for computing SNARK AVK from key registration; AggregateVerificationKeyForSnark gains total_stake/target_value fields, custom PartialEq, and byte serialization; Clerk updated to hold an optional SnarkClerk.
  • mithril-common / mithril-aggregator / mithril-signer: ProtocolAggregateVerificationKeyForSnark type alias; NextSnarkAggregateVerificationKey protocol message part key; Certificate and CertificateMessage gain the SNARK AVK field; verifier adds SNARK AVK chaining logic dispatched by AggregateSignatureType; database migration 41 adds the aggregate_verification_key_snark column; EpochService gains mithril_era().
  • mithril-client / mithril-client-cli: future_snark feature flag propagation; message builder computes SNARK AVK when the protocol message contains the SNARK AVK part key.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
mithril-stm/src/proof_system/halo2_snark/clerk.rs New SnarkClerk for SNARK AVK computation
mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs AggregateVerificationKeyForSnark extended with stake/target fields and byte serialization
mithril-stm/src/protocol/aggregate_signature/clerk.rs Clerk holds optional SnarkClerk and uses it for AVK
mithril-stm/src/proof_system/mod.rs Exports AggregateVerificationKeyForSnark (feature-gated) and SnarkClerk
mithril-common/src/entities/protocol_message.rs New NextSnarkAggregateVerificationKey enum variant
mithril-common/src/entities/certificate.rs Adds SNARK AVK field, strip_snark_aggregate_verification_key, and CertificateSignature::aggregate_signature_type()
mithril-common/src/messages/certificate.rs Adds SNARK AVK field to the message DTO
mithril-common/src/certificate_chain/certificate_verifier.rs Dispatches AVK chaining verification by signature type; new SNARK-specific chaining method
mithril-common/src/certificate_chain/certificate_genesis.rs Genesis message enriched with SNARK AVK
mithril-common/src/crypto_helper/types/wrappers.rs Adds ProtocolAggregateVerificationKeyForSnark type alias; changes VerificationKeyForSnark from bytes_hex_codec to json_hex_codec
mithril-common/src/signable_builder/interface.rs SignableSeedBuilder trait gains compute_next_aggregate_verification_key_for_snark
mithril-aggregator/src/services/certifier/certifier_service.rs Strips SNARK AVK during Pythagoras era
mithril-aggregator/src/database/migration.rs Migration 41 adds aggregate_verification_key_snark column
mithril-aggregator/src/database/record/certificate.rs CertificateRecord persistence of SNARK AVK
mithril-signer/src/services/epoch_service.rs Adds era_checker dependency and mithril_era() to epoch service
mithril-client/src/message.rs Computes and includes SNARK AVK in protocol message when needed
mithril-client/Cargo.toml / mithril-client-cli/Cargo.toml future_snark feature propagation

Comment thread mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs
Comment thread mithril-stm/src/proof_system/halo2_snark/clerk.rs
Comment thread mithril-common/src/crypto_helper/types/wrappers.rs
Comment thread mithril-common/src/certificate_chain/certificate_verifier.rs Outdated
Comment thread mithril-common/src/entities/certificate.rs Outdated
Comment thread mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs Outdated
Comment thread mithril-common/src/certificate_chain/certificate_verifier.rs Outdated
Comment thread mithril-common/src/certificate_chain/certificate_verifier.rs Outdated
Comment thread mithril-common/src/crypto_helper/types/wrappers.rs
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 9, 2026 18:49 — with GitHub Actions Inactive
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from b3610e9 to cf99c75 Compare March 10, 2026 16:36
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 10, 2026 16:51 — with GitHub Actions Inactive
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from 476c0ef to 6c53d3a Compare March 10, 2026 18:33
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 10, 2026 19:42 — with GitHub Actions Inactive
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch 2 times, most recently from 545f1bc to 217984d Compare March 11, 2026 16:10
@jpraynaud
jpraynaud marked this pull request as ready for review March 11, 2026 16:27
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 11, 2026 16:31 — with GitHub Actions Inactive
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from 217984d to 9d08dd0 Compare March 12, 2026 14:49

@curiecrypt curiecrypt 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 👍

@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from 9d08dd0 to 9e07bd1 Compare March 12, 2026 18:19
When a previous client tries to verify a certificate with a
Concatenation proof which has been created with a new aggregator
compiled with 'future_snark', it can't parse it because it embeds
a 'ClosedKeyRegistrationEntry' which has a rigid serde deserialization
based on array representation (receives an array of length 4 when expecting 2).
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from bdde290 to 2e4c153 Compare March 12, 2026 20:01
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 12, 2026 20:20 — with GitHub Actions Inactive
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 12, 2026 21:06 — with GitHub Actions Inactive

@Alenar Alenar 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, mostly nitpick comments

Comment thread mithril-aggregator/src/database/record/certificate.rs Outdated
Comment thread mithril-aggregator/src/database/record/certificate.rs Outdated
Comment thread mithril-client/Cargo.toml
Comment thread mithril-common/src/crypto_helper/types/wrappers.rs Outdated
Comment thread mithril-common/src/certificate_chain/certificate_genesis.rs Outdated
Comment thread mithril-stm/src/proof_system/concatenation/clerk.rs Outdated
Comment thread mithril-stm/src/proof_system/concatenation/proof.rs Outdated
Comment thread mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs
Comment thread mithril-stm/src/proof_system/halo2_snark/eligibility.rs
Comment thread mithril-test-lab/mithril-end-to-end/backward-compatibility.md Outdated
Comment thread mithril-test-lab/mithril-end-to-end/src/mithril/aggregator.rs Outdated
Comment thread mithril-aggregator/src/tools/genesis.rs Outdated
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from 8b10e7d to 14c19e5 Compare March 13, 2026 18:41
* mithril-aggregator from `0.8.33` to `0.8.34`
* mithril-client-cli from `0.12.42` to `0.12.43`
* mithril-client from `0.13.4` to `0.13.5`
* mithril-common from `0.6.55` to `0.6.56`
* mithril-signer from `0.3.22` to `0.3.23`
* mithril-stm from `0.9.28` to `0.9.29`
* mithril-end-to-end from `0.4.121` to `0.4.122`
@jpraynaud
jpraynaud force-pushed the jpraynaud/2811-snark-friendly-certificate-chain branch from 14c19e5 to 4949549 Compare March 15, 2026 20:16
@jpraynaud
jpraynaud temporarily deployed to testing-preview March 15, 2026 20:34 — with GitHub Actions Inactive

@turmelclem turmelclem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@jpraynaud
jpraynaud merged commit e40622c into main Mar 16, 2026
59 checks passed
@jpraynaud
jpraynaud deleted the jpraynaud/2811-snark-friendly-certificate-chain branch March 16, 2026 09:02
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.

Adapt certificate chain to support SNARK AVK

6 participants