Skip to content

Commit

Permalink
chore(wop): remove outdated parameters and update other parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
IceTDrinker committed Apr 8, 2024
1 parent cda3f2b commit d5c5160
Show file tree
Hide file tree
Showing 12 changed files with 1,121 additions and 2,411 deletions.
31 changes: 1 addition & 30 deletions tfhe/benches/shortint/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use criterion::{criterion_group, Criterion};
use rand::Rng;
use std::env;
use tfhe::keycache::NamedParam;
use tfhe::shortint::keycache::{KEY_CACHE, KEY_CACHE_WOPBS};
use tfhe::shortint::parameters::parameters_wopbs::WOPBS_PARAM_MESSAGE_4_NORM2_6_KS_PBS;
use tfhe::shortint::keycache::KEY_CACHE;
use tfhe::shortint::parameters::*;
use tfhe::shortint::{Ciphertext, CompressedServerKey, ServerKey};

Expand Down Expand Up @@ -383,34 +382,6 @@ fn server_key_from_compressed_key(c: &mut Criterion) {
bench_group.finish();
}

// TODO: remove?
fn _bench_wopbs_param_message_8_norm2_5(c: &mut Criterion) {
let mut bench_group = c.benchmark_group("programmable_bootstrap");

let param = WOPBS_PARAM_MESSAGE_4_NORM2_6_KS_PBS;
let param_set: ShortintParameterSet = param.into();
let pbs_params = param_set.pbs_parameters().unwrap();

let keys = KEY_CACHE_WOPBS.get_from_param((pbs_params, param));
let (cks, _, wopbs_key) = (keys.client_key(), keys.server_key(), keys.wopbs_key());

let mut rng = rand::thread_rng();

let clear = rng.gen::<usize>() % param.message_modulus.0;
let ct = cks.encrypt_without_padding(clear as u64);
let vec_lut = wopbs_key.generate_lut_native_crt(&ct, |x| x);

let id = format!("Shortint WOPBS: {param:?}");

bench_group.bench_function(&id, |b| {
b.iter(|| {
let _ = wopbs_key.programmable_bootstrapping_native_crt(&ct, &vec_lut);
})
});

bench_group.finish();
}

macro_rules! define_server_key_unary_bench_fn (
(method_name:$server_key_method:ident, display_name:$name:ident, $params_set:expr) => {
fn $server_key_method(c: &mut Criterion) {
Expand Down
8 changes: 3 additions & 5 deletions tfhe/examples/utilities/generates_test_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ use tfhe::shortint::parameters::coverage_parameters::{
use tfhe::shortint::parameters::key_switching::{
ShortintKeySwitchingParameters, PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
};
use tfhe::shortint::parameters::parameters_wopbs_message_carry::{
WOPBS_PARAM_MESSAGE_1_CARRY_1_KS_PBS, WOPBS_PARAM_MESSAGE_2_CARRY_2_KS_PBS,
WOPBS_PARAM_MESSAGE_3_CARRY_3_KS_PBS, WOPBS_PARAM_MESSAGE_4_CARRY_4_KS_PBS,
};
use tfhe::shortint::parameters::{
ClassicPBSParameters, WopbsParameters, ALL_MULTI_BIT_PARAMETER_VEC, ALL_PARAMETER_VEC,
PARAM_MESSAGE_1_CARRY_1_KS_PBS, PARAM_MESSAGE_2_CARRY_2_KS_PBS, PARAM_MESSAGE_3_CARRY_3_KS_PBS,
PARAM_MESSAGE_4_CARRY_4_KS_PBS,
PARAM_MESSAGE_4_CARRY_4_KS_PBS, WOPBS_PARAM_MESSAGE_1_CARRY_1_KS_PBS,
WOPBS_PARAM_MESSAGE_2_CARRY_2_KS_PBS, WOPBS_PARAM_MESSAGE_3_CARRY_3_KS_PBS,
WOPBS_PARAM_MESSAGE_4_CARRY_4_KS_PBS,
};
use tfhe::shortint::MultiBitPBSParameters;

Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/integer/wopbs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ impl WopbsKey {
/// ```rust
/// use tfhe::integer::gen_keys_radix;
/// use tfhe::integer::wopbs::WopbsKey;
/// use tfhe::shortint::parameters::parameters_wopbs_message_carry::WOPBS_PARAM_MESSAGE_2_CARRY_2_KS_PBS;
/// use tfhe::shortint::parameters::parameters_wopbs_only::WOPBS_ONLY_4_BLOCKS_PARAM_MESSAGE_2_CARRY_2_KS_PBS;
///
/// let nb_block = 3;
/// //Generate the client key and the server key:
/// let (cks, sks) = gen_keys_radix(WOPBS_PARAM_MESSAGE_2_CARRY_2_KS_PBS, nb_block);
/// let (cks, sks) = gen_keys_radix(WOPBS_ONLY_4_BLOCKS_PARAM_MESSAGE_2_CARRY_2_KS_PBS, nb_block);
/// let wopbs_key = WopbsKey::new_wopbs_key_only_for_wopbs(&cks, &sks);
/// let mut moduli = 1_u64;
/// for _ in 0..nb_block {
Expand Down
1 change: 0 additions & 1 deletion tfhe/src/integer/wopbs/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::integer::wopbs::{encode_radix, WopbsKey};
use crate::integer::{gen_keys, IntegerKeyKind};
use crate::shortint::ciphertext::Degree;
use crate::shortint::parameters::parameters_wopbs::*;
use crate::shortint::parameters::parameters_wopbs_message_carry::*;
use crate::shortint::parameters::*;
use paste::paste;
use rand::Rng;
Expand Down
120 changes: 37 additions & 83 deletions tfhe/src/shortint/keycache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use crate::shortint::parameters::key_switching::*;
use crate::shortint::parameters::multi_bit::*;
use crate::shortint::parameters::parameters_compact_pk::*;
use crate::shortint::parameters::parameters_wopbs::*;
use crate::shortint::parameters::parameters_wopbs_message_carry::*;
use crate::shortint::parameters::parameters_wopbs_prime_moduli::*;
use crate::shortint::parameters::*;
use crate::shortint::wopbs::WopbsKey;
use crate::shortint::{ClientKey, KeySwitchingKey, ServerKey};
Expand Down Expand Up @@ -123,38 +121,6 @@ named_params_impl!( ShortintParameterSet =>
PARAM_MESSAGE_6_CARRY_2_COMPACT_PK_PBS_KS,
PARAM_MESSAGE_7_CARRY_1_COMPACT_PK_PBS_KS,
// Wopbs
WOPBS_PARAM_MESSAGE_1_NORM2_2_KS_PBS,
WOPBS_PARAM_MESSAGE_1_NORM2_4_KS_PBS,
WOPBS_PARAM_MESSAGE_1_NORM2_6_KS_PBS,
WOPBS_PARAM_MESSAGE_1_NORM2_8_KS_PBS,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ARAM_MESSAGE_1_CARRY_1_KS_PBS,
WOPBS_PARAM_MESSAGE_1_CARRY_2_KS_PBS,
Expand Down Expand Up @@ -191,55 +157,43 @@ named_params_impl!( ShortintParameterSet =>
WOPBS_PARAM_MESSAGE_7_CARRY_0_KS_PBS,
WOPBS_PARAM_MESSAGE_7_CARRY_1_KS_PBS,
WOPBS_PARAM_MESSAGE_8_CARRY_0_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_5_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_6_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_7_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_2_NORM2_8_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_5_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_6_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_7_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_3_NORM2_8_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_5_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_6_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_7_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_4_NORM2_8_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_5_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_6_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_7_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_5_NORM2_8_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_5_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_6_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_7_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_6_NORM2_8_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_5_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_6_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_7_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_7_NORM2_8_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_8_NORM2_2_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_8_NORM2_3_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_8_NORM2_4_KS_PBS,
WOPBS_PRIME_PARAM_MESSAGE_8_NORM2_5_KS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LY_2_BLOCKS_PARAM_MESSAGE_3_CARRY_3_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_3_CARRY_4_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_3_CARRY_5_KS_PBS,
WOPBS_ONLY_4_BLOCKS_PARAM_MESSAGE_4_CARRY_0_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_4_CARRY_1_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_4_CARRY_2_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_4_CARRY_3_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_4_CARRY_4_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_5_CARRY_0_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_5_CARRY_1_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_5_CARRY_2_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_5_CARRY_3_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_6_CARRY_0_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_6_CARRY_1_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_6_CARRY_2_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_7_CARRY_0_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_7_CARRY_1_KS_PBS,
WOPBS_ONLY_2_BLOCKS_PARAM_MESSAGE_8_CARRY_0_KS_PBS,
// Coverage
#[cfg(tarpaulin)]
COVERAGE_PARAM_MESSAGE_2_CARRY_2_KS_PBS,
Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/shortint/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ pub mod multi_bit;
pub mod parameters_compact_pk;
pub mod parameters_wopbs;
pub mod parameters_wopbs_message_carry;
pub(crate) mod parameters_wopbs_prime_moduli;
pub mod parameters_wopbs_only;

use super::ciphertext::{Degree, NoiseLevel};
use super::PBSOrder;
pub use crate::core_crypto::commons::parameters::EncryptionKeyChoice;
pub use key_switching::ShortintKeySwitchingParameters;
pub use multi_bit::*;
pub use parameters_compact_pk::*;
pub use parameters_wopbs::WopbsParameters;
pub use parameters_wopbs::*;

/// The modulus of the message space. For a given plaintext $p$ we have the message $m$ defined as
/// $m = p\bmod{MessageModulus}$ and so $0 <= m < MessageModulus$.
Expand Down
Loading

0 comments on commit d5c5160

Please sign in to comment.