Skip to content

Commit

Permalink
chore(tfhe): update boolean and shortint parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
soonum committed Sep 24, 2024
1 parent 1c0b6fb commit 98c6b66
Show file tree
Hide file tree
Showing 8 changed files with 545 additions and 548 deletions.
84 changes: 3 additions & 81 deletions tfhe/src/boolean/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
//! Failing to properly fix the parameters will potentially result with an incorrect and/or insecure
//! computation.
pub mod params;

pub use crate::core_crypto::commons::dispersion::StandardDev;
pub use crate::core_crypto::commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, DynamicDistribution, EncryptionKeyChoice,
GlweDimension, LweDimension, PolynomialSize,
};
pub use params::*;

use serde::{Deserialize, Serialize};
use tfhe_versionable::Versionize;
Expand Down Expand Up @@ -121,87 +124,6 @@ impl BooleanKeySwitchingParameters {
}
}

/// Default parameter set.
///
/// This parameter set ensures 128-bits of security, and a probability of error is upper-bounded by
/// $2^{-40}$. The secret keys generated with this parameter set are uniform binary.
/// This parameter set allows to evaluate faster Boolean circuits than the `TFHE_LIB_PARAMETERS`
/// one.
pub const DEFAULT_PARAMETERS: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(811),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
#[allow(clippy::excessive_precision)]
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
5.2851456906764125e-06,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.315272083503367e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
encryption_key_choice: EncryptionKeyChoice::Small,
};

pub const DEFAULT_PARAMETERS_KS_PBS: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(746),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
#[allow(clippy::excessive_precision)]
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
1.622209113562635e-05,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.315272083503367e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(4),
encryption_key_choice: EncryptionKeyChoice::Big,
};

/// The secret keys generated with this parameter set are uniform binary.
/// This parameter set ensures a probability of error upper-bounded by $2^{-165}$
/// for for 128-bits of security.
pub const PARAMETERS_ERROR_PROB_2_POW_MINUS_165: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(843),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
#[allow(clippy::excessive_precision)]
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
3.0428362050688556e-06,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.313225746198247e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
encryption_key_choice: EncryptionKeyChoice::Small,
};

pub const PARAMETERS_ERROR_PROB_2_POW_MINUS_165_KS_PBS: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(776),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
#[allow(clippy::excessive_precision)]
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.66750902600141e-06,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.313225746198247e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
encryption_key_choice: EncryptionKeyChoice::Big,
};

/// Parameter sets given in TFHE-lib:
/// <https://github.com/tfhe/tfhe/blob/bc71bfae7ad9d5f8ce5f29bdfd691189bfe207f3/src/libtfhe/tfhe_gate_bootstrapping.cpp#L51>
/// Original security in 2020 was 129-bits, while it is currently around 120 bits.
Expand Down
76 changes: 76 additions & 0 deletions tfhe/src/boolean/parameters/params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use crate::boolean::parameters::BooleanParameters;
use crate::core_crypto::prelude::*;
/// Default parameter set.
///
/// This parameter set ensures 132-bits of security, and a probability of error is upper-bounded by
/// $2^{-64}$. The secret keys generated with this parameter set are uniform binary.
/// This parameter set allows to evaluate faster Boolean circuits than the `TFHE_LIB_PARAMETERS`
/// one.
// p-fail = 2^-64.344, algorithmic cost ~ 75, 2-norm = 2.8284271247461903
pub const DEFAULT_PARAMETERS: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(805),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
5.861_589_664_267_133_6e-06,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.315272083503367e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
encryption_key_choice: EncryptionKeyChoice::Small,
};
// p-fail = 2^-64.017, algorithmic cost ~ 67, 2-norm = 2.8284271247461903
pub const DEFAULT_PARAMETERS_KS_PBS: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(739),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
1.830_452_073_350_730_5e-05,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.315272083503367e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(4),
encryption_key_choice: EncryptionKeyChoice::Big,
};
// p-fail = 2^-165.434, algorithmic cost ~ 117, 2-norm = 2.8284271247461903
pub const PARAMETERS_ERROR_PROB_2_POW_MINUS_165: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(837),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
3.374_714_376_692_653e-06,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.313225746198247e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
encryption_key_choice: EncryptionKeyChoice::Small,
};
// p-fail = 2^-166.826, algorithmic cost ~ 108, 2-norm = 2.8284271247461903
pub const PARAMETERS_ERROR_PROB_2_POW_MINUS_165_KS_PBS: BooleanParameters = BooleanParameters {
lwe_dimension: LweDimension(770),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
1.072_193_169_648_034_2e-05,
)),
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
9.313225746198247e-10,
)),
pbs_base_log: DecompositionBaseLog(10),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(3),
ks_level: DecompositionLevelCount(5),
encryption_key_choice: EncryptionKeyChoice::Big,
};
Loading

0 comments on commit 98c6b66

Please sign in to comment.