Skip to content

Commit

Permalink
Fix benches
Browse files Browse the repository at this point in the history
  • Loading branch information
vlopes11 committed Jun 8, 2022
1 parent c4c4511 commit da63faf
Showing 1 changed file with 49 additions and 19 deletions.
68 changes: 49 additions & 19 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use ark_bls12_381::{Bls12_381, Fq as BlsFq, Fr as BlsFr};
use ark_ff::PrimeField;
use ark_marlin::fiat_shamir::FiatShamirChaChaRng;
use ark_marlin::Marlin;
use ark_marlin::MarlinDefaultConfig;
use ark_marlin::{Marlin, MarlinDefaultConfig, FiatShamirRng};
use ark_mnt4_298::{Fq as MNT4Fq, Fr as MNT4Fr, MNT4_298};
use ark_mnt4_753::{Fq as MNT4BigFq, Fr as MNT4BigFr, MNT4_753};
use ark_mnt6_298::{Fq as MNT6Fq, Fr as MNT6Fr, MNT6_298};
Expand All @@ -17,8 +15,8 @@ use ark_relations::{
lc,
r1cs::{ConstraintSynthesizer, ConstraintSystemRef, SynthesisError},
};
use ark_sponge::poseidon::PoseidonSponge;
use ark_std::{ops::Mul, UniformRand};
use blake2::Blake2s;

const NUM_PROVE_REPEATITIONS: usize = 10;
const NUM_VERIFY_REPEATITIONS: usize = 50;
Expand Down Expand Up @@ -80,16 +78,24 @@ macro_rules! marlin_prove_bench {
let srs = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::universal_setup(65536, 65536, 65536, rng)
.unwrap();
let (pk, _) = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::index(&srs, c)
.unwrap();
Expand All @@ -100,8 +106,12 @@ macro_rules! marlin_prove_bench {
let _ = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::prove(&pk, c.clone(), rng)
.unwrap();
Expand All @@ -128,24 +138,36 @@ macro_rules! marlin_verify_bench {
let srs = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::universal_setup(65536, 65536, 65536, rng)
.unwrap();
let (pk, vk) = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::index(&srs, c)
.unwrap();
let proof = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::prove(&pk, c.clone(), rng)
.unwrap();
Expand All @@ -155,13 +177,21 @@ macro_rules! marlin_verify_bench {
let start = ark_std::time::Instant::now();

for _ in 0..NUM_VERIFY_REPEATITIONS {
// TODO define a rate
let rate = 4;
let mut rng: FiatShamirRng<$bench_field, $base_field, PoseidonSponge<$base_field>> = FiatShamirRng::new(rate);

let _ = Marlin::<
$bench_field,
$base_field,
MarlinKZG10<$bench_pairing_engine, DensePolynomial<$bench_field>>,
FiatShamirChaChaRng<$bench_field, $base_field, Blake2s>,
PoseidonSponge<$base_field>,
MarlinKZG10<
$bench_pairing_engine,
DensePolynomial<$bench_field>,
PoseidonSponge<$base_field>,
>,
MarlinDefaultConfig,
>::verify(&vk, &vec![v], &proof)
>::verify(&vk, &vec![v], &proof, Some(&mut rng))
.unwrap();
}

Expand Down

0 comments on commit da63faf

Please sign in to comment.