-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2399 from o1-labs/dw/bench-poseidon-master
mina_poseidon: bench poseidon block cipher [master]
- Loading branch information
Showing
3 changed files
with
119 additions
and
3 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,37 @@ | ||
use mina_poseidon::{ | ||
constants::{PlonkSpongeConstantsKimchi, PlonkSpongeConstantsLegacy}, | ||
pasta::{fp_kimchi as SpongeParametersKimchi, fp_legacy as SpongeParametersLegacy}, | ||
permutation::poseidon_block_cipher, | ||
}; | ||
use rand::{rngs::StdRng, thread_rng, Rng, SeedableRng}; | ||
|
||
use ark_ff::UniformRand; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use mina_curves::pasta::Fp; | ||
|
||
pub fn bench_poseidon_absorb_permutation_pasta_fp(c: &mut Criterion) { | ||
// FIXME: use o1_utils test rng | ||
let seed = thread_rng().gen(); | ||
eprintln!("Seed: {seed:?}"); | ||
let mut rng = StdRng::from_seed(seed); | ||
|
||
let input: [Fp; 3] = std::array::from_fn(|_| Fp::rand(&mut rng)); | ||
let mut input: Vec<Fp> = Vec::from(input); | ||
|
||
let params = SpongeParametersKimchi::static_params(); | ||
c.bench_function("poseidon_absorb_permutation kimchi", |b| { | ||
b.iter(|| { | ||
poseidon_block_cipher::<Fp, PlonkSpongeConstantsKimchi>(params, &mut input); | ||
}) | ||
}); | ||
|
||
let params = SpongeParametersLegacy::static_params(); | ||
c.bench_function("poseidon_absorb_permutation legacy", |b| { | ||
b.iter(|| { | ||
poseidon_block_cipher::<Fp, PlonkSpongeConstantsLegacy>(params, &mut input); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, bench_poseidon_absorb_permutation_pasta_fp); | ||
criterion_main!(benches); |