Skip to content

Commit 24a4f36

Browse files
curiecryptiquerejeta
authored andcommitted
error type for aggregate sig
1 parent 58cb869 commit 24a4f36

File tree

4 files changed

+95
-66
lines changed

4 files changed

+95
-66
lines changed

mithril-core/benches/size_benches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where
4646
let sigs = ps
4747
.par_iter()
4848
.filter_map(|p| p.sign(&msg))
49-
.collect::<Vec<StmSig<H>>>();
49+
.collect::<Vec<StmSig>>();
5050
let clerk = StmClerk::from_signer(&ps[0]);
5151

5252
// Aggregate with random parties

mithril-core/src/error.rs

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,17 @@ pub enum MultiSignatureError {
2727
KeyInvalid(Box<VerificationKeyPoP>),
2828
}
2929

30-
/// Errors which can be output by Mithril verification.
30+
/// Errors which can be output by Mithril single signature verification.
3131
#[derive(Debug, Clone, thiserror::Error)]
32-
pub enum StmSignatureError<D: Digest + FixedOutput> {
33-
/// No quorum was found
34-
#[error("No Quorum was found.")]
35-
NoQuorum,
36-
32+
pub enum StmSignatureError {
3733
/// The IVK is invalid after aggregating the keys
3834
#[error("Aggregated key does not correspond to the expected key.")]
3935
IvkInvalid(VerificationKey),
4036

41-
/// Mu is not the sum of the signatures
42-
#[error("Aggregated signature does not correspond to the expected signature.")]
43-
SumInvalid(Signature),
44-
4537
/// There is an index out of bounds
4638
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
4739
IndexBoundFailed(u64, u64),
4840

49-
/// There is a duplicate index
50-
#[error("Indeces are not unique.")]
51-
IndexNotUnique,
52-
5341
/// MSP.Eval was computed incorrectly
5442
#[error("The claimed evaluation of function phi is incorrect.")]
5543
EvalInvalid([u8; 64]),
@@ -62,6 +50,30 @@ pub enum StmSignatureError<D: Digest + FixedOutput> {
6250
#[error("A provided signature is invalid")]
6351
SingleSignatureInvalid(Signature),
6452

53+
/// This error occurs when the the serialization of the raw bytes failed
54+
#[error("Invalid bytes")]
55+
SerializationError,
56+
}
57+
58+
/// Errors which can be output by Mithril aggregate verification.
59+
#[derive(Debug, Clone, thiserror::Error)]
60+
pub enum StmAggregateSignatureError<D: Digest + FixedOutput> {
61+
/// No quorum was found
62+
#[error("No Quorum was found.")]
63+
NoQuorum,
64+
65+
/// The IVK is invalid after aggregating the keys
66+
#[error("Aggregated key does not correspond to the expected key.")]
67+
IvkInvalid(VerificationKey),
68+
69+
/// There is an index out of bounds
70+
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
71+
IndexBoundFailed(u64, u64),
72+
73+
/// There is a duplicate index
74+
#[error("Indices are not unique.")]
75+
IndexNotUnique,
76+
6577
/// The aggregated signature is invalid
6678
#[error("Aggregate signature is invalid")]
6779
SignatureInvalid,
@@ -123,7 +135,7 @@ pub enum RegisterError {
123135
UnregisteredInitializer,
124136
}
125137

126-
impl<D: Digest + FixedOutput> From<RegisterError> for StmSignatureError<D> {
138+
impl From<RegisterError> for StmSignatureError {
127139
fn from(e: RegisterError) -> Self {
128140
match e {
129141
RegisterError::SerializationError => Self::SerializationError,
@@ -134,7 +146,7 @@ impl<D: Digest + FixedOutput> From<RegisterError> for StmSignatureError<D> {
134146
}
135147
}
136148

137-
impl<D: Digest + FixedOutput> From<MerkleTreeError<D>> for StmSignatureError<D> {
149+
impl<D: Digest + FixedOutput> From<MerkleTreeError<D>> for StmAggregateSignatureError<D> {
138150
fn from(e: MerkleTreeError<D>) -> Self {
139151
match e {
140152
MerkleTreeError::BatchPathInvalid(e) => Self::PathInvalid(e),
@@ -144,17 +156,41 @@ impl<D: Digest + FixedOutput> From<MerkleTreeError<D>> for StmSignatureError<D>
144156
}
145157
}
146158

147-
impl<D: Digest + FixedOutput> From<MultiSignatureError> for StmSignatureError<D> {
159+
impl From<MultiSignatureError> for StmSignatureError {
148160
fn from(e: MultiSignatureError) -> Self {
149161
match e {
150162
MultiSignatureError::SerializationError => Self::SerializationError,
151163
MultiSignatureError::KeyInvalid(e) => Self::IvkInvalid(e.vk),
152164
MultiSignatureError::SignatureInvalid(e) => Self::SingleSignatureInvalid(e),
165+
MultiSignatureError::AggregateSignatureInvalid => unreachable!(),
166+
}
167+
}
168+
}
169+
170+
impl<D: Digest + FixedOutput> From<MultiSignatureError> for StmAggregateSignatureError<D> {
171+
fn from(e: MultiSignatureError) -> Self {
172+
match e {
173+
MultiSignatureError::SerializationError => Self::SerializationError,
174+
MultiSignatureError::KeyInvalid(e) => Self::IvkInvalid(e.vk),
175+
MultiSignatureError::SignatureInvalid(_e) => unreachable!(),
153176
MultiSignatureError::AggregateSignatureInvalid => Self::SignatureInvalid,
154177
}
155178
}
156179
}
157180

181+
impl<D: Digest + FixedOutput> From<StmSignatureError> for StmAggregateSignatureError<D> {
182+
fn from(e: StmSignatureError) -> Self {
183+
match e {
184+
StmSignatureError::SerializationError => Self::SerializationError,
185+
StmSignatureError::IvkInvalid(e) => Self::IvkInvalid(e),
186+
StmSignatureError::SingleSignatureInvalid(_e) => unreachable!(),
187+
StmSignatureError::IndexBoundFailed(e, _e) => Self::IndexBoundFailed(e, _e),
188+
StmSignatureError::LotteryLost => unreachable!(),
189+
StmSignatureError::EvalInvalid(_e) => unreachable!(),
190+
}
191+
}
192+
}
193+
158194
impl From<MultiSignatureError> for RegisterError {
159195
fn from(e: MultiSignatureError) -> Self {
160196
match e {

0 commit comments

Comments
 (0)