Skip to content

Commit 4817ac9

Browse files
committed
moved aggration errors to aggregate_signature
1 parent e374ade commit 4817ac9

File tree

9 files changed

+79
-40
lines changed

9 files changed

+79
-40
lines changed

mithril-common/src/protocol/multi_signer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl MultiSigner {
9191

9292
#[cfg(test)]
9393
mod test {
94-
use mithril_stm::MultiSignatureError;
94+
use mithril_stm::BlsSignatureError;
9595

9696
use crate::{
9797
crypto_helper::ProtocolAggregationError,
@@ -195,8 +195,8 @@ mod test {
195195
"Verify single signature should fail if the signer isn't in the registered parties",
196196
);
197197

198-
match error.downcast_ref::<MultiSignatureError>() {
199-
Some(MultiSignatureError::SignatureInvalid(_)) => (),
198+
match error.downcast_ref::<BlsSignatureError>() {
199+
Some(BlsSignatureError::SignatureInvalid(_)) => (),
200200
_ => panic!("Expected an SignatureInvalid error, got: {error:?}"),
201201
}
202202
}
@@ -221,8 +221,8 @@ mod test {
221221
.verify_single_signature(&ProtocolMessage::default(), &single_signature)
222222
.expect_err("Verify single signature should fail");
223223

224-
match error.downcast_ref::<MultiSignatureError>() {
225-
Some(MultiSignatureError::SignatureInvalid(_)) => (),
224+
match error.downcast_ref::<BlsSignatureError>() {
225+
Some(BlsSignatureError::SignatureInvalid(_)) => (),
226226
_ => panic!("Expected an SignatureInvalid error, got: {error:?}"),
227227
}
228228
}

mithril-stm/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ mod protocol;
117117
mod signature_scheme;
118118

119119
pub use protocol::*;
120+
pub use signature_scheme::BlsSignatureError;
120121

121122
#[cfg(feature = "benchmark-internals")]
122123
pub use signature_scheme::{

mithril-stm/src/protocol/aggregate_signature/basic_verifier.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use anyhow::{Context, anyhow};
22
use std::collections::{BTreeMap, HashMap, HashSet};
33

4+
use super::AggregationError;
45
use crate::{
5-
AggregationError, Index, Parameters, RegisteredParty, SingleSignature,
6-
SingleSignatureWithRegisteredParty, Stake, StmResult,
6+
Index, Parameters, RegisteredParty, SingleSignature, SingleSignatureWithRegisteredParty, Stake,
7+
StmResult,
78
membership_commitment::MerkleTreeLeaf,
89
signature_scheme::{BlsSignature, BlsVerificationKey},
910
};

mithril-stm/src/protocol/aggregate_signature/clerk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use blake2::digest::{Digest, FixedOutput};
55
use anyhow::anyhow;
66

77
#[cfg(feature = "future_proof_system")]
8-
use crate::AggregationError;
8+
use super::AggregationError;
99

1010
use super::{AggregateSignature, AggregateSignatureType, AggregateVerificationKey};
1111
use crate::{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use crate::AggregateSignatureType;
2+
3+
/// Error types for aggregation.
4+
#[derive(Debug, Clone, thiserror::Error)]
5+
pub enum AggregationError {
6+
/// Not enough signatures were collected, got this many instead.
7+
#[error("Not enough signatures. Got only {0} out of {1}.")]
8+
NotEnoughSignatures(u64, u64),
9+
10+
#[error("Unsupported proof system: {0}")]
11+
UnsupportedProofSystem(AggregateSignatureType),
12+
13+
/// There is a duplicate index
14+
#[error("Indices are not unique.")]
15+
IndexNotUnique,
16+
}
17+
18+
/// Errors which can be output by Mithril aggregate verification.
19+
#[derive(Debug, Clone, thiserror::Error)]
20+
pub enum AggregateSignatureError {
21+
/// This error occurs when the the serialization of the raw bytes failed
22+
#[error("Invalid bytes")]
23+
SerializationError,
24+
25+
/// Batch verification of STM aggregate signatures failed
26+
#[error("Batch verification of STM aggregate signatures failed")]
27+
BatchInvalid,
28+
29+
/// The proof system used in the aggregate signature is not supported
30+
#[error("Unsupported proof system: {0}")]
31+
UnsupportedProofSystem(AggregateSignatureType),
32+
}

mithril-stm/src/protocol/aggregate_signature/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
mod aggregate_key;
22
mod basic_verifier;
33
mod clerk;
4+
mod error;
45
mod signature;
56

67
pub use aggregate_key::*;
78
pub use basic_verifier::*;
89
pub use clerk::*;
10+
pub use error::*;
911
pub use signature::*;
1012

1113
#[cfg(test)]
@@ -20,9 +22,11 @@ mod tests {
2022
use rand_core::{RngCore, SeedableRng};
2123
use std::collections::{HashMap, HashSet};
2224

23-
use super::{AggregateSignature, AggregateSignatureType, BasicVerifier, Clerk};
25+
use super::{
26+
AggregateSignature, AggregateSignatureType, AggregationError, BasicVerifier, Clerk,
27+
};
2428
use crate::{
25-
AggregationError, Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
29+
Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
2630
SingleSignatureWithRegisteredParty, Stake, StmResult,
2731
membership_commitment::MerkleBatchPath, signature_scheme::BlsVerificationKey,
2832
};

mithril-stm/src/protocol/aggregate_signature/signature.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use anyhow::anyhow;
44
use blake2::digest::{Digest, FixedOutput};
55
use serde::{Deserialize, Serialize};
66

7-
use super::AggregateVerificationKey;
7+
use super::{AggregateSignatureError, AggregateVerificationKey};
88
use crate::{
9-
AggregateSignatureError, Parameters, StmError, StmResult,
10-
membership_commitment::MerkleBatchPath, proof_system::ConcatenationProof,
9+
Parameters, StmError, StmResult, membership_commitment::MerkleBatchPath,
10+
proof_system::ConcatenationProof,
1111
};
1212

1313
/// The type of STM aggregate signature.

mithril-stm/src/protocol/error.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,36 +71,36 @@ pub enum SignatureError {
7171
SerializationError,
7272
}
7373

74-
/// Error types for aggregation.
75-
#[derive(Debug, Clone, thiserror::Error)]
76-
pub enum AggregationError {
77-
/// Not enough signatures were collected, got this many instead.
78-
#[error("Not enough signatures. Got only {0} out of {1}.")]
79-
NotEnoughSignatures(u64, u64),
74+
// /// Error types for aggregation.
75+
// #[derive(Debug, Clone, thiserror::Error)]
76+
// pub enum AggregationError {
77+
// /// Not enough signatures were collected, got this many instead.
78+
// #[error("Not enough signatures. Got only {0} out of {1}.")]
79+
// NotEnoughSignatures(u64, u64),
8080

81-
#[error("Unsupported proof system: {0}")]
82-
UnsupportedProofSystem(AggregateSignatureType),
81+
// #[error("Unsupported proof system: {0}")]
82+
// UnsupportedProofSystem(AggregateSignatureType),
8383

84-
/// There is a duplicate index
85-
#[error("Indices are not unique.")]
86-
IndexNotUnique,
87-
}
84+
// /// There is a duplicate index
85+
// #[error("Indices are not unique.")]
86+
// IndexNotUnique,
87+
// }
8888

89-
/// Errors which can be output by Mithril aggregate verification.
90-
#[derive(Debug, Clone, thiserror::Error)]
91-
pub enum AggregateSignatureError {
92-
/// This error occurs when the the serialization of the raw bytes failed
93-
#[error("Invalid bytes")]
94-
SerializationError,
89+
// /// Errors which can be output by Mithril aggregate verification.
90+
// #[derive(Debug, Clone, thiserror::Error)]
91+
// pub enum AggregateSignatureError {
92+
// /// This error occurs when the the serialization of the raw bytes failed
93+
// #[error("Invalid bytes")]
94+
// SerializationError,
9595

96-
/// Batch verification of STM aggregate signatures failed
97-
#[error("Batch verification of STM aggregate signatures failed")]
98-
BatchInvalid,
96+
// /// Batch verification of STM aggregate signatures failed
97+
// #[error("Batch verification of STM aggregate signatures failed")]
98+
// BatchInvalid,
9999

100-
/// The proof system used in the aggregate signature is not supported
101-
#[error("Unsupported proof system: {0}")]
102-
UnsupportedProofSystem(AggregateSignatureType),
103-
}
100+
// /// The proof system used in the aggregate signature is not supported
101+
// #[error("Unsupported proof system: {0}")]
102+
// UnsupportedProofSystem(AggregateSignatureType),
103+
// }
104104

105105
/// Errors which can be outputted by key registration.
106106
#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)]

mithril-stm/src/protocol/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ mod participant;
77
mod single_signature;
88

99
pub use aggregate_signature::{
10-
AggregateSignature, AggregateSignatureType, AggregateVerificationKey, BasicVerifier, Clerk,
10+
AggregateSignature, AggregateSignatureError, AggregateSignatureType, AggregateVerificationKey,
11+
AggregationError, BasicVerifier, Clerk,
1112
};
1213
pub(crate) use eligibility_check::is_lottery_won;
13-
pub use error::{AggregateSignatureError, AggregationError, RegisterError, SignatureError};
14+
pub use error::{RegisterError, SignatureError};
1415
pub use key_registration::{ClosedKeyRegistration, KeyRegistration, RegisteredParty};
1516
pub use parameters::Parameters;
1617
pub use participant::{Initializer, Signer, VerificationKey, VerificationKeyProofOfPossession};

0 commit comments

Comments
 (0)