-
Notifications
You must be signed in to change notification settings - Fork 52
SNARK-friendly STM: Revise Generic Digest to support multiple hash functions #2864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
77f84dd to
ad8b276
Compare
44997fc to
bb072df
Compare
There was a problem hiding this comment.
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 introduces a generic MembershipDigest trait to abstract hash function usage in the SNARK-friendly STM protocol, replacing direct dependencies on Blake2 hash types throughout the codebase. This enables support for multiple hash function implementations while maintaining backward compatibility.
Key Changes
- Introduces
MembershipDigesttrait withConcatenationHashandSnarkHashassociated types - Provides
CustomMembershipDigestas a default Blake2-based implementation - Updates all STM protocol structs and functions to use the new trait abstraction instead of concrete Blake2 types
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/membership_commitment/mod.rs | Defines the core MembershipDigest trait and CustomMembershipDigest implementation |
| mithril-stm/src/lib.rs | Exports new trait and implementation to public API |
| mithril-stm/src/protocol/key_registration.rs | Updates ClosedKeyRegistration to use MembershipDigest with associated type for merkle tree |
| mithril-stm/src/protocol/single_signature/*.rs | Replaces Digest + FixedOutput bounds with MembershipDigest in signature operations |
| mithril-stm/src/protocol/participant/*.rs | Updates Signer and Initializer to use new trait abstraction |
| mithril-stm/src/protocol/aggregate_signature/*.rs | Updates aggregation components (Clerk, AggregateSignature, etc.) to use trait |
| mithril-stm/src/proof_system/concatenation.rs | Updates ConcatenationProof to use MembershipDigest::ConcatenationHash |
| mithril-stm/tests/*.rs | Updates tests to use CustomMembershipDigest instead of direct Blake2 types |
| mithril-stm/examples/key_registration.rs | Defines local CustomMembershipDigest for example usage |
| mithril-stm/benches/*.rs | Updates benchmarks to use new abstraction |
| mithril-stm/README.md | Updates example code to use CustomMembershipDigest |
| mithril-common/src/crypto_helper/*.rs | Updates to import and use CustomMembershipDigest from mithril-stm |
| demo/protocol-demo/src/types.rs | Updates to import and use CustomMembershipDigest |
| demo/protocol-demo/Cargo.toml | Removes direct blake2 dependency (now transitively available) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bb072df to
f8d37d7
Compare
| #[cfg(feature = "future_snark")] | ||
| type SnarkHash = Blake2b<U64>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to mention that this Blake2b<U34> will be replaced by Poseidon when implementing the SNARK primitives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a comment about it in the doc of impl (line 162).
Should we add one more on top of type SnarkHash = Blake2b<U64>;?
mithril-stm/src/signature_scheme/schnorr_signature/signature.rs
Outdated
Show resolved
Hide resolved
jpraynaud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Content
This PR includes the changes required to support multiple hash functions for different proof systems.
Pre-submit checklist
Comments
Issue(s)
Relates to #2794