aboutsummaryrefslogtreecommitdiff
path: root/benches/bbg.rs
diff options
context:
space:
mode:
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);