Skip to content

Commit 6425660

Browse files
committed
change log and crates version
1 parent f8cf4f3 commit 6425660

File tree

15 files changed

+65
-79
lines changed

15 files changed

+65
-79
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-stm/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.6.0 (11-19-2025)
9+
10+
### Changed
11+
12+
- Stm error handling is done with `anyhow`.
13+
814
## 0.5.5 (10-13-2025)
915

1016
### Fixed

mithril-stm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-stm"
3-
version = "0.5.5"
3+
version = "0.6.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
homepage = { workspace = true }

mithril-stm/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ match msig {
141141
println!("Not enough signatures");
142142
assert!(n < &params.k && k == &params.k)
143143
},
144-
// Some(AggregationError::UsizeConversionInvalid) => {
145-
// println!("Invalid usize conversion");
146-
// },
144+
147145
Some(AggregationError::UnsupportedProofSystem(aggregate_signature_type)) => {
148146
println!("Unsupported proof system: {:?}", aggregate_signature_type);
149147
},

mithril-stm/src/aggregate_signature/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,11 @@ mod tests {
267267
println!("Not enough signatures");
268268
assert!(n < &params.k && k == &params.k)
269269
},
270-
// Some(AggregationError::UsizeConversionInvalid) => {
271-
// println!("Invalid usize conversion");
272-
// },
273270
Some(AggregationError::UnsupportedProofSystem(aggregate_signature_type)) => {
274-
println!("Unsupported proof system: {:?}", aggregate_signature_type);
271+
panic!("Unsupported proof system: {:?}", aggregate_signature_type);
275272
},
276273
_ => {
277-
println!("Unexpected error during aggregation: {:?}", error);
274+
panic!("Unexpected error during aggregation: {:?}", error);
278275
}
279276
},
280277
}

mithril-stm/src/aggregate_signature/proof/concatenation.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::bls_multi_signature::{BlsSignature, BlsVerificationKey};
88
use crate::key_registration::RegisteredParty;
99
use crate::merkle_tree::MerkleBatchPath;
1010
use crate::{
11-
AggregateVerificationKey, BasicVerifier, Parameters, SingleSignature,
12-
SingleSignatureWithRegisteredParty, StmAggregateSignatureError, StmResult,
11+
AggregateSignatureError, AggregateVerificationKey, BasicVerifier, Parameters, SingleSignature,
12+
SingleSignatureWithRegisteredParty, StmResult,
1313
};
1414

1515
/// `ConcatenationProof` uses the "concatenation" proving system (as described in Section 4.3 of the original paper.)
@@ -211,25 +211,25 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> ConcatenationProof<D> {
211211
u64_bytes.copy_from_slice(
212212
bytes
213213
.get(bytes_index..bytes_index + 8)
214-
.ok_or(StmAggregateSignatureError::SerializationError)?,
214+
.ok_or(AggregateSignatureError::SerializationError)?,
215215
);
216216
let total_sigs = usize::try_from(u64::from_be_bytes(u64_bytes))
217-
.map_err(|_| StmAggregateSignatureError::SerializationError)?;
217+
.map_err(|_| AggregateSignatureError::SerializationError)?;
218218
bytes_index += 8;
219219

220220
let mut sig_reg_list = Vec::with_capacity(total_sigs);
221221
for _ in 0..total_sigs {
222222
u64_bytes.copy_from_slice(
223223
bytes
224224
.get(bytes_index..bytes_index + 8)
225-
.ok_or(StmAggregateSignatureError::SerializationError)?,
225+
.ok_or(AggregateSignatureError::SerializationError)?,
226226
);
227227
let sig_reg_size = usize::try_from(u64::from_be_bytes(u64_bytes))
228-
.map_err(|_| StmAggregateSignatureError::SerializationError)?;
228+
.map_err(|_| AggregateSignatureError::SerializationError)?;
229229
let sig_reg = SingleSignatureWithRegisteredParty::from_bytes::<D>(
230230
bytes
231231
.get(bytes_index + 8..bytes_index + 8 + sig_reg_size)
232-
.ok_or(StmAggregateSignatureError::SerializationError)?,
232+
.ok_or(AggregateSignatureError::SerializationError)?,
233233
)?;
234234
bytes_index += 8 + sig_reg_size;
235235
sig_reg_list.push(sig_reg);
@@ -238,7 +238,7 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> ConcatenationProof<D> {
238238
let batch_proof = MerkleBatchPath::from_bytes(
239239
bytes
240240
.get(bytes_index..)
241-
.ok_or(StmAggregateSignatureError::SerializationError)?,
241+
.ok_or(AggregateSignatureError::SerializationError)?,
242242
)?;
243243

244244
Ok(ConcatenationProof {

mithril-stm/src/aggregate_signature/signature.rs

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use anyhow::anyhow;
21
use std::collections::HashMap;
32
use std::fmt::Display;
43
use std::hash::Hash;
54

5+
use anyhow::anyhow;
66
use blake2::digest::{Digest, FixedOutput};
77
use serde::{Deserialize, Serialize};
88

9-
use crate::error::StmAggregateSignatureError;
9+
use crate::error::AggregateSignatureError;
1010
use crate::merkle_tree::MerkleBatchPath;
1111
use crate::{AggregateVerificationKey, Parameters, StmResult};
1212

@@ -103,7 +103,7 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
103103
}
104104
#[cfg(feature = "future_proof_system")]
105105
AggregateSignature::Future => Err(anyhow!(
106-
StmAggregateSignatureError::UnsupportedProofSystem(self.into())
106+
AggregateSignatureError::UnsupportedProofSystem(self.into())
107107
)),
108108
}
109109
}
@@ -120,36 +120,26 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
120120
acc.entry(sig.into()).or_default().push(sig.clone());
121121
acc
122122
});
123-
stm_signatures
124-
.into_iter()
125-
.try_for_each(|(aggregate_signature_type, aggregate_signatures)| {
126-
match aggregate_signature_type {
127-
AggregateSignatureType::Concatenation => {
128-
let aggregate_signatures_length = aggregate_signatures.len();
129-
let concatenation_proofs = aggregate_signatures
130-
.into_iter()
131-
.filter_map(|s| s.to_concatenation_proof().cloned())
132-
.collect::<Vec<_>>();
133-
if concatenation_proofs.len() != aggregate_signatures_length {
134-
return Err(anyhow!(StmAggregateSignatureError::BatchInvalid));
135-
}
136-
137-
ConcatenationProof::batch_verify(
138-
&concatenation_proofs,
139-
msgs,
140-
avks,
141-
parameters,
142-
)
143-
}
144-
#[cfg(feature = "future_proof_system")]
145-
AggregateSignatureType::Future => {
146-
Err(anyhow!(StmAggregateSignatureError::UnsupportedProofSystem(
147-
aggregate_signature_type
148-
)))
123+
stm_signatures.into_iter().try_for_each(
124+
|(aggregate_signature_type, aggregate_signatures)| match aggregate_signature_type {
125+
AggregateSignatureType::Concatenation => {
126+
let aggregate_signatures_length = aggregate_signatures.len();
127+
let concatenation_proofs = aggregate_signatures
128+
.into_iter()
129+
.filter_map(|s| s.to_concatenation_proof().cloned())
130+
.collect::<Vec<_>>();
131+
if concatenation_proofs.len() != aggregate_signatures_length {
132+
return Err(anyhow!(AggregateSignatureError::BatchInvalid));
149133
}
134+
135+
ConcatenationProof::batch_verify(&concatenation_proofs, msgs, avks, parameters)
150136
}
151-
})
152-
.map_err(|_| anyhow!(StmAggregateSignatureError::BatchInvalid))
137+
#[cfg(feature = "future_proof_system")]
138+
AggregateSignatureType::Future => Err(anyhow!(
139+
AggregateSignatureError::UnsupportedProofSystem(aggregate_signature_type)
140+
)),
141+
},
142+
)
153143
}
154144

155145
/// Convert an aggregate signature to bytes
@@ -173,11 +163,10 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
173163

174164
/// Extract an aggregate signature from a byte slice.
175165
pub fn from_bytes(bytes: &[u8]) -> StmResult<Self> {
176-
let proof_type_byte =
177-
bytes.first().ok_or(StmAggregateSignatureError::SerializationError)?;
166+
let proof_type_byte = bytes.first().ok_or(AggregateSignatureError::SerializationError)?;
178167
let proof_bytes = &bytes[1..];
179168
let proof_type = AggregateSignatureType::from_byte_encoding_prefix(*proof_type_byte)
180-
.ok_or(StmAggregateSignatureError::SerializationError)?;
169+
.ok_or(AggregateSignatureError::SerializationError)?;
181170
match proof_type {
182171
AggregateSignatureType::Concatenation => Ok(AggregateSignature::Concatenation(
183172
ConcatenationProof::from_bytes(proof_bytes)?,

mithril-stm/src/bls_multi_signature/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ mod tests {
9494
use rand_chacha::ChaCha20Rng;
9595
use rand_core::{RngCore, SeedableRng};
9696

97+
use crate::RegisterError;
9798
use crate::bls_multi_signature::helper::unsafe_helpers::{p1_affine_to_sig, p2_affine_to_vk};
9899
use crate::error::MultiSignatureError;
99100
use crate::key_registration::KeyRegistration;
@@ -199,8 +200,8 @@ mod tests {
199200

200201
assert!(
201202
matches!(
202-
error.downcast_ref::<MultiSignatureError>(),
203-
Some(MultiSignatureError::VerificationKeyInfinity(_))
203+
error.downcast_ref::<RegisterError>(),
204+
Some(RegisterError::KeyInvalid(_))
204205
),
205206
"Unexpected error: {error:?}");
206207
}

mithril-stm/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub enum MerkleTreeError {
5858

5959
/// Errors which can be output by Mithril single signature verification.
6060
#[derive(Debug, Clone, thiserror::Error)]
61-
pub enum StmSignatureError {
61+
pub enum SignatureError {
6262
/// There is an index out of bounds
6363
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
6464
IndexBoundFailed(u64, u64),
@@ -89,7 +89,7 @@ pub enum AggregationError {
8989

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

mithril-stm/src/key_registration.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ impl KeyRegistration {
3838
pk: BlsVerificationKeyProofOfPossession,
3939
) -> StmResult<()> {
4040
if let Entry::Vacant(e) = self.keys.entry(pk.vk) {
41-
pk.verify_proof_of_possession()?;
41+
pk.verify_proof_of_possession()
42+
.map_err(|_| RegisterError::KeyInvalid(Box::new(pk)))?;
4243
e.insert(stake);
4344
return Ok(());
4445
}
@@ -141,7 +142,7 @@ mod tests {
141142
assert_eq!(fake_it, 0);
142143
assert!(a.verify_proof_of_possession().is_err());
143144
},
144-
_ => {println!("Unexpected error: {error}")}
145+
_ => {panic!("Unexpected error: {error}")}
145146
}
146147
}
147148
}

0 commit comments

Comments
 (0)