Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulletproofs: update to criterion 0.5 #54

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bulletproofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ version = '0.4.0'
default-features = false

[dev-dependencies]
criterion = "0.3"
criterion = "0.5.1"
rand_chacha = "0.3"
bincode = "1"

Expand Down
24 changes: 9 additions & 15 deletions bulletproofs/benches/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

use ark_bulletproofs::{BulletproofGens, PedersenGens};
use ark_secq256k1::Affine;

#[macro_use]
extern crate criterion;
use criterion::Criterion;
use criterion::BenchmarkId;
use criterion::{criterion_group, criterion_main, Criterion};

fn pc_gens(c: &mut Criterion) {
c.bench_function("PedersenGens::new", |b| {
Expand All @@ -14,17 +12,13 @@ fn pc_gens(c: &mut Criterion) {
}

fn bp_gens(c: &mut Criterion) {
c.bench_function_over_inputs(
"BulletproofGens::new",
|b, size| b.iter(|| BulletproofGens::<Affine>::new(*size, 1)),
(0..10).map(|i| 2 << i),
);
}

criterion_group! {
bp,
bp_gens,
pc_gens,
let mut group = c.benchmark_group("BulletproofGens::new");
for size in (0..10).map(|i| 2 << i) {
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, &size| {
b.iter(|| BulletproofGens::<Affine>::new(size, 1))
});
}
}

criterion_group!(bp, bp_gens, pc_gens);
criterion_main!(bp);
40 changes: 13 additions & 27 deletions bulletproofs/benches/r1cs_secq256k1.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#![allow(non_snake_case)]
#![allow(deprecated)]

#[macro_use]
extern crate criterion;

use ark_std::UniformRand;
use criterion::Criterion;
use criterion::BenchmarkId;
use criterion::{criterion_group, criterion_main, Criterion};

// Code below copied from ../tests/r1cs.rs
//
Expand All @@ -16,10 +12,6 @@ use criterion::Criterion;
// someone wants to figure a way to use #[path] attributes or
// something to avoid the duplication.

extern crate ark_bulletproofs;
extern crate merlin;
extern crate rand;

use ark_bulletproofs::r1cs::*;
use ark_bulletproofs::{BulletproofGens, PedersenGens};
use ark_secq256k1::{Affine, Fr};
Expand Down Expand Up @@ -158,9 +150,9 @@ fn bench_kshuffle_prove(c: &mut Criterion) {
let pc_gens = PedersenGens::default();
let bp_gens = BulletproofGens::new(2 * MAX_SHUFFLE_SIZE, 1);

c.bench_function_over_inputs(
"k-shuffle proof creation",
move |b, k| {
let mut group = c.benchmark_group("k-shuffle proof creation");
for size in (1..=LG_MAX_SHUFFLE_SIZE).map(|i| 1 << i) {
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, k| {
// Generate inputs and outputs to kshuffle
let mut rng = rand::thread_rng();
let (min, max) = (0u64, u64::MAX);
Expand All @@ -181,12 +173,9 @@ fn bench_kshuffle_prove(c: &mut Criterion) {
&output,
)
.unwrap();
})
},
(1..=LG_MAX_SHUFFLE_SIZE)
.map(|i| 1 << i)
.collect::<Vec<_>>(),
);
});
});
}
}

criterion_group! {
Expand All @@ -203,9 +192,9 @@ fn bench_kshuffle_verify(c: &mut Criterion) {
let pc_gens = PedersenGens::default();
let bp_gens = BulletproofGens::new(2 * MAX_SHUFFLE_SIZE, 1);

c.bench_function_over_inputs(
"k-shuffle proof verification",
move |b, k| {
let mut group = c.benchmark_group("k-shuffle proof verification");
for size in (1..=LG_MAX_SHUFFLE_SIZE).map(|i| 1 << i) {
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, k| {
// Generate the proof in its own scope to prevent reuse of
// prover variables by the verifier
let (proof, input_commitments, output_commitments) = {
Expand Down Expand Up @@ -242,11 +231,8 @@ fn bench_kshuffle_verify(c: &mut Criterion) {
)
.unwrap();
})
},
(1..=LG_MAX_SHUFFLE_SIZE)
.map(|i| 1 << i)
.collect::<Vec<_>>(),
);
});
}
}

criterion_group! {
Expand Down
1 change: 0 additions & 1 deletion t256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rand = { version = "0.8.5" }
rand_core = { version = "0.6.4" }
merlin = { version = "3.0.0" }
ark-ff-macros = { version = "0.4.2", default-features = false }
criterion = "0.5.1"
sha2 = "0.10.8"

[dev-dependencies]
Expand Down
Loading