Skip to content

Commit

Permalink
chore(shortint): move tuniform 0.10 parameters into their own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarlin-zama committed Dec 20, 2024
1 parent bd2d649 commit 325fe6e
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,3 @@ pub const V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: ClassicPBSParamete
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};

// security = 132 bits, p-fail = 2^-64.138, algorithmic cost ~ 113, 2-norm = 5
pub const V0_10_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: ClassicPBSParameters =
ClassicPBSParameters {
lwe_dimension: LweDimension(887),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_noise_distribution: DynamicDistribution::new_t_uniform(46),
glwe_noise_distribution: DynamicDistribution::new_t_uniform(17),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
max_noise_level: MaxNoiseLevel::new(5),
log2_p_fail: -64.138,
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,3 @@ pub const V0_11_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1:
expansion_kind: CompactCiphertextListExpansionKind::RequiresCasting,
}
.validate();

/// This legacy parameter set were used with the v1 pke zk scheme on TFHE-rs v0.10 and lower
pub const V0_10_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1:
CompactPublicKeyEncryptionParameters = CompactPublicKeyEncryptionParameters {
encryption_lwe_dimension: LweDimension(1024),
encryption_noise_distribution: DynamicDistribution::new_t_uniform(42),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
expansion_kind: CompactCiphertextListExpansionKind::RequiresCasting,
}
.validate();
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,3 @@ pub const V0_11_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M6
ks_base_log: DecompositionBaseLog(24),
destination_key: EncryptionKeyChoice::Big,
};

// These are the same parameters as they where defined in TFHE-rs 0.10 and before
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;

pub const V0_10_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:
ShortintKeySwitchingParameters = ShortintKeySwitchingParameters {
ks_level: DecompositionLevelCount(5),
ks_base_log: DecompositionBaseLog(3),
destination_key: EncryptionKeyChoice::Small,
};

pub const V0_10_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:
ShortintKeySwitchingParameters = ShortintKeySwitchingParameters {
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(27),
destination_key: EncryptionKeyChoice::Big,
};
3 changes: 3 additions & 0 deletions tfhe/src/shortint/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub use crate::shortint::parameters::v0_10::classic::compact_pk::gaussian::p_fai
pub use crate::shortint::parameters::v0_10::classic::gaussian::p_fail_2_minus_64::ks_pbs::*;
pub use crate::shortint::parameters::v0_10::classic::gaussian::p_fail_2_minus_64::pbs_ks::*;
pub use crate::shortint::parameters::v0_10::multi_bit::gaussian::p_fail_2_minus_64::ks_pbs::*;
pub use crate::shortint::parameters::v0_10::classic::tuniform::p_fail_2_minus_64::ks_pbs::*;
pub use crate::shortint::parameters::v0_10::key_switching::p_fail_2_minus_64::ks_pbs::*;
pub use crate::shortint::parameters::v0_10::compact_public_key_only::p_fail_2_minus_64::ks_pbs::*;

#[cfg(tarpaulin)]
pub use coverage_parameters::*;
Expand Down
1 change: 1 addition & 0 deletions tfhe/src/shortint/parameters/v0_10/classic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod compact_pk;
pub mod gaussian;
pub mod tuniform;
1 change: 1 addition & 0 deletions tfhe/src/shortint/parameters/v0_10/classic/tuniform/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod p_fail_2_minus_64;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::core_crypto::prelude::*;
use crate::shortint::{CarryModulus, ClassicPBSParameters, MaxNoiseLevel, MessageModulus};

// security = 132 bits, p-fail = 2^-64.138, algorithmic cost ~ 113, 2-norm = 5
pub const V0_10_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: ClassicPBSParameters =
ClassicPBSParameters {
lwe_dimension: LweDimension(887),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_noise_distribution: DynamicDistribution::new_t_uniform(46),
glwe_noise_distribution: DynamicDistribution::new_t_uniform(17),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
max_noise_level: MaxNoiseLevel::new(5),
log2_p_fail: -64.138,
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod ks_pbs;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod p_fail_2_minus_64;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::core_crypto::commons::parameters::{
CiphertextModulus, DynamicDistribution, LweDimension,
};
use crate::shortint::parameters::{
CarryModulus, CompactCiphertextListExpansionKind, CompactPublicKeyEncryptionParameters,
MessageModulus,
};

/// This legacy parameter set were used with the v1 pke zk scheme on TFHE-rs v0.10 and lower
pub const V0_10_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1:
CompactPublicKeyEncryptionParameters = CompactPublicKeyEncryptionParameters {
encryption_lwe_dimension: LweDimension(1024),
encryption_noise_distribution: DynamicDistribution::new_t_uniform(42),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
expansion_kind: CompactCiphertextListExpansionKind::RequiresCasting,
}
.validate();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod ks_pbs;
1 change: 1 addition & 0 deletions tfhe/src/shortint/parameters/v0_10/key_switching/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod p_fail_2_minus_64;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::shortint::parameters::{
DecompositionBaseLog, DecompositionLevelCount, EncryptionKeyChoice,
ShortintKeySwitchingParameters,
};

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;

pub const V0_10_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:
ShortintKeySwitchingParameters = ShortintKeySwitchingParameters {
ks_level: DecompositionLevelCount(5),
ks_base_log: DecompositionBaseLog(3),
destination_key: EncryptionKeyChoice::Small,
};

pub const V0_10_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:
ShortintKeySwitchingParameters = ShortintKeySwitchingParameters {
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(27),
destination_key: EncryptionKeyChoice::Big,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod ks_pbs;
6 changes: 6 additions & 0 deletions tfhe/src/shortint/parameters/v0_10/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
//! FHE Parameters as they were defined in TFHE-rs 0.10 and before.
//!
//! These parameters may be used for backward compatibility.
pub mod classic;
pub mod compact_public_key_only;
pub mod key_switching;
pub mod multi_bit;

0 comments on commit 325fe6e

Please sign in to comment.