-
Notifications
You must be signed in to change notification settings - Fork 52
SNARK-friendly STM: Re-organize modules #2804
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
1ec9ee5 to
1673005
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 reorganizes the mithril-stm library's module structure in preparation for SNARK integration. The refactoring consolidates code into four main modules: signature_scheme (for BLS and Schnorr signatures), protocol (for STM protocol logic), membership_commitment (for Merkle trees), and proof_system (for concatenation proofs). This reorganization improves separation of concerns and prepares the codebase for future SNARK-friendly implementations.
Key changes:
- Introduces new top-level module structure grouping related functionality
- Updates import paths throughout the codebase to reflect new organization
- Moves deprecated aliases from
lib.rstoprotocol/mod.rs - Changes
blst_error_to_stm_errorvisibility frompub(crate)topub
Reviewed changes
Copilot reviewed 30 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/lib.rs | Simplified to export from new top-level modules; moved deprecated aliases to protocol module |
| mithril-stm/src/signature_scheme/mod.rs | New module aggregating BLS and Schnorr signature schemes |
| mithril-stm/src/signature_scheme/schnorr_signature/mod.rs | Empty placeholder module for future Schnorr implementation |
| mithril-stm/src/protocol/mod.rs | New module aggregating protocol components with deprecated aliases |
| mithril-stm/src/protocol/error.rs | Changed blst_error_to_stm_error visibility to public |
| mithril-stm/src/protocol/eligibility_check.rs | Moved from root to protocol module |
| mithril-stm/src/membership_commitment/mod.rs | New module for Merkle tree implementations |
| mithril-stm/src/proof_system/mod.rs | New module for proof system implementations |
| mithril-stm/src/signature_scheme/bls_multi_signature/*.rs | Updated import paths to reference new module structure |
| mithril-stm/src/protocol/aggregate_signature/*.rs | Updated import paths for new module locations |
| mithril-stm/src/protocol/participant/*.rs | Updated import paths for signature scheme and protocol references |
| mithril-stm/Cargo.toml | Version bumped from 0.6.0 to 0.6.1 |
| mithril-stm/CHANGELOG.md | Added entry for version 0.6.1 documenting reorganization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1 @@ | |||
|
|
|||
Copilot
AI
Nov 26, 2025
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.
The schnorr_signature module is declared in signature_scheme/mod.rs but contains only an empty file. Either add a TODO comment explaining this is a placeholder for future SNARK implementation, or remove the module declaration from signature_scheme/mod.rs until the implementation is ready.
| pub use aggregate_signature::{ | ||
| AggregateSignature, AggregateSignatureType, AggregateVerificationKey, BasicVerifier, Clerk, | ||
| }; | ||
| pub use error::*; | ||
| pub use key_registration::*; | ||
| pub use parameters::*; | ||
| pub use participant::{Initializer, Signer, VerificationKey, VerificationKeyProofOfPossession}; | ||
| pub use single_signature::{SingleSignature, SingleSignatureWithRegisteredParty}; |
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.
It's probably better to control exactly what we make public:
| pub use aggregate_signature::{ | |
| AggregateSignature, AggregateSignatureType, AggregateVerificationKey, BasicVerifier, Clerk, | |
| }; | |
| pub use error::*; | |
| pub use key_registration::*; | |
| pub use parameters::*; | |
| pub use participant::{Initializer, Signer, VerificationKey, VerificationKeyProofOfPossession}; | |
| pub use single_signature::{SingleSignature, SingleSignatureWithRegisteredParty}; | |
| pub use aggregate_signature::{ | |
| AggregateSignature, AggregateSignatureType, AggregateVerificationKey, BasicVerifier, Clerk, | |
| }; | |
| pub use error::{ | |
| AggregateSignatureError, AggregationError, MultiSignatureError, RegisterError, SignatureError, | |
| }; | |
| pub use key_registration::{ClosedKeyRegistration, KeyRegistration}; | |
| pub use parameters::Parameters; | |
| pub use participant::{Initializer, Signer, VerificationKey, VerificationKeyProofOfPossession}; | |
| pub use single_signature::{SingleSignature, SingleSignatureWithRegisteredParty}; |
| MerkleBatchPath, MerklePath, MerkleTreeLeaf, parent, sibling, | ||
| }; | ||
| use crate::{MerkleTreeError, StmResult}; | ||
| use anyhow::{Context, anyhow}; |
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.
Could you move it with the other external imports?
| use anyhow::{Context, anyhow}; | |
| use anyhow::{Context, anyhow}; |
| use std::marker::PhantomData; | ||
|
|
||
| use crate::StmResult; | ||
| use crate::error::MerkleTreeError; | ||
| use crate::{MerkleTreeError, StmResult}; | ||
| use blake2::digest::{Digest, FixedOutput}; | ||
| use serde::{Deserialize, Serialize}; |
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.
Could you also re-organize these imports?
| use crate::signature_scheme::{BlsSignature, BlsSigningKey, BlsVerificationKey}; | ||
| use crate::{ | ||
| ClosedKeyRegistration, Parameters, SingleSignature, Stake, | ||
| protocol::eligibility_check::is_lottery_won, |
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.
This should probably be a super import.
| use crate::{ | ||
| StmResult, | ||
| bls_multi_signature::{ | ||
| MultiSignatureError, StmResult, blst_error_to_stm_error, |
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.
blst_error_to_stm_error should not be published IMHO
Content
This PR includes re-organization of the modules in
mithril-stmto make the library ready for SNARK integration.Pre-submit checklist
Comments
Issue(s)
Closes #2793