Browse Source

Add basic benchmarks for the prover

pull/1/head
George Kadianakis 11 months ago
parent
commit
89d9528a01
3 changed files with 42 additions and 2 deletions
  1. +6
    -0
      Cargo.toml
  2. +36
    -0
      benches/bench_prove.rs
  3. +0
    -2
      src/transcript.rs

+ 6
- 0
Cargo.toml

@ -18,6 +18,12 @@ ark-relations = { version = "^0.4.0", default-features = false }
ark-snark = { version = "^0.4.0", default-features = false } ark-snark = { version = "^0.4.0", default-features = false }
ark-groth16 = { version = "^0.4.0" } ark-groth16 = { version = "^0.4.0" }
thiserror = "1.0" thiserror = "1.0"
criterion = "0.5.1"
ark-curve25519 = "0.4.0"
[dev-dependencies] [dev-dependencies]
ark-bn254 = "0.4.0" ark-bn254 = "0.4.0"
[[bench]]
harness = false
name = "bench_prove"

+ 36
- 0
benches/bench_prove.rs

@ -0,0 +1,36 @@
use ark_std::UniformRand;
use sigmabus_poc::transcript::{tests::poseidon_test_config, PoseidonTranscript};
use criterion::{criterion_group, criterion_main, Criterion};
use ark_bn254::{Bn254, Fr, G1Projective};
use ark_std::rand::{RngCore, SeedableRng};
use ark_std::test_rng;
use sigmabus_poc::sigmabus::Sigmabus;
fn bench_prove(c: &mut Criterion) {
let mut rng = ark_std::rand::rngs::StdRng::seed_from_u64(test_rng().next_u64());
let poseidon_config = poseidon_test_config::<Fr>();
// generate the trusted setup
let params = Sigmabus::<Bn254>::setup(&mut rng, &poseidon_config);
// compute the witness x
let x = Fr::rand(&mut rng);
let mut transcript_p = PoseidonTranscript::<G1Projective>::new(&poseidon_config);
// generate Sigmabus proof for X==x*G
c.bench_function("prove", |b| {
b.iter(|| {
let _proof = Sigmabus::<Bn254>::prove(&mut rng, &params, &mut transcript_p, x).unwrap();
});
});
}
criterion_group! {
name=prover_benches;
config=Criterion::default();
targets=
bench_prove,
}
criterion_main!(prover_benches);

+ 0
- 2
src/transcript.rs

@ -56,13 +56,11 @@ fn prepare_point(p: &C) -> Vec {
] ]
} }
#[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds; use ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds;
/// WARNING the method poseidon_test_config is for tests only /// WARNING the method poseidon_test_config is for tests only
#[cfg(test)]
pub fn poseidon_test_config<F: PrimeField>() -> PoseidonConfig<F> { pub fn poseidon_test_config<F: PrimeField>() -> PoseidonConfig<F> {
let full_rounds = 8; let full_rounds = 8;
let partial_rounds = 31; let partial_rounds = 31;

Loading…
Cancel
Save