You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. use rand;
  2. #[macro_use]
  3. extern crate criterion;
  4. use algebra::ed_on_bls12_377::EdwardsProjective as Edwards;
  5. use criterion::Criterion;
  6. use crypto_primitives::crh::{pedersen::*, FixedLengthCRH};
  7. #[derive(Clone, PartialEq, Eq, Hash)]
  8. pub struct HashWindow;
  9. impl Window for HashWindow {
  10. const WINDOW_SIZE: usize = 250;
  11. const NUM_WINDOWS: usize = 8;
  12. }
  13. fn pedersen_crh_setup(c: &mut Criterion) {
  14. c.bench_function("Pedersen CRH Setup", move |b| {
  15. b.iter(|| {
  16. let mut rng = &mut rand::thread_rng();
  17. CRH::<Edwards, HashWindow>::setup(&mut rng).unwrap()
  18. })
  19. });
  20. }
  21. fn pedersen_crh_eval(c: &mut Criterion) {
  22. let mut rng = &mut rand::thread_rng();
  23. let parameters = CRH::<Edwards, HashWindow>::setup(&mut rng).unwrap();
  24. let input = vec![5u8; 128];
  25. c.bench_function("Pedersen CRH Eval", move |b| {
  26. b.iter(|| CRH::<Edwards, HashWindow>::evaluate(&parameters, &input).unwrap())
  27. });
  28. }
  29. criterion_group! {
  30. name = crh_setup;
  31. config = Criterion::default().sample_size(10);
  32. targets = pedersen_crh_setup
  33. }
  34. criterion_group! {
  35. name = crh_eval;
  36. config = Criterion::default().sample_size(10);
  37. targets = pedersen_crh_eval
  38. }
  39. criterion_main!(crh_setup, crh_eval);