Skip to content

Commit

Permalink
feat: add keys with compression
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeul-zama authored and zama-bot committed Sep 11, 2024
1 parent 022cbe2 commit 53e3fd5
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 2 deletions.
3 changes: 3 additions & 0 deletions data/0_7/high_level_api/client_key_with_compression.bcode
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/0_7/high_level_api/client_key_with_compression.cbor
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/0_7/high_level_api/server_key_with_compression.bcode
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/0_7/high_level_api/server_key_with_compression.cbor
Git LFS file not shown
33 changes: 33 additions & 0 deletions data/high_level_api.ron
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)),
),
]
30 changes: 28 additions & 2 deletions src/data_0_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::generate::{
store_versioned_auxiliary_02, store_versioned_test_02, TfhersVersion, VALID_TEST_PARAMS,
};
use crate::{
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;
Expand Down Expand Up @@ -111,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 {
Expand Down Expand Up @@ -141,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);

Expand Down Expand Up @@ -191,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),
]
}
}

0 comments on commit 53e3fd5

Please sign in to comment.