-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abstract benchmarks, add HyperNova & ProtoGalaxy's IVC benchmarks
- Loading branch information
Showing
6 changed files
with
276 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use ark_ec::CurveGroup; | ||
use ark_ff::PrimeField; | ||
use criterion::*; | ||
|
||
use folding_schemes::{ | ||
frontend::{utils::CustomFCircuit, FCircuit}, | ||
Error, FoldingScheme, | ||
}; | ||
|
||
pub(crate) fn bench_ivc_opt< | ||
C1: CurveGroup, | ||
C2: CurveGroup, | ||
FS: FoldingScheme<C1, C2, CustomFCircuit<C1::ScalarField>>, | ||
>( | ||
c: &mut Criterion, | ||
name: String, | ||
n: usize, | ||
prep_param: FS::PreprocessorParam, | ||
) -> Result<(), Error> | ||
where | ||
C1: CurveGroup<BaseField = C2::ScalarField, ScalarField = C2::BaseField>, | ||
C2::BaseField: PrimeField, | ||
{ | ||
let fcircuit_size = 1 << n; // 2^n | ||
|
||
let f_circuit = CustomFCircuit::<C1::ScalarField>::new(fcircuit_size)?; | ||
|
||
let mut rng = rand::rngs::OsRng; | ||
|
||
// prepare the FS prover & verifier params | ||
let fs_params = FS::preprocess(&mut rng, &prep_param)?; | ||
|
||
let z_0 = vec![C1::ScalarField::from(3_u32)]; | ||
let mut fs = FS::init(&fs_params, f_circuit, z_0)?; | ||
|
||
// warmup steps | ||
for _ in 0..5 { | ||
fs.prove_step(rng, vec![], None)?; | ||
} | ||
|
||
let mut group = c.benchmark_group(format!( | ||
"{} - FCircuit: {} (2^{}) constraints", | ||
name, fcircuit_size, n | ||
)); | ||
group.significance_level(0.1).sample_size(10); | ||
group.bench_function("prove_step", |b| { | ||
b.iter(|| black_box(fs.clone()).prove_step(rng, vec![], None).unwrap()) | ||
}); | ||
|
||
// verify the IVCProof | ||
let ivc_proof = fs.ivc_proof(); | ||
group.bench_function("verify", |b| { | ||
b.iter(|| FS::verify(black_box(fs_params.1.clone()), black_box(ivc_proof.clone())).unwrap()) | ||
}); | ||
group.finish(); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use criterion::*; | ||
|
||
use ark_bn254::{constraints::GVar as bn_GVar, Fr as bn_Fr, G1Projective as bn_G}; | ||
use ark_grumpkin::{constraints::GVar as grumpkin_GVar, Projective as grumpkin_G}; | ||
use ark_pallas::{constraints::GVar as pallas_GVar, Fr as pallas_Fr, Projective as pallas_G}; | ||
use ark_vesta::{constraints::GVar as vesta_GVar, Projective as vesta_G}; | ||
|
||
use folding_schemes::{ | ||
commitment::pedersen::Pedersen, | ||
folding::{hypernova::HyperNova, nova::PreprocessorParam}, | ||
frontend::{utils::CustomFCircuit, FCircuit}, | ||
transcript::poseidon::poseidon_canonical_config, | ||
}; | ||
|
||
mod common; | ||
use common::bench_ivc_opt; | ||
|
||
fn bench_hypernova_ivc(c: &mut Criterion) { | ||
let poseidon_config = poseidon_canonical_config::<pallas_Fr>(); | ||
|
||
// iterate over the powers of n | ||
for n in [0_usize, 14, 16, 18, 19, 20, 21, 22].iter() { | ||
let fcircuit_size = 1 << n; // 2^n | ||
let fcircuit = CustomFCircuit::<pallas_Fr>::new(fcircuit_size).unwrap(); | ||
let prep_param = PreprocessorParam::new(poseidon_config.clone(), fcircuit); | ||
|
||
bench_ivc_opt::< | ||
pallas_G, | ||
vesta_G, | ||
HyperNova< | ||
pallas_G, | ||
pallas_GVar, | ||
vesta_G, | ||
vesta_GVar, | ||
CustomFCircuit<pallas_Fr>, | ||
Pedersen<pallas_G>, | ||
Pedersen<vesta_G>, | ||
1, | ||
1, | ||
false, | ||
>, | ||
>( | ||
c, | ||
"HyperNova - Pallas-Vesta curves".to_string(), | ||
*n, | ||
prep_param, | ||
) | ||
.unwrap(); | ||
} | ||
|
||
let poseidon_config = poseidon_canonical_config::<bn_Fr>(); | ||
for n in [0_usize, 14, 16, 18, 19, 20, 21, 22].iter() { | ||
let fcircuit_size = 1 << n; // 2^n | ||
let fcircuit = CustomFCircuit::<bn_Fr>::new(fcircuit_size).unwrap(); | ||
let prep_param = PreprocessorParam::new(poseidon_config.clone(), fcircuit); | ||
|
||
bench_ivc_opt::< | ||
bn_G, | ||
grumpkin_G, | ||
HyperNova< | ||
bn_G, | ||
bn_GVar, | ||
grumpkin_G, | ||
grumpkin_GVar, | ||
CustomFCircuit<bn_Fr>, | ||
Pedersen<bn_G>, | ||
Pedersen<grumpkin_G>, | ||
1, | ||
1, | ||
false, | ||
>, | ||
>( | ||
c, | ||
"HyperNova - BN254-Grumpkin curves".to_string(), | ||
*n, | ||
prep_param, | ||
) | ||
.unwrap(); | ||
} | ||
} | ||
|
||
criterion_group!(benches, bench_hypernova_ivc); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use criterion::*; | ||
|
||
use ark_bn254::{constraints::GVar as bn_GVar, Fr as bn_Fr, G1Projective as bn_G}; | ||
use ark_grumpkin::{constraints::GVar as grumpkin_GVar, Projective as grumpkin_G}; | ||
use ark_pallas::{constraints::GVar as pallas_GVar, Fr as pallas_Fr, Projective as pallas_G}; | ||
use ark_vesta::{constraints::GVar as vesta_GVar, Projective as vesta_G}; | ||
|
||
use folding_schemes::{ | ||
commitment::pedersen::Pedersen, | ||
folding::protogalaxy::ProtoGalaxy, | ||
frontend::{utils::CustomFCircuit, FCircuit}, | ||
transcript::poseidon::poseidon_canonical_config, | ||
}; | ||
|
||
mod common; | ||
use common::bench_ivc_opt; | ||
|
||
fn bench_protogalaxy_ivc(c: &mut Criterion) { | ||
let poseidon_config = poseidon_canonical_config::<pallas_Fr>(); | ||
|
||
// iterate over the powers of n | ||
for n in [0_usize, 14, 16, 18, 19, 20, 21, 22].iter() { | ||
let fcircuit_size = 1 << n; // 2^n | ||
let fcircuit = CustomFCircuit::<pallas_Fr>::new(fcircuit_size).unwrap(); | ||
let prep_param = (poseidon_config.clone(), fcircuit); | ||
|
||
bench_ivc_opt::< | ||
pallas_G, | ||
vesta_G, | ||
ProtoGalaxy< | ||
pallas_G, | ||
pallas_GVar, | ||
vesta_G, | ||
vesta_GVar, | ||
CustomFCircuit<pallas_Fr>, | ||
Pedersen<pallas_G>, | ||
Pedersen<vesta_G>, | ||
>, | ||
>( | ||
c, | ||
"ProtoGalaxy - Pallas-Vesta curves".to_string(), | ||
*n, | ||
prep_param, | ||
) | ||
.unwrap(); | ||
} | ||
|
||
let poseidon_config = poseidon_canonical_config::<bn_Fr>(); | ||
for n in [0_usize, 14, 16, 18, 19, 20, 21, 22].iter() { | ||
let fcircuit_size = 1 << n; // 2^n | ||
let fcircuit = CustomFCircuit::<bn_Fr>::new(fcircuit_size).unwrap(); | ||
let prep_param = (poseidon_config.clone(), fcircuit); | ||
|
||
bench_ivc_opt::< | ||
bn_G, | ||
grumpkin_G, | ||
ProtoGalaxy< | ||
bn_G, | ||
bn_GVar, | ||
grumpkin_G, | ||
grumpkin_GVar, | ||
CustomFCircuit<bn_Fr>, | ||
Pedersen<bn_G>, | ||
Pedersen<grumpkin_G>, | ||
>, | ||
>( | ||
c, | ||
"ProtoGalaxy - BN254-Grumpkin curves".to_string(), | ||
*n, | ||
prep_param, | ||
) | ||
.unwrap(); | ||
} | ||
} | ||
|
||
criterion_group!(benches, bench_protogalaxy_ivc); | ||
criterion_main!(benches); |
Oops, something went wrong.