Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mithril-stm/src/aggregate_signature/aggregate_key.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use blake2::digest::{Digest, FixedOutput};
use serde::{Deserialize, Serialize};

use crate::merkle_tree::{MerkleBatchPath, MerkleTreeBatchCommitment};
use crate::membership_commitment::{MerkleBatchPath, MerkleTreeBatchCommitment};
use crate::{ClosedKeyRegistration, Stake};

/// Stm aggregate key (batch compatible), which contains the merkle tree commitment and the total stake of the system.
Expand Down
4 changes: 2 additions & 2 deletions mithril-stm/src/aggregate_signature/basic_verifier.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::{Context, anyhow};
use std::collections::{BTreeMap, HashMap, HashSet};

use crate::bls_multi_signature::{BlsSignature, BlsVerificationKey};
use crate::key_registration::RegisteredParty;
use crate::merkle_tree::MerkleTreeLeaf;
use crate::membership_commitment::MerkleTreeLeaf;
use crate::signature_scheme::{BlsSignature, BlsVerificationKey};
use crate::{
AggregationError, Index, Parameters, SingleSignature, SingleSignatureWithRegisteredParty,
Stake, StmResult,
Expand Down
2 changes: 1 addition & 1 deletion mithril-stm/src/aggregate_signature/clerk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
AggregateSignature, AggregateSignatureType, AggregateVerificationKey, ClosedKeyRegistration,
Index, Parameters, Signer, SingleSignature, Stake, StmResult, VerificationKey,
aggregate_signature::ConcatenationProof,
proof_system::ConcatenationProof,
};
use anyhow::Context;
use blake2::digest::{Digest, FixedOutput};
Expand Down
6 changes: 2 additions & 4 deletions mithril-stm/src/aggregate_signature/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
mod aggregate_key;
mod basic_verifier;
mod clerk;
mod proof;
mod signature;

pub use aggregate_key::*;
pub use basic_verifier::*;
pub use clerk::*;
pub use proof::*;
pub use signature::*;

#[cfg(test)]
Expand All @@ -26,9 +24,9 @@ mod tests {
use crate::{
AggregateSignature, AggregateSignatureType, AggregationError, BasicVerifier, Clerk,
Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
SingleSignatureWithRegisteredParty, Stake, bls_multi_signature::BlsVerificationKey,
SingleSignatureWithRegisteredParty, Stake, signature_scheme::BlsVerificationKey,
};
use crate::{StmResult, merkle_tree::MerkleBatchPath};
use crate::{StmResult, membership_commitment::MerkleBatchPath};

type Sig = AggregateSignature<D>;
type D = Blake2b<U32>;
Expand Down
8 changes: 3 additions & 5 deletions mithril-stm/src/aggregate_signature/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use blake2::digest::{Digest, FixedOutput};
use serde::{Deserialize, Serialize};

use crate::error::AggregateSignatureError;
use crate::merkle_tree::MerkleBatchPath;
use crate::{AggregateVerificationKey, Parameters, StmResult};

use super::ConcatenationProof;
use crate::membership_commitment::MerkleBatchPath;
use crate::{AggregateVerificationKey, Parameters, StmResult, proof_system::ConcatenationProof};

/// The type of STM aggregate signature.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
Expand Down Expand Up @@ -211,7 +209,7 @@ mod tests {
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

use crate::bls_multi_signature::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::signature_scheme::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::{
AggregateSignature, AggregateSignatureType, Clerk, ClosedKeyRegistration,
KeyRegistration, Parameters, Signer,
Expand Down
2 changes: 1 addition & 1 deletion mithril-stm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use blst::BLST_ERROR;

use crate::StmResult;
use crate::aggregate_signature::AggregateSignatureType;
use crate::bls_multi_signature::{
use crate::signature_scheme::{
BlsSignature, BlsVerificationKey, BlsVerificationKeyProofOfPossession,
};

Expand Down
6 changes: 3 additions & 3 deletions mithril-stm/src/key_registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{
use anyhow::anyhow;
use blake2::digest::{Digest, FixedOutput};

use crate::bls_multi_signature::{BlsVerificationKey, BlsVerificationKeyProofOfPossession};
use crate::error::RegisterError;
use crate::merkle_tree::{MerkleTree, MerkleTreeLeaf};
use crate::membership_commitment::{MerkleTree, MerkleTreeLeaf};
use crate::signature_scheme::{BlsVerificationKey, BlsVerificationKeyProofOfPossession};
use crate::{Stake, StmResult};

/// Stores a registered party with its public key and the associated stake.
Expand Down Expand Up @@ -94,7 +94,7 @@ mod tests {
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

use crate::bls_multi_signature::BlsSigningKey;
use crate::signature_scheme::BlsSigningKey;

use super::*;

Expand Down
7 changes: 4 additions & 3 deletions mithril-stm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@
//! ```

mod aggregate_signature;
mod bls_multi_signature;
mod eligibility_check;
mod error;
mod key_registration;
mod merkle_tree;
mod membership_commitment;
mod parameters;
mod participant;
mod proof_system;
mod signature_scheme;
mod single_signature;

pub use aggregate_signature::{
Expand All @@ -133,7 +134,7 @@ pub use participant::{Initializer, Signer, VerificationKey, VerificationKeyProof
pub use single_signature::{SingleSignature, SingleSignatureWithRegisteredParty};

#[cfg(feature = "benchmark-internals")]
pub use bls_multi_signature::{
pub use signature_scheme::{
BlsProofOfPossession, BlsSignature, BlsSigningKey, BlsVerificationKey,
BlsVerificationKeyProofOfPossession,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use serde::{Deserialize, Serialize};

use crate::StmResult;
use crate::error::MerkleTreeError;
use crate::merkle_tree::{MerkleBatchPath, MerklePath, MerkleTreeLeaf, parent, sibling};
use crate::membership_commitment::merkle_tree::{
MerkleBatchPath, MerklePath, MerkleTreeLeaf, parent, sibling,
};
use anyhow::{Context, anyhow};
/// `MerkleTree` commitment.
/// This structure differs from `MerkleTree` in that it does not contain all elements, which are not always necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::cmp::Ordering;
use serde::{Deserialize, Serialize};

use crate::StmResult;
use crate::bls_multi_signature::BlsVerificationKey;
use crate::error::MerkleTreeError;
use crate::signature_scheme::BlsVerificationKey;
use crate::{Stake, VerificationKey};
/// The values that are committed in the Merkle Tree.
/// Namely, a verified `VerificationKey` and its corresponding stake.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};

use crate::StmResult;
use crate::error::MerkleTreeError;
use crate::merkle_tree::{
use crate::membership_commitment::merkle_tree::{
MerkleBatchPath, MerklePath, MerkleTreeBatchCommitment, MerkleTreeCommitment, MerkleTreeLeaf,
left_child, parent, right_child, sibling,
};
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<D: Digest + FixedOutput> MerkleTree<D> {
#[cfg(test)]
mod tests {
use super::*;
use crate::bls_multi_signature::BlsVerificationKey;
use crate::signature_scheme::BlsVerificationKey;
use blake2::{Blake2b, digest::consts::U32};
use proptest::collection::vec;
use proptest::prelude::*;
Expand Down
3 changes: 3 additions & 0 deletions mithril-stm/src/membership_commitment/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod merkle_tree;

pub use merkle_tree::*;
2 changes: 1 addition & 1 deletion mithril-stm/src/participant/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use digest::FixedOutput;
use rand_core::{CryptoRng, RngCore};
use serde::{Deserialize, Serialize};

use crate::bls_multi_signature::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::signature_scheme::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::{Parameters, RegisterError, Signer, Stake};
use crate::{StmResult, key_registration::*};
use anyhow::anyhow;
Expand Down
2 changes: 1 addition & 1 deletion mithril-stm/src/participant/signer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use blake2::digest::{Digest, FixedOutput};

use crate::bls_multi_signature::{BlsSignature, BlsSigningKey, BlsVerificationKey};
use crate::eligibility_check::is_lottery_won;
use crate::key_registration::ClosedKeyRegistration;
use crate::signature_scheme::{BlsSignature, BlsSigningKey, BlsVerificationKey};
use crate::{Parameters, SingleSignature, Stake};

/// Wrapper of the MultiSignature Verification key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use blake2::digest::{Digest, FixedOutput};

use serde::{Deserialize, Serialize};

use crate::aggregate_signature::clerk::Clerk;
use crate::bls_multi_signature::{BlsSignature, BlsVerificationKey};
use crate::key_registration::RegisteredParty;
use crate::merkle_tree::MerkleBatchPath;
use crate::membership_commitment::MerkleBatchPath;
use crate::signature_scheme::{BlsSignature, BlsVerificationKey};
use crate::{
AggregateSignatureError, AggregateVerificationKey, BasicVerifier, Parameters, SingleSignature,
SingleSignatureWithRegisteredParty, StmResult,
AggregateSignatureError, AggregateVerificationKey, BasicVerifier, Clerk, Parameters,
SingleSignature, SingleSignatureWithRegisteredParty, StmResult,
};

/// `ConcatenationProof` uses the "concatenation" proving system (as described in Section 4.3 of the original paper.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) mod unsafe_helpers {
use crate::error::MultiSignatureError::SerializationError;
use crate::{
StmResult,
bls_multi_signature::{BlsProofOfPossession, BlsVerificationKey},
signature_scheme::{BlsProofOfPossession, BlsVerificationKey},
};

/// Check manually if the pairing `e(g1,mvk) = e(k2,g2)` holds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ mod tests {
use rand_core::{RngCore, SeedableRng};

use crate::RegisterError;
use crate::bls_multi_signature::helper::unsafe_helpers::{p1_affine_to_sig, p2_affine_to_vk};
use crate::error::MultiSignatureError;
use crate::key_registration::KeyRegistration;
use crate::signature_scheme::helper::unsafe_helpers::{p1_affine_to_sig, p2_affine_to_vk};

use super::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use blst::{blst_p1, min_sig::Signature as BlstSig};
use crate::error::{MultiSignatureError, blst_error_to_stm_error};
use crate::{
StmResult,
bls_multi_signature::{
signature_scheme::{
BlsSigningKey, POP,
helper::unsafe_helpers::{compress_p1, scalar_to_pk_in_g1, uncompress_p1},
},
Expand Down Expand Up @@ -79,7 +79,7 @@ mod tests {
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

use crate::bls_multi_signature::{BlsProofOfPossession, BlsSigningKey};
use crate::signature_scheme::{BlsProofOfPossession, BlsSigningKey};

const GOLDEN_JSON: &str = r#"[168,50,233,193,15,136,65,72,123,148,129,176,38,198,209,47,28,204,176,144,57,251,42,28,66,76,89,97,158,63,54,198,194,176,135,221,14,185,197,225,202,98,243,74,233,225,143,151,147,177,170,117,66,165,66,62,33,216,232,75,68,114,195,22,100,65,44,198,4,166,102,233,253,240,59,175,60,117,142,114,140,122,17,87,110,187,1,17,10,195,154,13,249,86,54,226]"#;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
};
use crate::{
StmResult,
bls_multi_signature::{
signature_scheme::{
BlsVerificationKey,
helper::unsafe_helpers::{p1_affine_to_sig, p2_affine_to_vk, sig_to_p1, vk_from_p2_affine},
},
Expand Down Expand Up @@ -220,7 +220,7 @@ mod tests {
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

use crate::bls_multi_signature::{BlsSignature, BlsSigningKey};
use crate::signature_scheme::{BlsSignature, BlsSigningKey};

const GOLDEN_JSON: &str = r#"[132,95,124,197,185,105,193,171,114,182,52,171,205,119,202,188,2,213,61,125,219,242,10,131,53,219,53,197,157,42,152,194,234,161,244,204,2,134,47,179,176,49,200,232,120,241,180,246]"#;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use blst::min_sig::SecretKey as BlstSk;
use rand_core::{CryptoRng, RngCore};

use crate::StmResult;
use crate::bls_multi_signature::signature::BlsSignature;
use crate::error::{MultiSignatureError, blst_error_to_stm_error};
use crate::signature_scheme::BlsSignature;

/// MultiSig secret key, which is a wrapper over the BlstSk type from the blst
/// library.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
use crate::error::{MultiSignatureError, blst_error_to_stm_error};
use crate::{
StmResult,
bls_multi_signature::{
signature_scheme::{
BlsProofOfPossession, BlsSigningKey, POP, helper::unsafe_helpers::verify_pairing,
},
};
Expand Down
4 changes: 4 additions & 0 deletions mithril-stm/src/signature_scheme/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mod bls_multi_signature;
mod schnorr_signature;

pub use bls_multi_signature::*;
1 change: 1 addition & 0 deletions mithril-stm/src/signature_scheme/schnorr_signature/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 2 additions & 2 deletions mithril-stm/src/single_signature/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::{
use blake2::digest::{Digest, FixedOutput};
use serde::{Deserialize, Serialize};

use crate::bls_multi_signature::BlsSignature;
use crate::eligibility_check::is_lottery_won;
use crate::signature_scheme::BlsSignature;
use crate::{
AggregateVerificationKey, Index, Parameters, SignatureError, Stake, StmResult, VerificationKey,
};
Expand Down Expand Up @@ -207,7 +207,7 @@ mod tests {
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

use crate::bls_multi_signature::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::signature_scheme::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::{ClosedKeyRegistration, KeyRegistration, Parameters, Signer, SingleSignature};

type D = Blake2b<U32>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod tests {
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

use crate::bls_multi_signature::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::signature_scheme::{BlsSigningKey, BlsVerificationKeyProofOfPossession};
use crate::{
ClosedKeyRegistration, KeyRegistration, Parameters, Signer,
SingleSignatureWithRegisteredParty,
Expand Down