Skip to content

Commit

Permalink
Benchmarks verification (#4)
Browse files Browse the repository at this point in the history
* benchmarks verification

* fmt

* upgrades gmp
  • Loading branch information
kobigurk authored Apr 27, 2020
1 parent 5874890 commit 09f9bc2
Show file tree
Hide file tree
Showing 11 changed files with 230 additions and 146 deletions.
266 changes: 131 additions & 135 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ blake2 = ">= 0.8.1"
[features]
dalek = ["curve25519-dalek", "bulletproofs"]
zexe = []
class = []
default = ["zexe"]

[dev-dependencies]
criterion = "0.2"
criterion = "0.3"

[lib]
bench = false
Expand Down Expand Up @@ -65,7 +66,7 @@ required-features = ["zexe"]
[[bench]]
name = "membership_class"
harness = false
required-features = ["zexe"]
required-features = ["zexe", "class"]

[[bench]]
name = "membership_bp"
Expand Down
12 changes: 11 additions & 1 deletion benches/membership_bp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("membership_bp protocol", move |b| {
c.bench_function("membership_bp protocol proving", |b| {
b.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"membership"));
crs.crs_hash_to_prime.hash_to_prime_parameters.transcript =
Expand All @@ -120,6 +120,16 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});
c.bench_function("membership_bp protocol verification", |b| {
b.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"membership"));
crs.crs_hash_to_prime.hash_to_prime_parameters.transcript =
Some(verification_transcript.clone());
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
12 changes: 11 additions & 1 deletion benches/membership_bp_60.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("membership_bp_60 protocol", move |b| {
c.bench_function("membership_bp_60 protocol proving", |b| {
b.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"membership"));
crs.crs_hash_to_prime.hash_to_prime_parameters.transcript =
Expand All @@ -122,6 +122,16 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});
c.bench_function("membership_bp_60 protocol verification", |b| {
b.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"membership"));
crs.crs_hash_to_prime.hash_to_prime_parameters.transcript =
Some(verification_transcript.clone());
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
11 changes: 10 additions & 1 deletion benches/membership_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("membership_class protocol", move |b| {
c.bench_function("membership_class protocol proving", |b| {
b.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"membership"));
let mut verifier_channel = TranscriptVerifierChannel::new(&crs, &proof_transcript);
Expand All @@ -119,6 +119,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});

c.bench_function("membership_class protocol verification", |b| {
b.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"membership"));
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
11 changes: 10 additions & 1 deletion benches/membership_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("membership_hash protocol", move |b| {
c.bench_function("membership_hash protocol proving", |b| {
b.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"membership"));
let mut verifier_channel = TranscriptVerifierChannel::new(&crs, &proof_transcript);
Expand All @@ -130,6 +130,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});

c.bench_function("membership_hash protocol verification", |b| {
b.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"membership"));
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
16 changes: 15 additions & 1 deletion benches/membership_prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("membership_prime protocol", move |b| {
c.bench_function("membership_prime protocol proving", |b| {
b.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"membership"));
let mut verifier_channel = TranscriptVerifierChannel::new(&crs, &proof_transcript);
Expand All @@ -119,6 +119,20 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});

c.bench_function("membership_prime protocol verification", |b| {
b.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"membership"));
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);

let statement = Statement {
c_e_q: commitment,
c_p: acc.clone(),
};
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
11 changes: 10 additions & 1 deletion benches/membership_prime_60.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("membership_prime_60 protocol", move |b| {
c.bench_function("membership_prime_60 protocol proving", |b| {
b.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"membership"));
let mut verifier_channel = TranscriptVerifierChannel::new(&crs, &proof_transcript);
Expand All @@ -121,6 +121,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});

c.bench_function("membership_prime_60 protocol verification", |b| {
b.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"membership"));
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
12 changes: 11 additions & 1 deletion benches/nonmembership_bp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("nonmembership_bp protocol", move |be| {
c.bench_function("nonmembership_bp protocol proving", |be| {
be.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"nonmembership"));
crs.crs_hash_to_prime.hash_to_prime_parameters.transcript =
Expand All @@ -128,6 +128,16 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});
c.bench_function("nonmembership_bp protocol verification", |be| {
be.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"nonmembership"));
crs.crs_hash_to_prime.hash_to_prime_parameters.transcript =
Some(verification_transcript.clone());
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
10 changes: 9 additions & 1 deletion benches/nonmembership_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("nonmembership_hash protocol", move |be| {
c.bench_function("nonmembership_hash protocol proving", |be| {
be.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"nonmembership"));
let mut verifier_channel = TranscriptVerifierChannel::new(&crs, &proof_transcript);
Expand All @@ -138,6 +138,14 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});
c.bench_function("nonmembership_hash protocol verification", |be| {
be.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"nonmembership"));
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
10 changes: 9 additions & 1 deletion benches/nonmembership_prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut prover_channel = TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();

c.bench_function("nonmembership_prime protocol", move |be| {
c.bench_function("nonmembership_prime protocol proving", |be| {
be.iter(|| {
let proof_transcript = RefCell::new(Transcript::new(b"nonmembership"));
let mut verifier_channel = TranscriptVerifierChannel::new(&crs, &proof_transcript);
Expand All @@ -127,6 +127,14 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.unwrap();
})
});
c.bench_function("nonmembership_prime protocol verification", |be| {
be.iter(|| {
let verification_transcript = RefCell::new(Transcript::new(b"nonmembership"));
let mut prover_channel =
TranscriptProverChannel::new(&crs, &verification_transcript, &proof);
protocol.verify(&mut prover_channel, &statement).unwrap();
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down

0 comments on commit 09f9bc2

Please sign in to comment.