Skip to content

Commit

Permalink
Add benchmarks for sign_recoverable (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-lj authored Feb 9, 2023
1 parent 65f569b commit 375ab9c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fastcrypto/benches/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,27 @@ mod signature_benches {
c.bench_function(&(name.to_string()), move |b| b.iter(|| keypair.sign(msg)));
}

fn sign_recoverable_single<KP: KeyPair + RecoverableSigner, M: measurement::Measurement>(
name: &str,
c: &mut BenchmarkGroup<M>,
) {
let msg: &[u8] = b"";
let mut csprng: ThreadRng = thread_rng();
let keypair = KP::generate(&mut csprng);
c.bench_function(&(name.to_string()), move |b| {
b.iter(|| keypair.sign_recoverable(msg))
});
}

fn sign(c: &mut Criterion) {
let mut group: BenchmarkGroup<_> = c.benchmark_group("Sign");
sign_single::<Ed25519KeyPair, _>("Ed25519", &mut group);
sign_single::<bls12381::min_sig::BLS12381KeyPair, _>("BLS12381MinSig", &mut group);
sign_single::<bls12381::min_pk::BLS12381KeyPair, _>("BLS12381MinPk", &mut group);
sign_single::<Secp256k1KeyPair, _>("Secp256k1", &mut group);
sign_single::<Secp256r1KeyPair, _>("Secp256r1", &mut group);
sign_recoverable_single::<Secp256k1KeyPair, _>("Secp256k1 recoverable", &mut group);
sign_recoverable_single::<Secp256r1KeyPair, _>("Secp256r1 recoverable", &mut group);
}

fn verify_single<KP: KeyPair, M: measurement::Measurement>(
Expand Down

0 comments on commit 375ab9c

Please sign in to comment.