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.

66 lines
2.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. use criterion::{criterion_group, criterion_main, Criterion};
  2. extern crate rand;
  3. #[macro_use]
  4. extern crate ff;
  5. use ff::*;
  6. extern crate num;
  7. extern crate num_bigint;
  8. use num_bigint::BigInt;
  9. use babyjubjub_rs::{utils, Point};
  10. fn criterion_benchmark(c: &mut Criterion) {
  11. // let x: BigInt = BigInt::parse_bytes(
  12. // b"17777552123799933955779906779655732241715742912184938656739573121738514868268",
  13. // 10,
  14. // )
  15. // .unwrap();
  16. // c.bench_function("modulus", |b| {
  17. // b.iter(|| utils::modulus(&x, &babyjubjub_rs::Q))
  18. // });
  19. let p: Point = Point {
  20. x: babyjubjub_rs::Fr::from_str(
  21. "17777552123799933955779906779655732241715742912184938656739573121738514868268",
  22. )
  23. .unwrap(),
  24. y: babyjubjub_rs::Fr::from_str(
  25. "2626589144620713026669568689430873010625803728049924121243784502389097019475",
  26. )
  27. .unwrap(),
  28. z: babyjubjub_rs::Fr::one(),
  29. };
  30. let q = p.clone();
  31. c.bench_function("add", |b| b.iter(|| p.add(&q)));
  32. let r: BigInt = BigInt::parse_bytes(b"3", 10).unwrap();
  33. c.bench_function("mul_scalar_small", |b| b.iter(|| p.mul_scalar(&r)));
  34. let r: BigInt = BigInt::parse_bytes(
  35. b"2626589144620713026669568689430873010625803728049924121243784502389097019475",
  36. 10,
  37. )
  38. .unwrap();
  39. c.bench_function("mul_scalar", |b| b.iter(|| p.mul_scalar(&r)));
  40. // c.bench_function("compress", |b| b.iter(|| p.compress()));
  41. // let p_comp = p.compress();
  42. // c.bench_function("decompress", |b| {
  43. // b.iter(|| babyjubjub_rs::decompress_point(p_comp))
  44. // });
  45. // let sk = babyjubjub_rs::new_key();
  46. // let pk = sk.public().unwrap();
  47. // let msg = 5.to_bigint().unwrap();
  48. // c.bench_function("sign_poseidon", |b| {
  49. // b.iter(|| sk.sign_poseidon(msg.clone()))
  50. // });
  51. // let sig = sk.sign_poseidon(msg.clone()).unwrap();
  52. // c.bench_function("verify_poseidon", |b| {
  53. // b.iter(|| babyjubjub_rs::verify_poseidon(pk.clone(), sig.clone(), msg.clone()))
  54. // });
  55. }
  56. criterion_group!(benches, criterion_benchmark);
  57. criterion_main!(benches);