mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-07 20:30:34 +00:00
Update hashtocurve benchmark
This commit is contained in:
parent
d14d2314a1
commit
a757bc4e43
1 changed files with 3 additions and 27 deletions
|
|
@ -2,46 +2,22 @@
|
||||||
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
use halo2::arithmetic::{HashToCurve, Shake128};
|
use halo2::arithmetic::Curve;
|
||||||
use halo2::pasta::{pallas, vesta};
|
use halo2::pasta::{pallas, vesta};
|
||||||
|
|
||||||
fn criterion_benchmark(c: &mut Criterion) {
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
bench_hash_to_curve(c);
|
bench_hash_to_curve(c);
|
||||||
bench_encode_to_curve(c);
|
|
||||||
bench_map_to_curve(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_hash_to_curve(c: &mut Criterion) {
|
fn bench_hash_to_curve(c: &mut Criterion) {
|
||||||
let mut group = c.benchmark_group("hash-to-curve");
|
let mut group = c.benchmark_group("hash-to-curve");
|
||||||
|
|
||||||
let hash_pallas = pallas::MAP.hash_to_curve("z.cash:test", Shake128::default());
|
let hash_pallas = pallas::Point::hash_to_curve("z.cash:test");
|
||||||
group.bench_function("Pallas", |b| b.iter(|| hash_pallas(b"benchmark")));
|
group.bench_function("Pallas", |b| b.iter(|| hash_pallas(b"benchmark")));
|
||||||
|
|
||||||
let hash_vesta = vesta::MAP.hash_to_curve("z.cash:test", Shake128::default());
|
let hash_vesta = vesta::Point::hash_to_curve("z.cash:test");
|
||||||
group.bench_function("Vesta", |b| b.iter(|| hash_vesta(b"benchmark")));
|
group.bench_function("Vesta", |b| b.iter(|| hash_vesta(b"benchmark")));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_encode_to_curve(c: &mut Criterion) {
|
|
||||||
let mut group = c.benchmark_group("encode-to-curve");
|
|
||||||
|
|
||||||
let encode_pallas = pallas::MAP.encode_to_curve("z.cash:test", Shake128::default());
|
|
||||||
group.bench_function("Pallas", |b| b.iter(|| encode_pallas(b"benchmark")));
|
|
||||||
|
|
||||||
let encode_vesta = vesta::MAP.encode_to_curve("z.cash:test", Shake128::default());
|
|
||||||
group.bench_function("Vesta", |b| b.iter(|| encode_vesta(b"benchmark")));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bench_map_to_curve(c: &mut Criterion) {
|
|
||||||
let mut group = c.benchmark_group("map-to-curve");
|
|
||||||
|
|
||||||
let pallas_input = &pallas::Base::one();
|
|
||||||
group.bench_function("Pallas", |b| {
|
|
||||||
b.iter(|| pallas::MAP.map_to_curve(pallas_input))
|
|
||||||
});
|
|
||||||
|
|
||||||
let vesta_input = &vesta::Base::one();
|
|
||||||
group.bench_function("Vesta", |b| b.iter(|| vesta::MAP.map_to_curve(vesta_input)));
|
|
||||||
}
|
|
||||||
|
|
||||||
criterion_group!(benches, criterion_benchmark);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue