chore(shortint): update param compact key

This commit is contained in:
J-B Orfila
2023-06-13 13:44:46 +02:00
committed by Arthur Meyre
parent 61819b2cea
commit a8e8a2e555
16 changed files with 1352 additions and 360 deletions

View File

@@ -192,7 +192,7 @@ int main(void) {
config_builder_all_disabled(&builder);
config_builder_enable_custom_integers(&builder,
SHORTINT_PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
SHORTINT_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
config_builder_build(builder, &config);
ClientKey *client_key = NULL;

View File

@@ -10,7 +10,7 @@ use tfhe::integer::U256;
use tfhe::prelude::*;
use tfhe::shortint::keycache::NamedParam;
use tfhe::shortint::parameters::{
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK, PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK, PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
};
use tfhe::{
generate_keys, CompactFheUint256List, CompactFheUint32List, CompactPublicKey, ConfigBuilder,
@@ -95,7 +95,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
}
{
let params = PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK;
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL;
let config = ConfigBuilder::all_disabled()
.enable_custom_integers(params, None)
.build();
@@ -199,7 +199,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
}
{
let params = PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK;
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL;
let config = ConfigBuilder::all_disabled()
.enable_custom_integers(params, None)
.build();

View File

@@ -11,7 +11,7 @@ use std::io::Write;
use std::path::Path;
use tfhe::shortint::keycache::NamedParam;
use tfhe::shortint::parameters::{
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK, PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK, PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
};
use tfhe::shortint::ClassicPBSParameters;
@@ -24,7 +24,7 @@ struct Args {
fn params_from_name(name: &str) -> ClassicPBSParameters {
match name.to_lowercase().as_str() {
"param_message_2_carry_2_compact_pk" => PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
"param_small_message_2_carry_2_compact_pk" => PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
"param_message_2_carry_2_compact_pk_small" => PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
_ => panic!("failed to get parameters for name '{name}'"),
}
}

View File

@@ -351,7 +351,7 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint32_big_single', (t) => {
});
test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_single', (t) => {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -375,7 +375,7 @@ function hlapi_compact_public_key_encrypt_decrypt_uint32_single_compact(config)
}
test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_single_compact', (t) => {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -425,7 +425,7 @@ function hlapi_compact_public_key_encrypt_decrypt_uint32_list_compact(config) {
}
test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_list_compact', (t) => {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -471,7 +471,7 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint256_big_single', (t) => {
});
test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_single', (t) => {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -495,7 +495,7 @@ function hlapi_compact_public_key_encrypt_decrypt_uint256_single_compact(config)
}
test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_single_compact', (t) => {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -545,7 +545,7 @@ function hlapi_compact_public_key_encrypt_decrypt_uint256_list_compact(config) {
}
test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_list_compact', (t) => {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();

View File

@@ -3,6 +3,8 @@ pub use crate::core_crypto::commons::dispersion::StandardDev;
pub use crate::core_crypto::commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
pub use crate::shortint::parameters::parameters_compact_pk::*;
pub use crate::shortint::parameters::*;
use std::os::raw::c_int;
use crate::shortint;
@@ -130,7 +132,7 @@ macro_rules! expose_as_shortint_pbs_parameters(
$(
#[no_mangle]
pub static [<SHORTINT_ $param_name>]: ShortintPBSParameters =
ShortintPBSParameters::convert(crate::shortint::parameters::$param_name);
ShortintPBSParameters::convert($param_name);
)*
}
@@ -198,7 +200,7 @@ expose_as_shortint_pbs_parameters!(
PARAM_SMALL_MESSAGE_2_CARRY_2,
PARAM_SMALL_MESSAGE_3_CARRY_3,
PARAM_SMALL_MESSAGE_4_CARRY_4,
PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
);
#[no_mangle]

View File

@@ -420,7 +420,7 @@ fn test_decompressed_public_key_encrypt() {
fn test_compact_public_key_big() {
let config = ConfigBuilder::all_disabled()
.enable_custom_integers(
crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
crate::shortint::parameters::parameters_compact_pk::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
None,
)
.build();
@@ -437,7 +437,7 @@ fn test_compact_public_key_big() {
fn test_compact_public_key_list_big() {
let config = ConfigBuilder::all_disabled()
.enable_custom_integers(
crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
crate::shortint::parameters::parameters_compact_pk::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
None,
)
.build();
@@ -448,7 +448,8 @@ fn test_compact_public_key_list_big() {
fn test_compact_public_key_list_small() {
let config = ConfigBuilder::all_disabled()
.enable_custom_integers(
crate::shortint::parameters::PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
crate::shortint::parameters::parameters_compact_pk
::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
None,
)
.build();
@@ -495,7 +496,8 @@ fn test_compact_public_key_list(config: Config) {
fn test_compact_public_key_small() {
let config = ConfigBuilder::all_disabled()
.enable_custom_integers(
crate::shortint::parameters::PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
crate::shortint::parameters::parameters_compact_pk
::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
None,
)
.build();

View File

@@ -22,7 +22,7 @@ create_parametrized_test!(big_radix_encrypt_decrypt_compact_128_bits_list {
});
create_parametrized_test!(small_radix_encrypt_decrypt_compact_128_bits_list {
PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL
});
/// Test that the public key can encrypt a 128 bit number

View File

@@ -1,6 +1,8 @@
use crate::core_crypto::commons::generators::DeterministicSeeder;
pub use crate::core_crypto::commons::math::random::Seed;
use crate::core_crypto::prelude::ActivatedRandomGenerator;
pub use crate::shortint::parameters::parameters_compact_pk::*;
pub use crate::shortint::parameters::*;
use bincode;
use wasm_bindgen::prelude::*;
@@ -71,7 +73,7 @@ macro_rules! expose_predefined_parameters {
match name {
$(
ShortintParametersName::$param_name => {
Self(crate::shortint::parameters::$param_name)
Self($param_name)
}
)*
}
@@ -124,7 +126,7 @@ expose_predefined_parameters! {
PARAM_SMALL_MESSAGE_4_CARRY_4,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
}
#[wasm_bindgen]

View File

@@ -1,3 +1,5 @@
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::*;
@@ -258,7 +260,7 @@ impl NamedParam for ShortintParameterSet {
PARAM_SMALL_MESSAGE_2_CARRY_2,
PARAM_SMALL_MESSAGE_3_CARRY_3,
PARAM_SMALL_MESSAGE_4_CARRY_4,
PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
// MultiBit Group 2
PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2,

View File

@@ -14,11 +14,15 @@ use crate::shortint::ciphertext::PBSOrder;
use serde::{Deserialize, Serialize};
pub mod key_switching;
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 use key_switching::ShortintKeySwitchingParameters;
pub use multi_bit::*;
pub use parameters_compact_pk::*;
pub use parameters_wopbs::WopbsParameters;
/// The choice of encryption key for (`shortint ciphertext`)[`super::ciphertext::Ciphertext`].
@@ -120,44 +124,6 @@ impl ClassicPBSParameters {
}
}
/// A structure defining the set of cryptographic parameters for homomorphic integer circuit
/// evaluation. This structure contains information to run the so-called multi-bit PBS with improved
/// latency provided enough threads are available on the machine performing the FHE computations
#[derive(Serialize, Copy, Clone, Deserialize, Debug, PartialEq)]
pub struct MultiBitPBSParameters {
pub lwe_dimension: LweDimension,
pub glwe_dimension: GlweDimension,
pub polynomial_size: PolynomialSize,
pub lwe_modular_std_dev: StandardDev,
pub glwe_modular_std_dev: StandardDev,
pub pbs_base_log: DecompositionBaseLog,
pub pbs_level: DecompositionLevelCount,
pub ks_base_log: DecompositionBaseLog,
pub ks_level: DecompositionLevelCount,
pub message_modulus: MessageModulus,
pub carry_modulus: CarryModulus,
pub ciphertext_modulus: CiphertextModulus,
pub encryption_key_choice: EncryptionKeyChoice,
pub grouping_factor: LweBskGroupingFactor,
pub deterministic_execution: bool,
}
impl MultiBitPBSParameters {
pub const fn with_deterministic_execution(self) -> Self {
Self {
deterministic_execution: true,
..self
}
}
pub const fn with_non_deterministic_execution(self) -> Self {
Self {
deterministic_execution: false,
..self
}
}
}
#[derive(Serialize, Copy, Clone, Deserialize, Debug, PartialEq)]
pub enum PBSParameters {
PBS(ClassicPBSParameters),
@@ -549,18 +515,6 @@ pub const BIVARIATE_PBS_COMPLIANT_PARAMETER_SET_VEC: [ClassicPBSParameters; 16]
PARAM_MESSAGE_4_CARRY_4,
];
/// Vector containing all [`MultiBitPBSParameters`] parameter sets
pub const ALL_MULTI_BIT_PARAMETER_VEC: [MultiBitPBSParameters; 8] = [
PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_3,
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3,
PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_3,
PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_3,
];
/// Nomenclature: PARAM_MESSAGE_X_CARRY_Y: the message (respectively carry) modulus is
/// encoded over X (reps. Y) bits, i.e., message_modulus = 2^{X} (resp. carry_modulus = 2^{Y}).
/// All parameter sets guarantee 128-bits of security and an error probability smaller than
@@ -1170,181 +1124,6 @@ pub const PARAM_SMALL_MESSAGE_4_CARRY_4: ClassicPBSParameters = ClassicPBSParame
encryption_key_choice: EncryptionKeyChoice::Small,
};
// Group 2
pub const PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(764),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_modular_std_dev: StandardDev(0.000006025673585415336),
glwe_modular_std_dev: StandardDev(0.0000000000039666089171633006),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(6),
ks_level: DecompositionLevelCount(2),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(818),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(0.000002226459789930014),
glwe_modular_std_dev: StandardDev(0.0000000000000003152931493498455),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(5),
ks_level: DecompositionLevelCount(3),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(922),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(0.0000003272369292345697),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(4),
ks_level: DecompositionLevelCount(4),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(1052),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(0.000000029779789543501806),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(4),
ks_level: DecompositionLevelCount(5),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
// Group 3
pub const PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(765),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_modular_std_dev: StandardDev(0.000005915594083804978),
glwe_modular_std_dev: StandardDev(0.0000000000039666089171633006),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(6),
ks_level: DecompositionLevelCount(2),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(888),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(0.0000006125031601933181),
glwe_modular_std_dev: StandardDev(0.0000000000000003152931493498455),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(7),
ks_level: DecompositionLevelCount(2),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(972),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(0.00000013016688349592805),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(6),
ks_level: DecompositionLevelCount(3),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(1098),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(0.000000012752307213087621),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(5),
ks_level: DecompositionLevelCount(4),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MESSAGE_2_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(0.000000049029381729),
glwe_modular_std_dev: StandardDev(0.00000000000000031528),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
encryption_key_choice: EncryptionKeyChoice::Small,
..PARAM_MESSAGE_2_CARRY_2_COMPACT_PK
};
/// Return a parameter set from a message and carry moduli.
///
/// # Example

View File

@@ -0,0 +1,214 @@
//! #Warning experimental
pub use crate::core_crypto::commons::dispersion::{DispersionParameter, StandardDev};
pub use crate::core_crypto::commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use crate::shortint::parameters::{
CarryModulus, CiphertextModulus, EncryptionKeyChoice, LweBskGroupingFactor, MessageModulus,
};
use serde::{Deserialize, Serialize};
/// A structure defining the set of cryptographic parameters for homomorphic integer circuit
/// evaluation. This structure contains information to run the so-called multi-bit PBS with improved
/// latency provided enough threads are available on the machine performing the FHE computations
#[derive(Serialize, Copy, Clone, Deserialize, Debug, PartialEq)]
pub struct MultiBitPBSParameters {
pub lwe_dimension: LweDimension,
pub glwe_dimension: GlweDimension,
pub polynomial_size: PolynomialSize,
pub lwe_modular_std_dev: StandardDev,
pub glwe_modular_std_dev: StandardDev,
pub pbs_base_log: DecompositionBaseLog,
pub pbs_level: DecompositionLevelCount,
pub ks_base_log: DecompositionBaseLog,
pub ks_level: DecompositionLevelCount,
pub message_modulus: MessageModulus,
pub carry_modulus: CarryModulus,
pub ciphertext_modulus: CiphertextModulus,
pub encryption_key_choice: EncryptionKeyChoice,
pub grouping_factor: LweBskGroupingFactor,
pub deterministic_execution: bool,
}
impl MultiBitPBSParameters {
pub const fn with_deterministic_execution(self) -> Self {
Self {
deterministic_execution: true,
..self
}
}
pub const fn with_non_deterministic_execution(self) -> Self {
Self {
deterministic_execution: false,
..self
}
}
}
/// Vector containing all [`MultiBitPBSParameters`] parameter sets
pub const ALL_MULTI_BIT_PARAMETER_VEC: [MultiBitPBSParameters; 8] = [
PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_2,
PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_3,
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3,
PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_3,
PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_3,
];
// Group 2
pub const PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(764),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_modular_std_dev: StandardDev(0.000006025673585415336),
glwe_modular_std_dev: StandardDev(0.0000000000039666089171633006),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(6),
ks_level: DecompositionLevelCount(2),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(818),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(0.000002226459789930014),
glwe_modular_std_dev: StandardDev(0.0000000000000003152931493498455),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(5),
ks_level: DecompositionLevelCount(3),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(922),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(0.0000003272369292345697),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(4),
ks_level: DecompositionLevelCount(4),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_2: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(1052),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(0.000000029779789543501806),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(4),
ks_level: DecompositionLevelCount(5),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(2),
deterministic_execution: false,
};
// Group 3
pub const PARAM_MULTI_BIT_MESSAGE_1_CARRY_1_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(765),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_modular_std_dev: StandardDev(0.000005915594083804978),
glwe_modular_std_dev: StandardDev(0.0000000000039666089171633006),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(6),
ks_level: DecompositionLevelCount(2),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(888),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(0.0000006125031601933181),
glwe_modular_std_dev: StandardDev(0.0000000000000003152931493498455),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(7),
ks_level: DecompositionLevelCount(2),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(972),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(0.00000013016688349592805),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(6),
ks_level: DecompositionLevelCount(3),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};
pub const PARAM_MULTI_BIT_MESSAGE_4_CARRY_4_GROUP_3: MultiBitPBSParameters =
MultiBitPBSParameters {
lwe_dimension: LweDimension(1098),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(0.000000012752307213087621),
glwe_modular_std_dev: StandardDev(0.0000000000000000002168404344971009),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(5),
ks_level: DecompositionLevelCount(4),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
grouping_factor: LweBskGroupingFactor(3),
deterministic_execution: false,
};

View File

@@ -0,0 +1,912 @@
//! #Warning experimental
pub use crate::core_crypto::commons::dispersion::{DispersionParameter, StandardDev};
pub use crate::core_crypto::commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use crate::shortint::parameters::{
CarryModulus, CiphertextModulus, EncryptionKeyChoice, MessageModulus,
};
use crate::shortint::ClassicPBSParameters;
pub const ALL_PARAMETER_VEC_COMPACT_PK: [ClassicPBSParameters; 56] = [
PARAM_MESSAGE_1_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_5_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_6_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_7_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_5_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_6_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_5_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_5_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_5_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_5_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_6_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_6_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_7_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_5_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_6_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_7_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_5_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_6_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_5_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_5_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_5_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_5_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_6_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_6_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_7_CARRY_1_COMPACT_PK_SMALL,
];
pub const PARAM_MESSAGE_1_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.96669408172410e-12),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(12),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_1_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_1_CARRY_3_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_1_CARRY_4_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_1_CARRY_5_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(32),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_1_CARRY_6_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(64),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_1_CARRY_7_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(128),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_2_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_2_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_2_CARRY_3_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_2_CARRY_4_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_2_CARRY_5_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(32),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_2_CARRY_6_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(64),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_3_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_3_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_3_CARRY_3_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_3_CARRY_4_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_3_CARRY_5_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(32),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_4_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_4_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_4_CARRY_3_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_4_CARRY_4_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_5_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(32),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_5_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(32),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_5_CARRY_3_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(32),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_6_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(64),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_6_CARRY_2_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(64),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
pub const PARAM_MESSAGE_7_CARRY_1_COMPACT_PK: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(128),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
};
// Parameter set for small
pub const PARAM_MESSAGE_1_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(3),
polynomial_size: PolynomialSize(512),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.96669408172410e-12),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_1_CARRY_2_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(18),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_1_CARRY_3_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_1_CARRY_4_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_1_CARRY_5_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(32),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_1_CARRY_6_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(5),
ks_base_log: DecompositionBaseLog(4),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(64),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_1_CARRY_7_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(11),
ks_base_log: DecompositionBaseLog(2),
message_modulus: MessageModulus(2),
carry_modulus: CarryModulus(128),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_2_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(2),
polynomial_size: PolynomialSize(1024),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(8),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_2_CARRY_3_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(21),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_2_CARRY_4_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_2_CARRY_5_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(32),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_2_CARRY_6_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(65536),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(64),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_3_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(3.15283466779972e-16),
pbs_base_log: DecompositionBaseLog(22),
pbs_level: DecompositionLevelCount(1),
ks_level: DecompositionLevelCount(3),
ks_base_log: DecompositionBaseLog(6),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_3_CARRY_2_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(4),
ks_base_log: DecompositionBaseLog(5),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_3_CARRY_3_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(7),
ks_base_log: DecompositionBaseLog(3),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_3_CARRY_4_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(22),
ks_base_log: DecompositionBaseLog(1),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_3_CARRY_5_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(65536),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(8),
carry_modulus: CarryModulus(32),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_4_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(12),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(11),
ks_base_log: DecompositionBaseLog(2),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_4_CARRY_2_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(1024),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(8192),
lwe_modular_std_dev: StandardDev(4.99029381172945e-8),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(9),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(21),
ks_base_log: DecompositionBaseLog(1),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_4_CARRY_3_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_4_CARRY_4_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(65536),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(16),
carry_modulus: CarryModulus(16),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_5_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(16384),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(32),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_5_CARRY_2_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(14),
pbs_level: DecompositionLevelCount(2),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(32),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_5_CARRY_3_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(65536),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(32),
carry_modulus: CarryModulus(8),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_6_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(32768),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(25),
message_modulus: MessageModulus(64),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_6_CARRY_2_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(65536),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(11),
pbs_level: DecompositionLevelCount(3),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(17),
message_modulus: MessageModulus(64),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};
pub const PARAM_MESSAGE_7_CARRY_1_COMPACT_PK_SMALL: ClassicPBSParameters = ClassicPBSParameters {
lwe_dimension: LweDimension(2048),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(65536),
lwe_modular_std_dev: StandardDev(3.15283466779972e-16),
glwe_modular_std_dev: StandardDev(2.16840434497101e-19),
pbs_base_log: DecompositionBaseLog(9),
pbs_level: DecompositionLevelCount(4),
ks_level: DecompositionLevelCount(2),
ks_base_log: DecompositionBaseLog(17),
message_modulus: MessageModulus(128),
carry_modulus: CarryModulus(2),
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Small,
};

View File

@@ -0,0 +1,2 @@
pub mod shortint;
pub mod shortint_compact_pk;

View File

@@ -3157,109 +3157,3 @@ where
println!("(msg_true - msg_false) * control_bit + msg_false = {clear_mux}, res = {dec_res}");
assert_eq!(clear_mux, dec_res);
}
create_parametrized_test!(test_shortint_compact_public_key_base_smart_add {
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK
});
fn test_shortint_compact_public_key_base_smart_add(params: ClassicPBSParameters) {
let (cks, sks) = crate::shortint::gen_keys(params);
let pk = crate::shortint::CompactPublicKey::new(&cks);
let mut rng = rand::thread_rng();
let modulus = cks.parameters.message_modulus().0 as u64;
for _ in 0..NB_TEST {
let clear_0 = rng.gen::<u64>() % modulus;
let clear_1 = rng.gen::<u64>() % modulus;
let mut ctxt_0 = pk.encrypt(clear_0);
let ctxt_1 = pk.encrypt(clear_1);
let d = cks.decrypt(&ctxt_0);
assert_eq!(d, clear_0);
let d = cks.decrypt(&ctxt_1);
assert_eq!(d, clear_1);
let mut ct_res = sks.unchecked_add(&ctxt_0, &ctxt_1);
let mut clear = clear_0 + clear_1;
let d = cks.decrypt(&ct_res);
assert_eq!(d, clear % modulus);
//add multiple times to raise the degree and test the smart operation
for _ in 0..40 {
sks.smart_add_assign(&mut ct_res, &mut ctxt_0);
clear += clear_0;
// decryption of ct_res
let dec_res = cks.decrypt(&ct_res);
// assert
assert_eq!(clear % modulus, dec_res);
}
}
}
create_parametrized_test!(test_shortint_compact_public_key_base_list_smart_sub {
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK
});
fn test_shortint_compact_public_key_base_list_smart_sub(params: ClassicPBSParameters) {
let (cks, sks) = crate::shortint::gen_keys(params);
let pk = crate::shortint::CompactPublicKey::new(&cks);
let mut rng = rand::thread_rng();
let modulus = cks.parameters.message_modulus().0 as u64;
const MAX_CT: usize = 5;
let mut first_clear_vec = Vec::with_capacity(MAX_CT);
let mut second_clear_vec = Vec::with_capacity(MAX_CT);
for _ in 0..(NB_TEST / 2).min(5) {
let num_ct_for_this_iter = rng.gen_range(1..=MAX_CT);
first_clear_vec.truncate(0);
second_clear_vec.truncate(0);
for _ in 0..num_ct_for_this_iter {
let clear_0 = rng.gen::<u64>() % modulus;
let clear_1 = rng.gen::<u64>() % modulus;
first_clear_vec.push(clear_0);
second_clear_vec.push(clear_1);
}
let first_compact_list = pk.encrypt_slice(&first_clear_vec);
let second_compact_list = pk.encrypt_slice(&second_clear_vec);
let mut first_expanded_vec = first_compact_list.expand();
let mut second_expanded_vec = second_compact_list.expand();
// decryption check
for i in 0..num_ct_for_this_iter {
let decrypted_0 = cks.decrypt(&first_expanded_vec[i]);
let decrypted_1 = cks.decrypt(&second_expanded_vec[i]);
assert_eq!(decrypted_0, first_clear_vec[i]);
assert_eq!(decrypted_1, second_clear_vec[i]);
}
for _ in 0..10 {
for i in 0..num_ct_for_this_iter {
sks.smart_sub_assign(&mut first_expanded_vec[i], &mut second_expanded_vec[i]);
first_clear_vec[i] = first_clear_vec[i].wrapping_sub(second_clear_vec[i]);
let decrypted_0 = cks.decrypt(&first_expanded_vec[i]);
let decrypted_1 = cks.decrypt(&second_expanded_vec[i]);
assert_eq!(decrypted_0, first_clear_vec[i] % modulus);
assert_eq!(decrypted_1, second_clear_vec[i] % modulus);
}
}
}
}

View File

@@ -0,0 +1,183 @@
// use crate::shortint::keycache::KEY_CACHE;
use crate::shortint::parameters::parameters_compact_pk::*;
use crate::shortint::parameters::*;
use paste::paste;
use rand::Rng;
/// Number of assert in randomized tests
const NB_TEST: usize = 30;
// Macro to generate tests for all parameter sets
macro_rules! create_parametrized_test{
($name:ident { $($param:ident),* }) => {
paste! {
$(
#[test]
fn [<test_ $name _ $param:lower>]() {
$name($param)
}
)*
}
};
($name:ident)=> {
create_parametrized_test!($name
{
PARAM_MESSAGE_1_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_5_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_6_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_7_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_5_COMPACT_PK,
PARAM_MESSAGE_2_CARRY_6_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_3_CARRY_5_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_4_CARRY_4_COMPACT_PK,
PARAM_MESSAGE_5_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_5_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_5_CARRY_3_COMPACT_PK,
PARAM_MESSAGE_6_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_6_CARRY_2_COMPACT_PK,
PARAM_MESSAGE_7_CARRY_1_COMPACT_PK,
PARAM_MESSAGE_1_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_5_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_6_COMPACT_PK_SMALL,
PARAM_MESSAGE_1_CARRY_7_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_5_COMPACT_PK_SMALL,
PARAM_MESSAGE_2_CARRY_6_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_3_CARRY_5_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_4_CARRY_4_COMPACT_PK_SMALL,
PARAM_MESSAGE_5_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_5_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_5_CARRY_3_COMPACT_PK_SMALL,
PARAM_MESSAGE_6_CARRY_1_COMPACT_PK_SMALL,
PARAM_MESSAGE_6_CARRY_2_COMPACT_PK_SMALL,
PARAM_MESSAGE_7_CARRY_1_COMPACT_PK_SMALL
});
};
}
create_parametrized_test!(shortint_compact_public_key_base_smart_add);
fn shortint_compact_public_key_base_smart_add(params: ClassicPBSParameters) {
let (cks, sks) = crate::shortint::gen_keys(params);
let pk = crate::shortint::CompactPublicKey::new(&cks);
let mut rng = rand::thread_rng();
let modulus = cks.parameters.message_modulus().0 as u64;
for _ in 0..NB_TEST {
let clear_0 = rng.gen::<u64>() % modulus;
let clear_1 = rng.gen::<u64>() % modulus;
let mut ctxt_0 = pk.encrypt(clear_0);
let ctxt_1 = pk.encrypt(clear_1);
let d = cks.decrypt(&ctxt_0);
assert_eq!(d, clear_0);
let d = cks.decrypt(&ctxt_1);
assert_eq!(d, clear_1);
let mut ct_res = sks.unchecked_add(&ctxt_0, &ctxt_1);
let mut clear = clear_0 + clear_1;
let d = cks.decrypt(&ct_res);
assert_eq!(d, clear % modulus);
//add multiple times to raise the degree and test the smart operation
for _ in 0..40 {
sks.smart_add_assign(&mut ct_res, &mut ctxt_0);
clear += clear_0;
// decryption of ct_res
let dec_res = cks.decrypt(&ct_res);
// assert
assert_eq!(clear % modulus, dec_res);
}
}
}
create_parametrized_test!(shortint_compact_public_key_base_list_smart_sub);
fn shortint_compact_public_key_base_list_smart_sub(params: ClassicPBSParameters) {
let (cks, sks) = crate::shortint::gen_keys(params);
let pk = crate::shortint::CompactPublicKey::new(&cks);
let mut rng = rand::thread_rng();
let modulus = cks.parameters.message_modulus().0 as u64;
const MAX_CT: usize = 5;
let mut first_clear_vec = Vec::with_capacity(MAX_CT);
let mut second_clear_vec = Vec::with_capacity(MAX_CT);
for _ in 0..(NB_TEST / 2).min(5) {
let num_ct_for_this_iter = rng.gen_range(1..=MAX_CT);
first_clear_vec.truncate(0);
second_clear_vec.truncate(0);
for _ in 0..num_ct_for_this_iter {
let clear_0 = rng.gen::<u64>() % modulus;
let clear_1 = rng.gen::<u64>() % modulus;
first_clear_vec.push(clear_0);
second_clear_vec.push(clear_1);
}
let first_compact_list = pk.encrypt_slice(&first_clear_vec);
let second_compact_list = pk.encrypt_slice(&second_clear_vec);
let mut first_expanded_vec = first_compact_list.expand();
let mut second_expanded_vec = second_compact_list.expand();
// decryption check
for i in 0..num_ct_for_this_iter {
let decrypted_0 = cks.decrypt(&first_expanded_vec[i]);
let decrypted_1 = cks.decrypt(&second_expanded_vec[i]);
assert_eq!(decrypted_0, first_clear_vec[i]);
assert_eq!(decrypted_1, second_clear_vec[i]);
}
for _ in 0..10 {
for i in 0..num_ct_for_this_iter {
sks.smart_sub_assign(&mut first_expanded_vec[i], &mut second_expanded_vec[i]);
first_clear_vec[i] = first_clear_vec[i].wrapping_sub(second_clear_vec[i]);
let decrypted_0 = cks.decrypt(&first_expanded_vec[i]);
let decrypted_1 = cks.decrypt(&second_expanded_vec[i]);
assert_eq!(decrypted_0, first_clear_vec[i] % modulus);
assert_eq!(decrypted_1, second_clear_vec[i] % modulus);
}
}
}
}

View File

@@ -155,7 +155,7 @@ async function compactPublicKeyTest32BitBig() {
}
async function compactPublicKeyTest32BitSmall() {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -230,13 +230,13 @@ async function compactPublicKeyBench32BitBig() {
}
async function compactPublicKeyBench32BitSmall() {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
return append_param_name(
await compactPublicKeyBench32BitOnConfig(config),
"PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK"
"PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL"
);
}
@@ -293,7 +293,7 @@ async function compactPublicKeyTest256BitBig() {
}
async function compactPublicKeyTest256BitSmall() {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -358,7 +358,7 @@ async function compressedCompactPublicKeyTest256BitBig() {
}
async function compressedCompactPublicKeyTest256BitSmall() {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
@@ -433,13 +433,13 @@ async function compactPublicKeyBench256BitBig() {
}
async function compactPublicKeyBench256BitSmall() {
const block_params = new ShortintParameters(ShortintParametersName.PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK);
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL);
let config = TfheConfigBuilder.all_disabled()
.enable_custom_integers(block_params)
.build();
return append_param_name(
await compactPublicKeyBench256BitOnConfig(config),
"PARAM_SMALL_MESSAGE_2_CARRY_2_COMPACT_PK"
"PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_SMALL"
);
}