Skip to content

Commit abf2fa3

Browse files
committed
chore(stm): apply review comments
1 parent c563417 commit abf2fa3

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

mithril-stm/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ use rand_chacha::ChaCha20Rng;
6767
use rand_core::{RngCore, SeedableRng};
6868
use rayon::prelude::*;
6969

70-
use mithril_stm::{Clerk, Parameters, SingleSignature, KeyRegistration, Initializer, Signer, AggregationError};
70+
use mithril_stm::{
71+
AggregateSignatureType, AggregationError, Clerk, Initializer, KeyRegistration, Parameters,
72+
Signer, SingleSignature,
73+
};
7174

7275
type H = Blake2b<U32>;
7376

@@ -125,8 +128,8 @@ for (s, p) in sigs.iter().zip(ps.iter()) {
125128
failed");
126129
}
127130

128-
// Aggregate with random parties
129-
let msig = clerk.aggregate_signatures(&sigs, &msg);
131+
// Aggregate a concatenation proof with random parties
132+
let msig = clerk.aggregate_signatures_with_type(&sigs, &msg, AggregateSignatureType::Concatenation);
130133

131134
match msig {
132135
Ok(aggr) => {

mithril-stm/src/aggregate_signature/mod.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ mod tests {
2626

2727
use crate::merkle_tree::MerkleBatchPath;
2828
use crate::{
29-
AggregateSignature, AggregationError, BasicVerifier, Clerk, CoreVerifierError, Initializer,
30-
KeyRegistration, Parameters, Signer, SingleSignature, SingleSignatureWithRegisteredParty,
31-
Stake,
29+
AggregateSignature, AggregateSignatureType, AggregationError, BasicVerifier, Clerk,
30+
CoreVerifierError, Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
31+
SingleSignatureWithRegisteredParty, Stake, bls_multi_signature::BlsVerificationKey,
3232
};
33-
use crate::{AggregateSignatureType, bls_multi_signature::BlsVerificationKey};
3433

3534
type Sig = AggregateSignature<D>;
3635
type D = Blake2b<U32>;
@@ -459,36 +458,32 @@ mod tests {
459458
#[test]
460459
fn test_invalid_proof_index_unique(tc in arb_proof_setup(10)) {
461460
with_proof_mod(tc, |aggr, clerk, _msg| {
462-
if let AggregateSignature::Concatenation(concatenation_proof) = aggr {
463-
for sig_reg in concatenation_proof.signatures.iter_mut() {
464-
for index in sig_reg.sig.indexes.iter_mut() {
465-
*index %= clerk.params.k - 1
466-
}
461+
let mut concatenation_proof = AggregateSignature::to_concatenation_proof(aggr).unwrap().to_owned();
462+
for sig_reg in concatenation_proof.signatures.iter_mut() {
463+
for index in sig_reg.sig.indexes.iter_mut() {
464+
*index %= clerk.params.k - 1
467465
}
468-
}else{
469-
panic!("Unexpected aggregate signature type");
470466
}
467+
*aggr = AggregateSignature::Concatenation(concatenation_proof);
471468
})
472469
}
473470
#[test]
474471
fn test_invalid_proof_path(tc in arb_proof_setup(10)) {
475472
with_proof_mod(tc, |aggr, _, _msg| {
476-
if let AggregateSignature::Concatenation(concatenation_proof) = aggr {
477-
let p = concatenation_proof.batch_proof.clone();
478-
let mut index_list = p.indices.clone();
479-
let values = p.values;
480-
let batch_proof = {
481-
index_list[0] += 1;
482-
MerkleBatchPath {
483-
values,
484-
indices: index_list,
485-
hasher: Default::default()
486-
}
487-
};
488-
concatenation_proof.batch_proof = batch_proof;
489-
}else{
490-
panic!("Unexpected aggregate signature type");
491-
}
473+
let mut concatenation_proof = AggregateSignature::to_concatenation_proof(aggr).unwrap().to_owned();
474+
let p = concatenation_proof.batch_proof.clone();
475+
let mut index_list = p.indices.clone();
476+
let values = p.values;
477+
let batch_proof = {
478+
index_list[0] += 1;
479+
MerkleBatchPath {
480+
values,
481+
indices: index_list,
482+
hasher: Default::default()
483+
}
484+
};
485+
concatenation_proof.batch_proof = batch_proof;
486+
*aggr = AggregateSignature::Concatenation(concatenation_proof);
492487
})
493488
}
494489
}

mithril-stm/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
//! use rand_core::{RngCore, SeedableRng};
1414
//! use rayon::prelude::*; // We use par_iter to speed things up
1515
//!
16-
//! use mithril_stm::{Clerk, Parameters, SingleSignature, KeyRegistration, Initializer, Signer, AggregationError};
16+
//! use mithril_stm::{
17+
//! AggregateSignatureType, AggregationError, Clerk, Initializer, KeyRegistration, Parameters,
18+
//! Signer, SingleSignature,
19+
//! };
1720
//!
1821
//! let nparties = 4; // Use a small number of parties for this example
1922
//! type D = Blake2b<U32>; // Setting the hash function for convenience

0 commit comments

Comments
 (0)