Skip to content

Commit

Permalink
Bump versions and misc tweaks (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush authored Oct 15, 2023
1 parent 10c72a9 commit c7e8ade
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ark-groth16"
version = "0.3.0"
version = "0.4.0"
authors = [ "arkworks contributors" ]
description = "An implementation of the Groth 2016 zkSNARK proof system"
homepage = "https://arkworks.rs"
Expand Down
25 changes: 16 additions & 9 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ use ark_relations::{
};
use ark_std::ops::Mul;

const NUM_PROVE_REPEATITIONS: usize = 10;
const NUM_VERIFY_REPEATITIONS: usize = 50;
const NUM_PROVE_REPETITIONS: usize = 1;
const NUM_VERIFY_REPETITIONS: usize = 50;
const NUM_CONSTRAINTS: usize = (1 << 20) - 100;
const NUM_VARIABLES: usize = (1 << 20) - 100;

#[derive(Copy)]
struct DummyCircuit<F: PrimeField> {
Expand Down Expand Up @@ -69,22 +71,27 @@ macro_rules! groth16_prove_bench {
let c = DummyCircuit::<$bench_field> {
a: Some(<$bench_field>::rand(rng)),
b: Some(<$bench_field>::rand(rng)),
num_variables: 10,
num_constraints: 65536,
num_variables: NUM_VARIABLES,
num_constraints: NUM_CONSTRAINTS,
};

let (pk, _) = Groth16::<$bench_pairing_engine>::circuit_specific_setup(c, rng).unwrap();

let start = ark_std::time::Instant::now();

for _ in 0..NUM_PROVE_REPEATITIONS {
for _ in 0..NUM_PROVE_REPETITIONS {
let _ = Groth16::<$bench_pairing_engine>::prove(&pk, c.clone(), rng).unwrap();
}

println!(
"per-constraint proving time for {}: {} ns/constraint",
stringify!($bench_pairing_engine),
start.elapsed().as_nanos() / NUM_PROVE_REPEATITIONS as u128 / 65536u128
start.elapsed().as_nanos() / (NUM_PROVE_REPETITIONS as u128 * NUM_CONSTRAINTS as u128)
);
println!(
"wall-clock proving time for {}: {} s",
stringify!($bench_pairing_engine),
start.elapsed().as_secs_f64() / NUM_PROVE_REPETITIONS as f64
);
};
}
Expand All @@ -96,7 +103,7 @@ macro_rules! groth16_verify_bench {
a: Some(<$bench_field>::rand(rng)),
b: Some(<$bench_field>::rand(rng)),
num_variables: 10,
num_constraints: 65536,
num_constraints: NUM_CONSTRAINTS,
};

let (pk, vk) = Groth16::<$bench_pairing_engine>::circuit_specific_setup(c, rng).unwrap();
Expand All @@ -106,14 +113,14 @@ macro_rules! groth16_verify_bench {

let start = ark_std::time::Instant::now();

for _ in 0..NUM_VERIFY_REPEATITIONS {
for _ in 0..NUM_VERIFY_REPETITIONS {
let _ = Groth16::<$bench_pairing_engine>::verify(&vk, &vec![v], &proof).unwrap();
}

println!(
"verifying time for {}: {} ns",
stringify!($bench_pairing_engine),
start.elapsed().as_nanos() / NUM_VERIFY_REPEATITIONS as u128
start.elapsed().as_nanos() / NUM_VERIFY_REPETITIONS as u128
);
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP> {
end_timer!(g2_time);

// Compute the B-query in G2
let b_g2_time = start_timer!(|| "Calculate B G2");
let b_g2_time = start_timer!(|| format!("Calculate B G2 of size {}", b.len()));
let b_g2_query = FixedBase::msm::<E::G2>(scalar_bits, g2_window, &g2_table, &b);
drop(g2_table);
end_timer!(b_g2_time);
Expand Down
2 changes: 1 addition & 1 deletion src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP> {
let h_assignment = cfg_into_iter!(h)
.map(|s| s.into_bigint())
.collect::<Vec<_>>();
let h_acc = E::G1::msm_bigint(&pk.h_query, &h_assignment);
let h_acc = E::G1::msm_bigint(&pk.h_query, &h_assignment[..h_assignment.len() - 1]);
drop(h_assignment);

// Compute C
Expand Down

0 comments on commit c7e8ade

Please sign in to comment.