feat: SNARK-friendly protocol message#3254
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a SNARK-friendly (“rigid”) variant of ProtocolMessage hashing to support opening the protocol-message hash inside the IVC circuit, while preserving byte-identical legacy hashing/serialization for pre-Lagrange certificates. Activation is era-driven (Pythagoras → Legacy, Lagrange → Rigid) and rigid-specific behavior is gated behind the future_snark feature.
Changes:
- Add
ProtocolMessageHashScheme(Legacydefault,Rigid) and implement rigid labeled-preimage hashing + integrity checks (feature-gated). - Add rigid-slot encodings for SNARK AVK (44 bytes) and protocol parameters (32 bytes) with stability tests.
- Make
SignableBuilderServiceera-aware: enforce SNARK AVK presence + rigid integrity in Lagrange; add verifier tests covering rigid dispatch and era transition.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/protocol/parameters.rs | Adds a 32-byte rigid-slot encoding for protocol parameters (feature-gated) + golden tests. |
| mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs | Adds a 44-byte rigid-slot projection for SNARK AVK + golden test. |
| mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs | Adds era discovery (compute_current_era) for Lagrange/Pythagoras dispatch (feature-gated). |
| mithril-signer/src/services/signable_builder/signable_seed_builder.rs | Adds era discovery (compute_current_era) for Lagrange/Pythagoras dispatch (feature-gated). |
| mithril-common/src/signable_builder/interface.rs | Extends SignableSeedBuilder with compute_current_era under future_snark. |
| mithril-common/src/signable_builder/signable_builder_service.rs | Era-aware selection of rigid hashing in Lagrange + rigid integrity check before returning the message. |
| mithril-common/src/entities/protocol_message.rs | Implements ProtocolMessageHashScheme, rigid preimage assembly/hashing, and rigid integrity validation (feature-gated). |
| mithril-common/src/entities/mod.rs | Updates entities re-exports to include new protocol-message types. |
| mithril-common/src/certificate_chain/certificate_verifier.rs | Adds tests ensuring verifier logic accepts rigid protocol messages and era-transition chaining behavior. |
Test Results 5 files ± 0 203 suites ±0 1h 1m 23s ⏱️ - 3h 37m 12s Results for commit 781f2ef. ± Comparison against base commit e0ad33f. This pull request removes 54 and adds 57 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
645abc6 to
825856e
Compare
8ba311f to
3c015d2
Compare
|
Hi @curiecrypt @hjeljeli32 @damrobi could you review the cryptographic part?
|
hjeljeli32
left a comment
There was a problem hiding this comment.
LGTM 👍 . I just left one comment about the behavior of rigid_preimage function.
And become SNARK-friendly so that its hash can be opened in the IVC circuit.
…grange era transition Cover concatenation AVK, SNARK AVK, protocol parameters, epoch and previous-hash chaining when the predecessor uses the legacy hash scheme (Pythagoras) and the successor uses the rigid hash scheme (Lagrange).
…EraFetcher' trait Instead of having 'SignableSeedBuilder' trait supporting it.
* mithril-era from `0.1.8` to `0.1.9` * mithril-aggregator from `0.8.50` to `0.8.51` * mithril-common from `0.6.71` to `0.6.72` * mithril-signer from `1.0.0` to `1.0.1` * mithril-stm from `0.10.16` to `0.10.17`
3c015d2 to
781f2ef
Compare
Content
This PR includes a SNARK-friendly variant of the
ProtocolMessageso its hash can be opened in the IVC circuit, while keeping the legacy hash scheme byte-identical for backward compatibility:ProtocolMessageHashScheme(Legacy,Rigid) onProtocolMessage.Legacystays the default and serializes without the field (pre-Lagrange wire shape preserved).Rigidscheme assembles a fixed-size labeled preimage:digest || next_aggregate_verification_key || next_protocol_parameters || current_epoch(190 bytes total).SignableBuilderServicebecomes era-aware:PythagoraskeepsLegacy,Lagrangeflips toRigidand runscheck_rigid_integritybefore signing.future_snarkfeature.Pre-submit checklist
Comments
One new TODO is intentional:
to_rigid_slot_byteswrites 4 zero bytes between the Merkle root andtotal_staketo mirror the IVC test fixture's leaf-count slot.Issue(s)
Closes #3146