-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
one benchmarking for orion over GF2 evaluated over GF2ext128
- Loading branch information
1 parent
22d3f11
commit 18e7aa7
Showing
4 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,128 @@ | ||
use std::{hint::black_box, ops::Mul, time::Duration}; | ||
|
||
use arith::{Field, FieldSerde, SimdField}; | ||
use ark_std::test_rng; | ||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; | ||
use gf2::{GF2x128, GF2x64, GF2}; | ||
use gf2_128::GF2_128; | ||
use pcs::{OrionPCS, OrionPCSSetup, PolynomialCommitmentScheme, ORION_CODE_PARAMETER_INSTANCE}; | ||
use polynomials::MultiLinearPoly; | ||
use transcript::{BytesHashTranscript, Keccak256hasher, Transcript}; | ||
use tynm::type_name; | ||
|
||
fn committing_benchmark_helper<F, PackF, EvalF, T>( | ||
c: &mut Criterion, | ||
lowest_num_vars: usize, | ||
highest_num_vars: usize, | ||
) where | ||
F: Field + FieldSerde, | ||
PackF: SimdField<Scalar = F>, | ||
EvalF: Field + FieldSerde + From<F> + Mul<F, Output = EvalF>, | ||
T: Transcript<EvalF>, | ||
{ | ||
let mut group = c.benchmark_group(format!( | ||
"Orion PCS committing benchmarking: F = {}, PackF = {}", | ||
type_name::<F>(), | ||
type_name::<PackF>(), | ||
)); | ||
|
||
let mut rng = test_rng(); | ||
|
||
for num_vars in lowest_num_vars..=highest_num_vars { | ||
let random_poly = MultiLinearPoly::<F>::random(num_vars, &mut rng); | ||
|
||
let orion_pp = OrionPCS::<F, PackF, EvalF, T>::gen_srs_for_testing( | ||
&mut rng, | ||
&OrionPCSSetup { | ||
num_vars, | ||
code_parameter: ORION_CODE_PARAMETER_INSTANCE, | ||
}, | ||
); | ||
|
||
group | ||
.bench_function( | ||
BenchmarkId::new(format!("{num_vars} variables"), num_vars), | ||
|b| { | ||
b.iter(|| { | ||
_ = black_box(OrionPCS::<F, PackF, EvalF, T>::commit( | ||
&orion_pp, | ||
&random_poly, | ||
)) | ||
}) | ||
}, | ||
) | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(30)); | ||
} | ||
} | ||
|
||
fn orion_committing_benchmark(c: &mut Criterion) { | ||
committing_benchmark_helper::<GF2, GF2x128, GF2_128, BytesHashTranscript<_, Keccak256hasher>>( | ||
c, 19, 25, | ||
) | ||
} | ||
|
||
fn opening_benchmark_helper<F, PackF, EvalF, T>( | ||
c: &mut Criterion, | ||
lowest_num_vars: usize, | ||
highest_num_vars: usize, | ||
) where | ||
F: Field + FieldSerde, | ||
PackF: SimdField<Scalar = F>, | ||
EvalF: Field + FieldSerde + From<F> + Mul<F, Output = EvalF>, | ||
T: Transcript<EvalF>, | ||
{ | ||
let mut group = c.benchmark_group(format!( | ||
"Orion PCS opening benchmarking: F = {}, EvalF = {}, PackF = {}", | ||
type_name::<F>(), | ||
type_name::<EvalF>(), | ||
type_name::<PackF>(), | ||
)); | ||
|
||
let mut rng = test_rng(); | ||
let mut transcript = T::new(); | ||
|
||
for num_vars in lowest_num_vars..=highest_num_vars { | ||
let random_poly = MultiLinearPoly::<F>::random(num_vars, &mut rng); | ||
let random_point: Vec<_> = (0..num_vars) | ||
.map(|_| EvalF::random_unsafe(&mut rng)) | ||
.collect(); | ||
|
||
let orion_pp = OrionPCS::<F, PackF, EvalF, T>::gen_srs_for_testing( | ||
&mut rng, | ||
&OrionPCSSetup { | ||
num_vars, | ||
code_parameter: ORION_CODE_PARAMETER_INSTANCE, | ||
}, | ||
); | ||
|
||
let commitment_with_data = OrionPCS::<F, PackF, EvalF, T>::commit(&orion_pp, &random_poly); | ||
|
||
group | ||
.bench_function( | ||
BenchmarkId::new(format!("{num_vars} variables"), num_vars), | ||
|b| { | ||
b.iter(|| { | ||
_ = black_box(OrionPCS::<F, PackF, EvalF, T>::open( | ||
&orion_pp, | ||
&random_poly, | ||
&random_point, | ||
&commitment_with_data, | ||
&mut transcript, | ||
)) | ||
}) | ||
}, | ||
) | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(30)); | ||
} | ||
} | ||
|
||
fn orion_opening_benchmark(c: &mut Criterion) { | ||
opening_benchmark_helper::<GF2, GF2x64, GF2_128, BytesHashTranscript<_, Keccak256hasher>>( | ||
c, 19, 25, | ||
) | ||
} | ||
|
||
criterion_group!(bench, orion_committing_benchmark, orion_opening_benchmark); | ||
criterion_main!(bench); |
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