Skip to content

Conversation

@curiecrypt
Copy link
Collaborator

@curiecrypt curiecrypt commented Nov 20, 2025

Content

This PR includes re-organization of the modules in mithril-stm to make the library ready for SNARK integration.

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)

Closes #2793

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

Test Results

    4 files  ±0    168 suites  ±0   23m 4s ⏱️ -50s
2 214 tests ±0  2 214 ✅ ±0  0 💤 ±0  0 ❌ ±0 
6 905 runs  ±0  6 905 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 1673005. ± Comparison against base commit 2943337.

♻️ This comment has been updated with latest results.

@curiecrypt curiecrypt force-pushed the curiecrypt/msnark/re-organize-modules branch from 1ec9ee5 to 1673005 Compare November 26, 2025 12:07
@curiecrypt curiecrypt requested a review from jpraynaud November 26, 2025 12:09
@curiecrypt curiecrypt marked this pull request as ready for review November 26, 2025 12:11
@jpraynaud jpraynaud requested a review from Copilot November 26, 2025 16:55
Copilot finished reviewing on behalf of jpraynaud November 26, 2025 16:57
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 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.rs to protocol/mod.rs
  • Changes blst_error_to_stm_error visibility from pub(crate) to pub

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

Copy link

Copilot AI Nov 26, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +16
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};
Copy link
Member

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:

Suggested change
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};
Copy link
Member

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?

Suggested change
use anyhow::{Context, anyhow};
use anyhow::{Context, anyhow};

Comment on lines 1 to 5
use std::marker::PhantomData;

use crate::StmResult;
use crate::error::MerkleTreeError;
use crate::{MerkleTreeError, StmResult};
use blake2::digest::{Digest, FixedOutput};
use serde::{Deserialize, Serialize};
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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

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.

Re-organize modules of STM library

3 participants