diff --git a/Cargo.toml b/Cargo.toml index f12ac9a..a4b78c8 100644 --- a/Cargo.toml +++ b/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-groth16 = { version = "^0.4.0" } thiserror = "1.0" +criterion = "0.5.1" +ark-curve25519 = "0.4.0" [dev-dependencies] ark-bn254 = "0.4.0" + +[[bench]] +harness = false +name = "bench_prove" diff --git a/benches/bench_prove.rs b/benches/bench_prove.rs new file mode 100644 index 0000000..64de5b4 --- /dev/null +++ b/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::(); + + // generate the trusted setup + let params = Sigmabus::::setup(&mut rng, &poseidon_config); + + // compute the witness x + let x = Fr::rand(&mut rng); + + let mut transcript_p = PoseidonTranscript::::new(&poseidon_config); + + // generate Sigmabus proof for X==x*G + c.bench_function("prove", |b| { + b.iter(|| { + let _proof = Sigmabus::::prove(&mut rng, ¶ms, &mut transcript_p, x).unwrap(); + }); + }); +} + +criterion_group! { + name=prover_benches; + config=Criterion::default(); + targets= + bench_prove, +} +criterion_main!(prover_benches); diff --git a/src/transcript.rs b/src/transcript.rs index 84db8b7..cdca77c 100644 --- a/src/transcript.rs +++ b/src/transcript.rs @@ -56,13 +56,11 @@ fn prepare_point(p: &C) -> Vec { ] } -#[cfg(test)] pub mod tests { use super::*; use ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds; /// WARNING the method poseidon_test_config is for tests only - #[cfg(test)] pub fn poseidon_test_config() -> PoseidonConfig { let full_rounds = 8; let partial_rounds = 31;