Skip to content

Conversation

@curiecrypt
Copy link
Collaborator

@curiecrypt curiecrypt commented Dec 16, 2025

Content

This PR includes the changes required to support multiple hash functions for different proof systems.

Pre-submit checklist

  • Branch
    • 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

Comments

Issue(s)

Relates to #2794

@curiecrypt curiecrypt force-pushed the curiecrypt/msnark/revise-digest-generic branch from 77f84dd to ad8b276 Compare December 16, 2025 18:47
@github-actions
Copy link

github-actions bot commented Dec 16, 2025

Test Results

    4 files  ±0    169 suites  ±0   22m 15s ⏱️ - 2m 4s
2 275 tests ±0  2 275 ✅ ±0  0 💤 ±0  0 ❌ ±0 
7 136 runs  ±0  7 136 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit fad50b2. ± Comparison against base commit ecad03d.

♻️ This comment has been updated with latest results.

Copy link

Copilot AI left a 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 MembershipDigest trait with ConcatenationHash and SnarkHash associated types
  • Provides CustomMembershipDigest as 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.

@curiecrypt curiecrypt force-pushed the curiecrypt/msnark/revise-digest-generic branch from bb072df to f8d37d7 Compare December 17, 2025 16:43
@curiecrypt curiecrypt marked this pull request as ready for review December 17, 2025 16:53
Comment on lines +166 to +167
#[cfg(feature = "future_snark")]
type SnarkHash = Blake2b<U64>;
Copy link
Member

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?

Copy link
Collaborator Author

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>;?

Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link

Copilot AI left a 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.

@curiecrypt curiecrypt deployed to testing-preview December 17, 2025 19:23 — 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.

3 participants