-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add signatures benchmarks (#354)
- Loading branch information
1 parent
335c50f
commit cae87a2
Showing
5 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; | ||
use miden_crypto::dsa::{ | ||
rpo_falcon512::SecretKey as FalconSecretKey, rpo_stark::SecretKey as RpoStarkSecretKey, | ||
}; | ||
use rand_utils::rand_array; | ||
|
||
fn key_gen_falcon(c: &mut Criterion) { | ||
c.bench_function("Falcon public key generation", |bench| { | ||
bench.iter_batched(|| FalconSecretKey::new(), |sk| sk.public_key(), BatchSize::SmallInput) | ||
}); | ||
|
||
c.bench_function("Falcon secret key generation", |bench| { | ||
bench.iter_batched(|| {}, |_| FalconSecretKey::new(), BatchSize::SmallInput) | ||
}); | ||
} | ||
|
||
fn key_gen_rpo_stark(c: &mut Criterion) { | ||
c.bench_function("RPO-STARK public key generation", |bench| { | ||
bench.iter_batched( | ||
|| RpoStarkSecretKey::random(), | ||
|sk| sk.public_key(), | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
|
||
c.bench_function("RPO-STARK secret key generation", |bench| { | ||
bench.iter_batched(|| {}, |_| RpoStarkSecretKey::random(), BatchSize::SmallInput) | ||
}); | ||
} | ||
|
||
fn signature_gen_falcon(c: &mut Criterion) { | ||
c.bench_function("Falcon signature generation", |bench| { | ||
bench.iter_batched( | ||
|| (FalconSecretKey::new(), rand_array().into()), | ||
|(sk, msg)| sk.sign(msg), | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
} | ||
|
||
fn signature_gen_rpo_stark(c: &mut Criterion) { | ||
c.bench_function("RPO-STARK signature generation", |bench| { | ||
bench.iter_batched( | ||
|| (RpoStarkSecretKey::random(), rand_array().into()), | ||
|(sk, msg)| sk.sign(msg), | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
} | ||
|
||
fn signature_ver_falcon(c: &mut Criterion) { | ||
c.bench_function("Falcon signature verification", |bench| { | ||
bench.iter_batched( | ||
|| { | ||
let sk = FalconSecretKey::new(); | ||
let msg = rand_array().into(); | ||
(sk.public_key(), msg, sk.sign(msg)) | ||
}, | ||
|(pk, msg, sig)| pk.verify(msg, &sig), | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
} | ||
|
||
fn signature_ver_rpo_stark(c: &mut Criterion) { | ||
c.bench_function("RPO-STARK signature verification", |bench| { | ||
bench.iter_batched( | ||
|| { | ||
let sk = RpoStarkSecretKey::random(); | ||
let msg = rand_array().into(); | ||
(sk.public_key(), msg, sk.sign(msg)) | ||
}, | ||
|(pk, msg, sig)| pk.verify(msg, &sig), | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
dsa_group, | ||
key_gen_falcon, | ||
key_gen_rpo_stark, | ||
signature_gen_falcon, | ||
signature_gen_rpo_stark, | ||
signature_ver_falcon, | ||
signature_ver_rpo_stark | ||
); | ||
criterion_main!(dsa_group); |