2018-07-25 20:46:00 +00:00
|
|
|
#![feature(test)]
|
|
|
|
|
2019-08-15 16:39:55 +00:00
|
|
|
extern crate pairing;
|
2019-08-06 09:46:40 +00:00
|
|
|
extern crate rand_core;
|
2018-07-25 20:46:00 +00:00
|
|
|
extern crate test;
|
2019-08-06 09:46:40 +00:00
|
|
|
extern crate zcash_primitives;
|
2018-07-25 20:46:00 +00:00
|
|
|
|
2019-08-15 16:39:55 +00:00
|
|
|
use pairing::bls12_381::Bls12;
|
2019-09-28 07:48:43 +00:00
|
|
|
use rand_core::{OsRng, RngCore};
|
2019-08-06 09:46:40 +00:00
|
|
|
use zcash_primitives::jubjub::JubjubBls12;
|
|
|
|
use zcash_primitives::pedersen_hash::{pedersen_hash, Personalization};
|
2018-07-25 20:46:00 +00:00
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_pedersen_hash(b: &mut test::Bencher) {
|
|
|
|
let params = JubjubBls12::new();
|
2019-08-06 09:46:40 +00:00
|
|
|
let rng = &mut OsRng;
|
2019-08-15 16:39:55 +00:00
|
|
|
let bits = (0..510)
|
|
|
|
.map(|_| (rng.next_u32() % 2) != 0)
|
|
|
|
.collect::<Vec<_>>();
|
2018-07-25 20:46:00 +00:00
|
|
|
let personalization = Personalization::MerkleTree(31);
|
|
|
|
|
2019-08-15 16:39:55 +00:00
|
|
|
b.iter(|| pedersen_hash::<Bls12, _>(personalization, bits.clone(), ¶ms));
|
2018-07-25 20:46:00 +00:00
|
|
|
}
|