Skip to content

Commit e981167

Browse files
curiecryptiquerejeta
authored andcommitted
size_benches runs with paper parameters
1 parent e84a161 commit e981167

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

mithril-common/src/crypto_helper/cardano/key_certification.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use mithril::key_reg::{ClosedKeyReg, KeyReg};
1313
use mithril::stm::{Stake, StmInitializer, StmParameters, StmSigner, StmVerificationKeyPoP};
1414
use mithril::RegisterError;
1515

16+
use blake2::digest::FixedOutput;
1617
use blake2::{digest::consts::U32, Blake2b, Digest};
1718
use kes_summed_ed25519::kes::{Sum6Kes, Sum6KesSig};
1819
use kes_summed_ed25519::traits::{KesSig, KesSk};
@@ -255,7 +256,7 @@ impl KeyRegWrapper {
255256

256257
/// Finalize the key registration.
257258
/// This function disables `KeyReg::register`, consumes the instance of `self`, and returns a `ClosedKeyReg`.
258-
pub fn close<D: Digest>(self) -> ClosedKeyReg<D> {
259+
pub fn close<D: Digest + FixedOutput>(self) -> ClosedKeyReg<D> {
259260
self.stm_key_reg.close()
260261
}
261262
}

mithril-core/benches/size_benches.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use mithril::key_reg::KeyReg;
77
use mithril::stm::{StmClerk, StmInitializer, StmParameters, StmSig, StmSigner};
88
use rand_chacha::ChaCha20Rng;
99
use rand_core::{RngCore, SeedableRng};
10-
use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator};
1110
use rayon::iter::ParallelIterator;
11+
use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator};
1212

13-
fn size<H>(k: u64, nparties: usize, hash_name: &str)
13+
fn size<H>(k: u64, m: u64, nparties: usize, hash_name: &str)
1414
where
1515
H: Digest + Clone + Sync + Send + Default + FixedOutput,
1616
{
@@ -30,8 +30,8 @@ where
3030
let params = StmParameters {
3131
k,
3232
// m equal to one, to get an upper bound were a signer can only submit a single signature
33-
m: 1,
34-
phi_f: 1.0,
33+
m,
34+
phi_f: 0.2,
3535
};
3636

3737
let mut key_reg = KeyReg::init();
@@ -43,7 +43,6 @@ where
4343

4444
let closed_reg = key_reg.close::<H>();
4545

46-
4746
let ps = ps
4847
.into_par_iter()
4948
.map(|p| p.new_signer(closed_reg.clone()).unwrap())
@@ -62,7 +61,7 @@ where
6261
let sig = sigs[0].clone();
6362

6463
println!(
65-
"k = {} | nr parties = {}; single signature {} bytes | aggregate signature {} bytes",
64+
"k = {} | nr parties = {}; total size of single signatures {} bytes | aggregate signature {} bytes",
6665
k,
6766
nparties,
6867
sig.to_bytes().len() * k as usize,
@@ -83,9 +82,9 @@ fn main() {
8382
println!("| This gives and upper bound of the size\n| as it assumes that at most one signature\n| is provided by each participant.");
8483
println!("+-------------------+");
8584

86-
let params: [(u64, usize); 2] = [(25, 300), (250, 2000)];
87-
for (k, nparties) in params {
88-
size::<Blake2b<U64>>(k, nparties, "Blake2b 512");
89-
size::<Blake2b<U32>>(k, nparties, "Blake2b 256");
85+
let params: [(u64, u64, usize); 2] = [(445, 2728, 3000), (554, 3597, 3000)];
86+
for (k, m, nparties) in params {
87+
size::<Blake2b<U64>>(k, m, nparties, "Blake2b 512");
88+
size::<Blake2b<U32>>(k, m, nparties, "Blake2b 256");
9089
}
9190
}

mithril-core/src/stm.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub struct StmAggrVerificationKey<D: Clone + Digest + FixedOutput> {
221221

222222
/// `StmMultiSig` uses the "concatenation" proving system (as described in Section 4.3 of the original paper.)
223223
/// This means that the aggregated signature contains a vector with all individual signatures.
224-
/// BatchPath is added as `Option` for batch compatibility.
224+
/// BatchPath is also a part of the aggregate signature which covers path for all signatures.
225225
#[derive(Debug, Clone, Serialize, Deserialize)]
226226
#[serde(bound(
227227
serialize = "BatchPath<D>: Serialize",
@@ -363,13 +363,10 @@ impl<D: Clone + Digest + FixedOutput> StmSigner<D> {
363363
/// Once the signature is produced, this function checks whether any index in `[0,..,self.params.m]`
364364
/// wins the lottery by evaluating the dense mapping.
365365
/// It records all the winning indexes in `Self.indexes`.
366-
/// The difference between `sign` and `sign` is that if it wins at least one lottery,
366+
/// If it wins at least one lottery,
367367
/// it does not produce a list of indexes of merkle path for its corresponding `(VerificationKey, Stake)`.
368368
/// Instead it stores the signer's merkle tree index and the merkle path production will be handled in `StmClerk`.
369-
pub fn sign(&self, msg: &[u8]) -> Option<StmSig<D>>
370-
where
371-
D: Default,
372-
{
369+
pub fn sign(&self, msg: &[u8]) -> Option<StmSig<D>> {
373370
let msgp = self
374371
.closed_reg
375372
.merkle_tree
@@ -611,7 +608,7 @@ impl<D: Clone + Digest + FixedOutput> StmSig<D> {
611608
/// Extract a batch compatible `StmSig` from a byte slice.
612609
pub fn from_bytes(bytes: &[u8]) -> Result<StmSig<D>, StmSignatureError<D>>
613610
where
614-
D: Default + FixedOutput,
611+
D: Default,
615612
{
616613
let mut u64_bytes = [0u8; 8];
617614

@@ -772,7 +769,7 @@ impl<D: Clone + Digest + FixedOutput> StmAggrSig<D> {
772769
out
773770
}
774771

775-
///Extract a `StmMultiSig` from a byte slice.
772+
///Extract a `StmAggrSig` from a byte slice.
776773
pub fn from_bytes(bytes: &[u8]) -> Result<StmAggrSig<D>, StmSignatureError<D>>
777774
where
778775
D: Default,

0 commit comments

Comments
 (0)