diff --git a/Cargo.toml b/Cargo.toml index 445307b..7b5e330 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,20 @@ edition = "2021" [dependencies] # This is a list of tfhe-rs versions we will generate data for. This list will grow over time. # They are only activated when generating data, with the binary target and the "generate" feature. -tfhe_0_6 = { version = "0.6", features = ["boolean", "integer", "shortint", "x86_64-unix", "experimental-force_fft_algo_dif4"], package = "tfhe", optional = true } -tfhe_0_7 = { version = "0.7", features = ["boolean", "integer", "shortint", "x86_64-unix", "experimental-force_fft_algo_dif4"], package = "tfhe", optional = true } +tfhe_0_6 = { version = "0.6", features = [ + "boolean", + "integer", + "shortint", + "x86_64-unix", + "experimental-force_fft_algo_dif4", +], package = "tfhe", optional = true } +tfhe_0_7 = { version = "0.7", features = [ + "boolean", + "integer", + "shortint", + "x86_64-unix", + "experimental-force_fft_algo_dif4", +], package = "tfhe", optional = true } tfhe-versionable_0_1 = { version = "0.1", optional = true, package = "tfhe-versionable" } tfhe-versionable_0_2 = { version = "0.2", optional = true, package = "tfhe-versionable" } @@ -30,5 +42,12 @@ required-features = ["generate"] [features] default = ["generate"] -generate = ["dep:tfhe_0_6", "dep:tfhe_0_7", "dep:tfhe-versionable_0_1", "dep:tfhe-versionable_0_2"] +generate = [ + "dep:tfhe_0_6", + "dep:tfhe_0_7", + "dep:tfhe-versionable_0_1", + "dep:tfhe-versionable_0_2", +] load = ["dep:semver"] + +[workspace] diff --git a/data/0_7/high_level_api/client_key_with_compression.bcode b/data/0_7/high_level_api/client_key_with_compression.bcode new file mode 100644 index 0000000..359ab92 --- /dev/null +++ b/data/0_7/high_level_api/client_key_with_compression.bcode @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9351118470e73eeafb7e106d179ba934362aa35edab8db4339a33ecb651a7f80 +size 33167 diff --git a/data/0_7/high_level_api/client_key_with_compression.cbor b/data/0_7/high_level_api/client_key_with_compression.cbor new file mode 100644 index 0000000..5db721a --- /dev/null +++ b/data/0_7/high_level_api/client_key_with_compression.cbor @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa27dc2ea178bc9a55d7f6c5b3a6140c13aa85eece2049d6798d4f4bd0aa9dc5 +size 5075 diff --git a/data/0_7/high_level_api/server_key_with_compression.bcode b/data/0_7/high_level_api/server_key_with_compression.bcode new file mode 100644 index 0000000..cfa2b70 --- /dev/null +++ b/data/0_7/high_level_api/server_key_with_compression.bcode @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f466228bda0eb39feb4dd285355a8447ab40540dc7255167f3b706e4cd0a0e57 +size 246579464 diff --git a/data/0_7/high_level_api/server_key_with_compression.cbor b/data/0_7/high_level_api/server_key_with_compression.cbor new file mode 100644 index 0000000..ca328f2 --- /dev/null +++ b/data/0_7/high_level_api/server_key_with_compression.cbor @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7685373d5af746ad42e85a9517772abfbb1c47ec8275c4510a79d2ece2eefd80 +size 285713294 diff --git a/data/high_level_api.ron b/data/high_level_api.ron index e3440b3..26d7d15 100644 --- a/data/high_level_api.ron +++ b/data/high_level_api.ron @@ -347,4 +347,37 @@ ], )), ), + ( + tfhe_version_min: "0.7", + tfhe_module: "high_level_api", + metadata: HlClientKey(( + test_filename: "client_key_with_compression", + parameters: ( + lwe_dimension: 761, + glwe_dimension: 1, + polynomial_size: 2048, + lwe_noise_gaussian_stddev: 0.00000636835566258815, + glwe_noise_gaussian_stddev: 0.00000000000000031529322391500584, + pbs_base_log: 23, + pbs_level: 1, + ks_base_log: 3, + ks_level: 5, + message_modulus: 4, + ciphertext_modulus: 18446744073709551616, + carry_modulus: 4, + max_noise_level: 5, + log2_p_fail: -40.05, + encryption_key_choice: "big", + ), + )), + ), + ( + tfhe_version_min: "0.7", + tfhe_module: "high_level_api", + metadata: HlServerKey(( + test_filename: "server_key_with_compression", + client_key_filename: "client_key_with_compression.cbor", + compressed: false, + )), + ), ] \ No newline at end of file diff --git a/src/data_0_6.rs b/src/data_0_6.rs index 6d0b28d..d4842cd 100644 --- a/src/data_0_6.rs +++ b/src/data_0_6.rs @@ -1,38 +1,32 @@ -use std::{borrow::Cow, fs::create_dir_all}; - -use tfhe_0_6::{ - boolean::engine::BooleanEngine, - core_crypto::commons::{ - generators::DeterministicSeeder, - math::random::{ActivatedRandomGenerator, Seed}, - }, - generate_keys, - prelude::FheEncrypt, - set_server_key, - shortint::{ - self, - engine::ShortintEngine, - parameters::{ - DecompositionBaseLog, DecompositionLevelCount, DynamicDistribution, GlweDimension, - LweDimension, PolynomialSize, StandardDev, PARAM_MESSAGE_1_CARRY_1_PBS_KS, - }, - CarryModulus, CiphertextModulus, ClassicPBSParameters, EncryptionKeyChoice, MaxNoiseLevel, - MessageModulus, PBSParameters, - }, - ClientKey, CompactFheBool, CompactFheBoolList, CompactFheInt8, CompactFheInt8List, - CompactFheUint8, CompactFheUint8List, CompactPublicKey, CompressedCompactPublicKey, - CompressedFheBool, CompressedFheInt8, CompressedFheUint8, CompressedPublicKey, - CompressedServerKey, ConfigBuilder, FheBool, FheInt8, FheUint8, PublicKey, -}; -use tfhe_versionable_0_1::Versionize; - +use crate::generate::{save_cbor, store_versioned_test_01, TfhersVersion, VALID_TEST_PARAMS}; use crate::{ - generate::{save_cbor, store_versioned_test_01, TfhersVersion, VALID_TEST_PARAMS}, HlBoolCiphertextListTest, HlBoolCiphertextTest, HlCiphertextListTest, HlCiphertextTest, HlClientKeyTest, HlPublicKeyTest, HlServerKeyTest, HlSignedCiphertextListTest, HlSignedCiphertextTest, ShortintCiphertextTest, ShortintClientKeyTest, TestMetadata, TestParameterSet, HL_MODULE_NAME, SHORTINT_MODULE_NAME, }; +use std::borrow::Cow; +use std::fs::create_dir_all; +use tfhe_0_6::boolean::engine::BooleanEngine; +use tfhe_0_6::core_crypto::commons::generators::DeterministicSeeder; +use tfhe_0_6::core_crypto::commons::math::random::{ActivatedRandomGenerator, Seed}; +use tfhe_0_6::prelude::FheEncrypt; +use tfhe_0_6::shortint::engine::ShortintEngine; +use tfhe_0_6::shortint::parameters::{ + DecompositionBaseLog, DecompositionLevelCount, DynamicDistribution, GlweDimension, + LweDimension, PolynomialSize, StandardDev, PARAM_MESSAGE_1_CARRY_1_PBS_KS, +}; +use tfhe_0_6::shortint::{ + self, CarryModulus, CiphertextModulus, ClassicPBSParameters, EncryptionKeyChoice, + MaxNoiseLevel, MessageModulus, PBSParameters, +}; +use tfhe_0_6::{ + generate_keys, set_server_key, ClientKey, CompactFheBool, CompactFheBoolList, CompactFheInt8, + CompactFheInt8List, CompactFheUint8, CompactFheUint8List, CompactPublicKey, + CompressedCompactPublicKey, CompressedFheBool, CompressedFheInt8, CompressedFheUint8, + CompressedPublicKey, CompressedServerKey, ConfigBuilder, FheBool, FheInt8, FheUint8, PublicKey, +}; +use tfhe_versionable_0_1::Versionize; macro_rules! store_versioned_test { ($msg:expr, $dir:expr, $test_filename:expr $(,)? ) => { diff --git a/src/data_0_7.rs b/src/data_0_7.rs index 4476902..e621e79 100644 --- a/src/data_0_7.rs +++ b/src/data_0_7.rs @@ -1,31 +1,28 @@ -use std::{borrow::Cow, fs::create_dir_all}; - -use tfhe_0_7::{ - boolean::engine::BooleanEngine, - core_crypto::commons::{ - generators::DeterministicSeeder, math::random::ActivatedRandomGenerator, - }, - generate_keys, - prelude::FheEncrypt, - set_server_key, - shortint::{ - engine::ShortintEngine, - parameters::{ - DecompositionBaseLog, DecompositionLevelCount, DynamicDistribution, GlweDimension, - LweDimension, PolynomialSize, StandardDev, COMP_PARAM_MESSAGE_2_CARRY_2, - }, - CarryModulus, CiphertextModulus, ClassicPBSParameters, EncryptionKeyChoice, MaxNoiseLevel, - MessageModulus, PBSParameters, - }, - CompactCiphertextList, CompactPublicKey, CompressedCiphertextListBuilder, FheBool, FheInt8, - FheUint8, Seed, +use crate::generate::{ + store_versioned_auxiliary_02, store_versioned_test_02, TfhersVersion, VALID_TEST_PARAMS, }; - use crate::{ - generate::{ - store_versioned_auxiliary_02, store_versioned_test_02, TfhersVersion, VALID_TEST_PARAMS, - }, - DataKind, HlHeterogeneousCiphertextListTest, TestMetadata, TestParameterSet, HL_MODULE_NAME, + DataKind, HlClientKeyTest, HlHeterogeneousCiphertextListTest, HlServerKeyTest, TestMetadata, + TestParameterSet, HL_MODULE_NAME, +}; +use std::borrow::Cow; +use std::fs::create_dir_all; +use tfhe_0_7::boolean::engine::BooleanEngine; +use tfhe_0_7::core_crypto::commons::generators::DeterministicSeeder; +use tfhe_0_7::core_crypto::commons::math::random::ActivatedRandomGenerator; +use tfhe_0_7::prelude::FheEncrypt; +use tfhe_0_7::shortint::engine::ShortintEngine; +use tfhe_0_7::shortint::parameters::{ + DecompositionBaseLog, DecompositionLevelCount, DynamicDistribution, GlweDimension, + LweDimension, PolynomialSize, StandardDev, COMP_PARAM_MESSAGE_2_CARRY_2, +}; +use tfhe_0_7::shortint::{ + CarryModulus, CiphertextModulus, ClassicPBSParameters, EncryptionKeyChoice, MaxNoiseLevel, + MessageModulus, PBSParameters, +}; +use tfhe_0_7::{ + generate_keys, set_server_key, CompactCiphertextList, CompactPublicKey, + CompressedCiphertextListBuilder, FheBool, FheInt8, FheUint8, Seed, }; macro_rules! store_versioned_test { @@ -115,6 +112,17 @@ const HL_COMPRESSED_LIST_TEST: HlHeterogeneousCiphertextListTest = compressed: true, }; +const HL_CLIENTKEY_WITH_COMPRESSION_TEST: HlClientKeyTest = HlClientKeyTest { + test_filename: Cow::Borrowed("client_key_with_compression"), + parameters: VALID_TEST_PARAMS, +}; + +const HL_SERVERKEY_WITH_COMPRESSION_TEST: HlServerKeyTest = HlServerKeyTest { + test_filename: Cow::Borrowed("server_key_with_compression"), + client_key_filename: Cow::Borrowed("client_key_with_compression.cbor"), + compressed: false, +}; + pub struct V0_7; impl TfhersVersion for V0_7 { @@ -145,7 +153,7 @@ impl TfhersVersion for V0_7 { .build(); let (hl_client_key, hl_server_key) = generate_keys(config); - set_server_key(hl_server_key); + set_server_key(hl_server_key.clone()); let compact_pub_key = CompactPublicKey::new(&hl_client_key); @@ -195,10 +203,24 @@ impl TfhersVersion for V0_7 { &HL_COMPRESSED_LIST_TEST.test_filename, ); + store_versioned_test!( + &hl_client_key, + &dir, + &HL_CLIENTKEY_WITH_COMPRESSION_TEST.test_filename, + ); + + store_versioned_test!( + &hl_server_key, + &dir, + &HL_SERVERKEY_WITH_COMPRESSION_TEST.test_filename, + ); + vec![ TestMetadata::HlHeterogeneousCiphertextList(HL_PACKED_COMPACTLIST_TEST), TestMetadata::HlHeterogeneousCiphertextList(HL_COMPACTLIST_TEST), TestMetadata::HlHeterogeneousCiphertextList(HL_COMPRESSED_LIST_TEST), + TestMetadata::HlClientKey(HL_CLIENTKEY_WITH_COMPRESSION_TEST), + TestMetadata::HlServerKey(HL_SERVERKEY_WITH_COMPRESSION_TEST), ] } }