Skip to content

Commit b274ecd

Browse files
committed
moved single sig error to its module
1 parent b2df10f commit b274ecd

File tree

6 files changed

+24
-130
lines changed

6 files changed

+24
-130
lines changed

mithril-stm/src/protocol/error.rs

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -7,101 +7,6 @@ use crate::{
77
signature_scheme::{BlsSignature, BlsVerificationKey, BlsVerificationKeyProofOfPossession},
88
};
99

10-
/// Error types for multi signatures.
11-
// #[derive(Debug, thiserror::Error, Eq, PartialEq)]
12-
// pub enum MultiSignatureError {
13-
// /// Invalid Single signature
14-
// #[error("Invalid single signature")]
15-
// SignatureInvalid(BlsSignature),
16-
17-
// /// Invalid aggregate signature
18-
// #[error("Invalid aggregated signature")]
19-
// AggregateSignatureInvalid,
20-
21-
// /// This error occurs when the the serialization of the raw bytes failed
22-
// #[error("Invalid bytes")]
23-
// SerializationError,
24-
25-
// /// Incorrect proof of possession
26-
// #[error("Key with invalid PoP")]
27-
// KeyInvalid(Box<BlsVerificationKeyProofOfPossession>),
28-
29-
// /// At least one signature in the batch is invalid
30-
// #[error("One signature in the batch is invalid")]
31-
// BatchInvalid,
32-
33-
// /// Single signature is the infinity
34-
// #[error("Single signature is the infinity")]
35-
// SignatureInfinity(BlsSignature),
36-
37-
// /// Verification key is the infinity
38-
// #[error("Verification key is the infinity")]
39-
// VerificationKeyInfinity(Box<BlsVerificationKey>),
40-
// }
41-
42-
/// Error types related to merkle trees.
43-
// #[derive(Debug, Clone, thiserror::Error)]
44-
// pub enum MerkleTreeError {
45-
// /// Serialization error
46-
// #[error("Serialization of a merkle tree failed")]
47-
// SerializationError,
48-
49-
// /// Invalid merkle path
50-
// #[error("Path does not verify against root")]
51-
// PathInvalid(Vec<u8>),
52-
53-
// /// Invalid merkle batch path
54-
// #[error("Batch path does not verify against root")]
55-
// BatchPathInvalid(Vec<u8>),
56-
// }
57-
58-
/// Errors which can be output by Mithril single signature verification.
59-
#[derive(Debug, Clone, thiserror::Error)]
60-
pub enum SignatureError {
61-
/// There is an index out of bounds
62-
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
63-
IndexBoundFailed(u64, u64),
64-
65-
/// The lottery was actually lost for the signature
66-
#[error("Lottery for this epoch was lost.")]
67-
LotteryLost,
68-
69-
/// This error occurs when the the serialization of the raw bytes failed
70-
#[error("Invalid bytes")]
71-
SerializationError,
72-
}
73-
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),
80-
81-
// #[error("Unsupported proof system: {0}")]
82-
// UnsupportedProofSystem(AggregateSignatureType),
83-
84-
// /// There is a duplicate index
85-
// #[error("Indices are not unique.")]
86-
// IndexNotUnique,
87-
// }
88-
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,
95-
96-
// /// Batch verification of STM aggregate signatures failed
97-
// #[error("Batch verification of STM aggregate signatures failed")]
98-
// BatchInvalid,
99-
100-
// /// The proof system used in the aggregate signature is not supported
101-
// #[error("Unsupported proof system: {0}")]
102-
// UnsupportedProofSystem(AggregateSignatureType),
103-
// }
104-
10510
/// Errors which can be outputted by key registration.
10611
#[derive(Debug, Clone, thiserror::Error, PartialEq, Eq)]
10712
pub enum RegisterError {
@@ -121,32 +26,3 @@ pub enum RegisterError {
12126
#[error("Initializer not registered. Cannot participate as a signer.")]
12227
UnregisteredInitializer,
12328
}
124-
125-
// pub fn blst_error_to_stm_error(
126-
// e: BLST_ERROR,
127-
// sig: Option<BlsSignature>,
128-
// key: Option<BlsVerificationKey>,
129-
// ) -> StmResult<()> {
130-
// match e {
131-
// BLST_ERROR::BLST_SUCCESS => Ok(()),
132-
// BLST_ERROR::BLST_PK_IS_INFINITY => {
133-
// if let Some(s) = sig {
134-
// return Err(anyhow!(MultiSignatureError::SignatureInfinity(s)));
135-
// }
136-
// if let Some(vk) = key {
137-
// return Err(anyhow!(MultiSignatureError::VerificationKeyInfinity(
138-
// Box::new(vk)
139-
// )));
140-
// }
141-
// Err(anyhow!(MultiSignatureError::SerializationError))
142-
// }
143-
// BLST_ERROR::BLST_VERIFY_FAIL => {
144-
// if let Some(s) = sig {
145-
// Err(anyhow!(MultiSignatureError::SignatureInvalid(s)))
146-
// } else {
147-
// Err(anyhow!(MultiSignatureError::AggregateSignatureInvalid))
148-
// }
149-
// }
150-
// _ => Err(anyhow!(MultiSignatureError::SerializationError)),
151-
// }
152-
// }

mithril-stm/src/protocol/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ pub use aggregate_signature::{
1111
AggregationError, BasicVerifier, Clerk,
1212
};
1313
pub(crate) use eligibility_check::is_lottery_won;
14-
pub use error::{RegisterError, SignatureError};
14+
pub use error::RegisterError;
1515
pub use key_registration::{ClosedKeyRegistration, KeyRegistration, RegisteredParty};
1616
pub use parameters::Parameters;
1717
pub use participant::{Initializer, Signer, VerificationKey, VerificationKeyProofOfPossession};
18-
pub use single_signature::{SingleSignature, SingleSignatureWithRegisteredParty};
18+
pub use single_signature::{SignatureError, SingleSignature, SingleSignatureWithRegisteredParty};
1919

2020
// Aliases
2121
#[deprecated(since = "0.5.0", note = "Use `AggregateSignature` instead")]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// Errors which can be output by Mithril single signature verification.
2+
#[derive(Debug, Clone, thiserror::Error)]
3+
pub enum SignatureError {
4+
/// There is an index out of bounds
5+
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
6+
IndexBoundFailed(u64, u64),
7+
8+
/// The lottery was actually lost for the signature
9+
#[error("Lottery for this epoch was lost.")]
10+
LotteryLost,
11+
12+
/// This error occurs when the the serialization of the raw bytes failed
13+
#[error("Invalid bytes")]
14+
SerializationError,
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
mod error;
12
mod signature;
23
mod signature_registered_party;
34

5+
pub use error::*;
46
pub use signature::*;
57
pub use signature_registered_party::*;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ use anyhow::{Context, anyhow};
77
use blake2::digest::{Digest, FixedOutput};
88
use serde::{Deserialize, Serialize};
99

10+
use super::SignatureError;
1011
use crate::{
11-
AggregateVerificationKey, Index, Parameters, SignatureError, Stake, StmResult, VerificationKey,
12-
is_lottery_won, signature_scheme::BlsSignature,
12+
AggregateVerificationKey, BlsSignature, Index, Parameters, Stake, StmResult, VerificationKey,
13+
is_lottery_won,
1314
};
1415

1516
/// Signature created by a single party who has won the lottery.

mithril-stm/src/protocol/single_signature/signature_registered_party.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use blake2::digest::{Digest, FixedOutput};
22
use serde::{Deserialize, Serialize, Serializer, ser::SerializeTuple};
33

4-
use super::SingleSignature;
5-
use crate::{RegisteredParty, SignatureError, StmResult};
4+
use super::{SignatureError, SingleSignature};
5+
use crate::{RegisteredParty, StmResult};
66

77
/// Signature with its registered party.
88
#[derive(Debug, Clone, Hash, Deserialize, Eq, PartialEq, Ord, PartialOrd)]

0 commit comments

Comments
 (0)