aboutsummaryrefslogtreecommitdiff
path: root/benches/bbg.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-12-06 14:06:55 +0100
committerDaniel Schadt <kingdread@gmx.de>2023-12-06 14:06:55 +0100
commite3189454dd22ccd724b8caba6e49f3fae963292e (patch)
tree4773f5c8e7ea4d3980d65ffd34935754ba36facb /benches/bbg.rs
parent9925eb2b22d6a4da3b6dcb0effbc5eb014d9cb0d (diff)
downloadhohibe-e3189454dd22ccd724b8caba6e49f3fae963292e.tar.gz
hohibe-e3189454dd22ccd724b8caba6e49f3fae963292e.tar.bz2
hohibe-e3189454dd22ccd724b8caba6e49f3fae963292e.zip
add first benchmarks for bbgHEADmaster
Diffstat (limited to 'benches/bbg.rs')
-rw-r--r--benches/bbg.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/benches/bbg.rs b/benches/bbg.rs
new file mode 100644
index 0000000..dfc1e6c
--- /dev/null
+++ b/benches/bbg.rs
@@ -0,0 +1,41 @@
+use criterion::{criterion_group, criterion_main, Criterion};
+use rand::{Rng, SeedableRng};
+use rand_chacha::ChaChaRng;
+
+use hohibe::hibe::{Hibe, BonehBoyenGoh};
+
+fn rng() -> impl Rng {
+ ChaChaRng::from_seed([0; 32])
+}
+
+fn setup(c: &mut Criterion) {
+ let mut rng = rng();
+ let bbg = BonehBoyenGoh::new(32);
+ c.bench_function("BonehBoyenGoh::setup(32)", |b| {
+ b.iter(|| bbg.setup(&mut rng));
+ });
+}
+
+fn generate_key(c: &mut Criterion) {
+ let mut rng = rng();
+ let bbg = BonehBoyenGoh::new(32);
+ let identity = &[0u32.into(), 1u32.into(), 2u32.into()];
+ let (public_key, master_key) = bbg.setup(&mut rng).unwrap();
+ c.bench_function("BonehBoyenGoh::generate_key(32)", |b| {
+ b.iter(|| bbg.generate_key(&mut rng, &public_key, &master_key, identity).unwrap());
+ });
+}
+
+fn derive_key(c: &mut Criterion) {
+ let mut rng = rng();
+ let bbg = BonehBoyenGoh::new(32);
+ let identity = &[0u32.into(), 1u32.into(), 2u32.into()];
+ let (public_key, master_key) = bbg.setup(&mut rng).unwrap();
+ let key = bbg.generate_key(&mut rng, &public_key, &master_key, identity).unwrap();
+ c.bench_function("BonehBoyenGoh::derive_key(32)", |b| {
+ b.iter(|| bbg.derive_key(&mut rng, &public_key, &key, identity, &3u32.into()).unwrap());
+ });
+}
+
+criterion_group!(benches, setup, generate_key, derive_key);
+criterion_main!(benches);