Skip to content

Commit 00f8d64

Browse files
committed
chore(zk): add batched mode for verification pairings
1 parent f970031 commit 00f8d64

File tree

3 files changed

+527
-145
lines changed

3 files changed

+527
-145
lines changed

tfhe-zk-pok/benches/pke_v2.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use criterion::{criterion_group, criterion_main, Criterion};
22
use rand::Rng;
3-
use tfhe_zk_pok::proofs::pke_v2::{prove, verify, Bound};
3+
use tfhe_zk_pok::proofs::pke_v2::{prove, verify, Bound, VerificationPairingMode};
44
use tfhe_zk_pok::proofs::ComputeLoad;
55
use utils::{init_params_v2, write_to_json, PKEV1_TEST_PARAMS, PKEV2_TEST_PARAMS};
66

@@ -30,6 +30,7 @@ fn bench_pke_v2_prove(c: &mut Criterion) {
3030
let bits = (params.k as u32) * effective_t.ilog2();
3131

3232
let bench_id = format!("{bench_name}::{param_name}_{bits}_bits_packed_{load}_{bound:?}");
33+
println!("{bench_id}");
3334

3435
let seed: u128 = rng.gen();
3536

@@ -59,19 +60,26 @@ fn bench_pke_v2_verify(c: &mut Criterion) {
5960

6061
let rng = &mut rand::thread_rng();
6162

62-
for ((params, param_name), load, bound) in itertools::iproduct!(
63+
for ((params, param_name), load, bound, pairing_mode) in itertools::iproduct!(
6364
[
6465
(PKEV1_TEST_PARAMS, "PKEV1_TEST_PARAMS"),
6566
(PKEV2_TEST_PARAMS, "PKEV2_TEST_PARAMS"),
6667
],
6768
[ComputeLoad::Proof, ComputeLoad::Verify],
68-
[Bound::CS, Bound::GHL]
69+
[Bound::CS, Bound::GHL],
70+
[
71+
VerificationPairingMode::TwoSteps,
72+
VerificationPairingMode::Batched
73+
]
6974
) {
7075
let (public_param, public_commit, private_commit, metadata) = init_params_v2(params, bound);
7176
let effective_t = params.t >> 1;
7277
let bits = (params.k as u32) * effective_t.ilog2();
7378

74-
let bench_id = format!("{bench_name}::{param_name}_{bits}_bits_packed_{load}_{bound:?}");
79+
let bench_id = format!(
80+
"{bench_name}::{param_name}_{bits}_bits_packed_{load}_{bound:?}_{pairing_mode:?}"
81+
);
82+
println!("{bench_id}");
7583

7684
let seed: u128 = rng.gen();
7785

@@ -85,7 +93,13 @@ fn bench_pke_v2_verify(c: &mut Criterion) {
8593

8694
bench_group.bench_function(&bench_id, |b| {
8795
b.iter(|| {
88-
verify(&proof, (&public_param, &public_commit), &metadata).unwrap();
96+
verify(
97+
&proof,
98+
(&public_param, &public_commit),
99+
&metadata,
100+
pairing_mode,
101+
)
102+
.unwrap();
89103
})
90104
});
91105

0 commit comments

Comments
 (0)