Skip to content

Commit

Permalink
Comment some benchmarks for the moment
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Mar 14, 2024
1 parent 866fa87 commit 71ae5a9
Showing 1 changed file with 61 additions and 60 deletions.
121 changes: 61 additions & 60 deletions ferveo-tdec/benches/tpke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,69 +409,70 @@ pub fn bench_ciphertext_validity_checks(c: &mut Criterion) {
}
}

pub fn bench_decryption_share_validity_checks(c: &mut Criterion) {
let mut group = c.benchmark_group("DECRYPTION SHARE VERIFICATION");
group.sample_size(10);
// TODO: Uncomment benchmarks
// pub fn bench_decryption_share_validity_checks(c: &mut Criterion) {
// let mut group = c.benchmark_group("DECRYPTION SHARE VERIFICATION");
// group.sample_size(10);

let rng = &mut StdRng::seed_from_u64(0);
let msg_size = MSG_SIZE_CASES[0];
// let rng = &mut StdRng::seed_from_u64(0);
// let msg_size = MSG_SIZE_CASES[0];

for shares_num in NUM_SHARES_CASES {
let share_fast_verification = {
let mut rng = rng.clone();
let setup = SetupFast::new(shares_num, msg_size, &mut rng);
move || {
black_box(verify_decryption_shares_fast(
&setup.pub_contexts,
&setup.shared.ciphertext,
&setup.decryption_shares,
))
}
};
group.bench_function(
BenchmarkId::new("share_fast_verification", shares_num),
|b| b.iter(|| share_fast_verification()),
);
// for shares_num in NUM_SHARES_CASES {
// let share_fast_verification = {
// let mut rng = rng.clone();
// let setup = SetupFast::new(shares_num, msg_size, &mut rng);
// move || {
// black_box(verify_decryption_shares_fast(
// &setup.pub_contexts,
// &setup.shared.ciphertext,
// &setup.decryption_shares,
// ))
// }
// };
// group.bench_function(
// BenchmarkId::new("share_fast_verification", shares_num),
// |b| b.iter(|| share_fast_verification()),
// );

let mut share_fast_batch_verification = {
let mut rng = rng.clone();
let setup = SetupFast::new(shares_num, msg_size, &mut rng);
// We need to repackage a bunch of variables here to avoid borrowing issues:
let ciphertext = setup.shared.ciphertext.clone();
let ciphertexts = vec![ciphertext];
let decryption_shares = setup.decryption_shares.clone();
let decryption_shares = vec![decryption_shares];
move || {
black_box(batch_verify_decryption_shares(
&setup.pub_contexts,
&ciphertexts,
&decryption_shares,
&mut rng,
))
}
};
group.bench_function(
BenchmarkId::new("share_fast_batch_verification", shares_num),
|b| b.iter(|| share_fast_batch_verification()),
);
// let mut share_fast_batch_verification = {
// let mut rng = rng.clone();
// let setup = SetupFast::new(shares_num, msg_size, &mut rng);
// // We need to repackage a bunch of variables here to avoid borrowing issues:
// let ciphertext = setup.shared.ciphertext.clone();
// let ciphertexts = vec![ciphertext];
// let decryption_shares = setup.decryption_shares.clone();
// let decryption_shares = vec![decryption_shares];
// move || {
// black_box(batch_verify_decryption_shares(
// &setup.pub_contexts,
// &ciphertexts,
// &decryption_shares,
// &mut rng,
// ))
// }
// };
// group.bench_function(
// BenchmarkId::new("share_fast_batch_verification", shares_num),
// |b| b.iter(|| share_fast_batch_verification()),
// );

let share_simple_verification = {
let mut rng = rng.clone();
let setup = SetupSimple::new(shares_num, msg_size, &mut rng);
move || {
black_box(verify_decryption_shares_simple(
&setup.pub_contexts,
&setup.shared.ciphertext,
&setup.decryption_shares,
))
}
};
group.bench_function(
BenchmarkId::new("share_simple_verification", shares_num),
|b| b.iter(|| share_simple_verification()),
);
}
}
// let share_simple_verification = {
// let mut rng = rng.clone();
// let setup = SetupSimple::new(shares_num, msg_size, &mut rng);
// move || {
// black_box(verify_decryption_shares_simple(
// &setup.pub_contexts,
// &setup.shared.ciphertext,
// &setup.decryption_shares,
// ))
// }
// };
// group.bench_function(
// BenchmarkId::new("share_simple_verification", shares_num),
// |b| b.iter(|| share_simple_verification()),
// );
// }
// }

// TODO: Relocate benchmark to ferveo/benches as part of #162, #163
// pub fn bench_recover_share_at_point(c: &mut Criterion) {
Expand Down Expand Up @@ -585,7 +586,7 @@ criterion_group!(
bench_share_combine,
bench_share_encrypt_decrypt,
bench_ciphertext_validity_checks,
bench_decryption_share_validity_checks,
// bench_decryption_share_validity_checks,
// bench_recover_share_at_point,
// bench_refresh_shares,
);
Expand Down

0 comments on commit 71ae5a9

Please sign in to comment.