Skip to content

Commit

Permalink
chore(shortint): update keyswitch 1_1 to 2_2 parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarlin-zama committed Jan 6, 2025
1 parent a2a54a4 commit 71fb6c5
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 30 deletions.
6 changes: 3 additions & 3 deletions apps/trivium/benches/kreyvium_shortint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn kreyvium_shortint_warmup(c: &mut Criterion) {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn kreyvium_shortint_gen(c: &mut Criterion) {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn kreyvium_shortint_trans(c: &mut Criterion) {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
Expand Down
6 changes: 3 additions & 3 deletions apps/trivium/benches/trivium_shortint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn trivium_shortint_warmup(c: &mut Criterion) {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB".to_string();
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn trivium_shortint_gen(c: &mut Criterion) {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB".to_string();
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn trivium_shortint_trans(c: &mut Criterion) {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB".to_string();
Expand Down
2 changes: 1 addition & 1 deletion apps/trivium/src/kreyvium/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fn kreyvium_test_shortint_long() {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
Expand Down
2 changes: 1 addition & 1 deletion apps/trivium/src/trivium/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fn trivium_test_shortint_long() {
let ksk = KeySwitchingKey::new(
(&client_key, Some(&server_key)),
(&underlying_ck, &underlying_sk),
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
);

let key_string = "0053A6F94C9FF24598EB".to_string();
Expand Down
12 changes: 6 additions & 6 deletions tfhe/benches/shortint/casting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub fn pack_cast_64(c: &mut Criterion) {
let (client_key_2, server_key_2): (ClientKey, ServerKey) =
gen_keys(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);

let ks_param = PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
let ks_param_name = "PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";
let ks_param = V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
let ks_param_name = "V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";

let ksk = KeySwitchingKey::new(
(&client_key_1, Some(&server_key_1)),
Expand Down Expand Up @@ -67,8 +67,8 @@ pub fn pack_cast(c: &mut Criterion) {
let (client_key_2, server_key_2): (ClientKey, ServerKey) =
gen_keys(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);

let ks_param = PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
let ks_param_name = "PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";
let ks_param = V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
let ks_param_name = "V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";

let ksk = KeySwitchingKey::new(
(&client_key_1, Some(&server_key_1)),
Expand Down Expand Up @@ -108,8 +108,8 @@ pub fn cast(c: &mut Criterion) {
let (client_key_2, server_key_2): (ClientKey, ServerKey) =
gen_keys(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);

let ks_param = PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
let ks_param_name = "PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";
let ks_param = V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
let ks_param_name = "V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";

let ksk = KeySwitchingKey::new(
(&client_key_1, Some(&server_key_1)),
Expand Down
6 changes: 3 additions & 3 deletions tfhe/examples/utilities/generates_test_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tfhe::shortint::parameters::coverage_parameters::{
COVERAGE_PARAM_MESSAGE_5_CARRY_1_KS_PBS,
COVERAGE_PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
};
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
use tfhe::shortint::parameters::key_switching::ShortintKeySwitchingParameters;

use tfhe::shortint::parameters::multi_bit::gaussian::p_fail_2_minus_64::ks_pbs::{
Expand Down Expand Up @@ -110,12 +110,12 @@ fn client_server_keys() {
(
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
),
(
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
),
];

Expand Down
6 changes: 3 additions & 3 deletions tfhe/src/shortint/key_switching_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl KeySwitchingKey {
/// let ksk = KeySwitchingKey::new(
/// (&ck1, Some(&sk1)),
/// (&ck2, &sk2),
/// PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
/// V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
/// );
/// ```
pub fn new<'input_key, InputEncryptionKey>(
Expand Down Expand Up @@ -337,7 +337,7 @@ impl KeySwitchingKey {
/// let ksk = KeySwitchingKey::new(
/// (&ck1, Some(&sk1)),
/// (&ck2, &sk2),
/// PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
/// V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
/// );
///
/// let cleartext = 1;
Expand Down Expand Up @@ -478,7 +478,7 @@ impl<'keys> KeySwitchingKeyView<'keys> {
/// let ksk = KeySwitchingKey::new(
/// (&ck1, Some(&sk1)),
/// (&ck2, &sk2),
/// PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
/// V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
/// );
///
/// let cleartext = 1;
Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/shortint/key_switching_key/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn gen_multi_keys_test_fresh_ci_run_filter() {
let keys = KEY_CACHE_KSK.get_from_param((
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
));
let ck1 = keys.client_key_1();
let (ck2, sk2) = (keys.client_key_2(), keys.server_key_2());
Expand Down Expand Up @@ -119,7 +119,7 @@ fn gen_multi_keys_test_add_with_overflow_ci_run_filter() {
let keys = KEY_CACHE_KSK.get_from_param((
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
));
let (ck1, sk1) = (keys.client_key_1(), keys.server_key_1());
let (ck2, sk2) = (keys.client_key_2(), keys.server_key_2());
Expand Down
6 changes: 3 additions & 3 deletions tfhe/src/shortint/keycache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::P
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
#[cfg(tarpaulin)]
use crate::shortint::parameters::coverage_parameters::*;
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
use crate::shortint::parameters::key_switching::*;
use crate::shortint::parameters::list_compression::*;
use crate::shortint::parameters::parameters_wopbs::*;
Expand Down Expand Up @@ -285,12 +285,12 @@ impl NamedParam for WopbsParameters {

impl NamedParam for ShortintKeySwitchingParameters {
fn name(&self) -> String {
named_params_impl!(expose PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS);
named_params_impl!(expose V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS);
named_params_impl!(
{
*self;
Self
} == (PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS)
} == (V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS)
);

format!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::shortint::parameters::{
DecompositionBaseLog, DecompositionLevelCount, EncryptionKeyChoice,
ShortintKeySwitchingParameters,
};
pub const PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS: ShortintKeySwitchingParameters =
pub const V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS: ShortintKeySwitchingParameters =
ShortintKeySwitchingParameters {
ks_level: DecompositionLevelCount(15),
ks_base_log: DecompositionBaseLog(1),
destination_key: EncryptionKeyChoice::Big,
ks_level: DecompositionLevelCount(5),
ks_base_log: DecompositionBaseLog(3),
destination_key: EncryptionKeyChoice::Small,
};

// The level and base log correspond to the level and base log of the 2_2 TUniform parameters, so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ use crate::shortint::parameters::{
ShortintKeySwitchingParameters,
};

pub const V0_10_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS: ShortintKeySwitchingParameters =
ShortintKeySwitchingParameters {
ks_level: DecompositionLevelCount(15),
ks_base_log: DecompositionBaseLog(1),
destination_key: EncryptionKeyChoice::Big,
};

pub const V0_10_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:
ShortintKeySwitchingParameters =
V0_10_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
Expand Down
2 changes: 1 addition & 1 deletion tfhe/src/shortint/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use super::ciphertext::{Ciphertext, CompressedCiphertext, PBSOrder};
pub use super::client_key::ClientKey;
pub use super::gen_keys;
pub use super::key_switching_key::KeySwitchingKey;
pub use super::parameters::key_switching::p_fail_2_minus_64::ks_pbs::PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
pub use super::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
pub use super::parameters::{
CarryModulus, CiphertextModulus, ClassicPBSParameters, DecompositionBaseLog,
DecompositionLevelCount, EncryptionKeyChoice, GlweDimension, LweDimension, MaxNoiseLevel,
Expand Down

0 comments on commit 71fb6c5

Please sign in to comment.