diff --git a/backends/tfhe-cuda-backend/cuda/src/crypto/keyswitch.cuh b/backends/tfhe-cuda-backend/cuda/src/crypto/keyswitch.cuh index 3e6c87648e..f84fee7030 100644 --- a/backends/tfhe-cuda-backend/cuda/src/crypto/keyswitch.cuh +++ b/backends/tfhe-cuda-backend/cuda/src/crypto/keyswitch.cuh @@ -75,8 +75,7 @@ keyswitch(Torus *lwe_array_out, const Torus *__restrict__ lwe_output_indexes, level_count); Torus state = a_i >> (sizeof(Torus) * 8 - base_log * level_count); - for (int j = level_count - 1; j >= 0; j--) { - // Levels are stored in reverse order + for (int j = 0; j < level_count; j++) { auto ksk_block = get_ith_block(ksk, i, j, lwe_dimension_out, level_count); Torus decomposed = decompose_one(state, mask_mod_b, base_log); @@ -209,8 +208,7 @@ __device__ void packing_keyswitch_lwe_ciphertext_into_glwe_ciphertext( // block of key for current lwe coefficient (cur_input_lwe[i]) auto ksk_block = &fp_ksk[i * ksk_block_size]; - for (int j = level_count - 1; j >= 0; j--) { - // Levels are stored in reverse order + for (int j = 0; j < level_count; j++) { auto ksk_glwe = &ksk_block[j * glwe_size * polynomial_size]; // Iterate through each level and multiply by the ksk piece auto ksk_glwe_chunk = &ksk_glwe[poly_id * coef_per_block]; diff --git a/backends/tfhe-cuda-backend/cuda/src/pbs/bootstrapping_key.cuh b/backends/tfhe-cuda-backend/cuda/src/pbs/bootstrapping_key.cuh index 38f2d60e1c..44df19c900 100644 --- a/backends/tfhe-cuda-backend/cuda/src/pbs/bootstrapping_key.cuh +++ b/backends/tfhe-cuda-backend/cuda/src/pbs/bootstrapping_key.cuh @@ -24,8 +24,8 @@ __device__ const T *get_ith_mask_kth_block(const T *ptr, int i, int k, uint32_t level_count) { return &ptr[get_start_ith_ggsw(i, polynomial_size, glwe_dimension, level_count) + - level * polynomial_size / 2 * (glwe_dimension + 1) * - (glwe_dimension + 1) + + (level_count - level - 1) * polynomial_size / 2 * + (glwe_dimension + 1) * (glwe_dimension + 1) + k * polynomial_size / 2 * (glwe_dimension + 1)]; } @@ -35,8 +35,8 @@ __device__ T *get_ith_mask_kth_block(T *ptr, int i, int k, int level, int glwe_dimension, uint32_t level_count) { return &ptr[get_start_ith_ggsw(i, polynomial_size, glwe_dimension, level_count) + - level * polynomial_size / 2 * (glwe_dimension + 1) * - (glwe_dimension + 1) + + (level_count - level - 1) * polynomial_size / 2 * + (glwe_dimension + 1) * (glwe_dimension + 1) + k * polynomial_size / 2 * (glwe_dimension + 1)]; } template @@ -45,8 +45,8 @@ __device__ T *get_ith_body_kth_block(T *ptr, int i, int k, int level, int glwe_dimension, uint32_t level_count) { return &ptr[get_start_ith_ggsw(i, polynomial_size, glwe_dimension, level_count) + - level * polynomial_size / 2 * (glwe_dimension + 1) * - (glwe_dimension + 1) + + (level_count - level - 1) * polynomial_size / 2 * + (glwe_dimension + 1) * (glwe_dimension + 1) + k * polynomial_size / 2 * (glwe_dimension + 1) + glwe_dimension * polynomial_size / 2]; } diff --git a/tfhe/src/core_crypto/algorithms/ggsw_encryption.rs b/tfhe/src/core_crypto/algorithms/ggsw_encryption.rs index e99dc19c17..a2d188bf3d 100644 --- a/tfhe/src/core_crypto/algorithms/ggsw_encryption.rs +++ b/tfhe/src/core_crypto/algorithms/ggsw_encryption.rs @@ -136,12 +136,13 @@ pub fn encrypt_constant_ggsw_ciphertext( ); // We loop through the levels (we reverse to match the order of the decomposition iterator.) - ggsw.into_levels().rev().for_each(|ggsw_decomp_matrix| { + ggsw.into_levels().for_each(|ggsw_decomp_matrix| { // We retrieve the decomposition of this level. let (glwe_level, glwe_decomp_term, mut substack2) = decomposition.collect_next_term(&mut substack1, align); diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext.rs b/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext.rs index f5578ac78e..3ccdefdade 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, GgswCiphertext, UnsignedInteger}; +impl Deprecable for GgswCiphertext +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "GgswCiphertext"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum GgswCiphertextVersions where C::Element: UnsignedInteger, { - V0(GgswCiphertext), + V0(Deprecated>), + V1(GgswCiphertext), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext_list.rs b/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext_list.rs index 5c40882949..f3eaed56ff 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext_list.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext_list.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, GgswCiphertextList, UnsignedInteger}; +impl Deprecable for GgswCiphertextList +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "GgswCiphertextList"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum GgswCiphertextListVersions where C::Element: UnsignedInteger, { - V0(GgswCiphertextList), + V0(Deprecated>), + V1(GgswCiphertextList), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_bootstrap_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_bootstrap_key.rs index c5d716a3e9..210536edab 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_bootstrap_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_bootstrap_key.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, LweBootstrapKey, UnsignedInteger}; +impl Deprecable for LweBootstrapKey +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "LweBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum LweBootstrapKeyVersions where C::Element: UnsignedInteger, { - V0(LweBootstrapKey), + V0(Deprecated>), + V1(LweBootstrapKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_keyswitch_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_keyswitch_key.rs index a04fbcbca9..1b9a0cbc1f 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_keyswitch_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_keyswitch_key.rs @@ -1,50 +1,14 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; -use crate::core_crypto::prelude::{ - CiphertextModulus, Container, ContainerMut, ContiguousEntityContainerMut, DecompositionBaseLog, - DecompositionLevelCount, LweKeyswitchKey, LweSize, UnsignedInteger, -}; +use crate::core_crypto::prelude::{Container, LweKeyswitchKey, UnsignedInteger}; -#[derive(Version)] -pub struct LweKeyswitchKeyV0 +impl Deprecable for LweKeyswitchKey where C::Element: UnsignedInteger, { - data: C, - decomp_base_log: DecompositionBaseLog, - decomp_level_count: DecompositionLevelCount, - output_lwe_size: LweSize, - ciphertext_modulus: CiphertextModulus, -} - -impl> Upgrade> - for LweKeyswitchKeyV0 -{ - type Error = std::convert::Infallible; - - fn upgrade(self) -> Result, Self::Error> { - let Self { - data, - decomp_base_log, - decomp_level_count, - output_lwe_size, - ciphertext_modulus, - } = self; - let mut new_ksk = LweKeyswitchKey::from_container( - data, - decomp_base_log, - decomp_level_count, - output_lwe_size, - ciphertext_modulus, - ); - - // Invert levels - for mut ksk_block in new_ksk.iter_mut() { - ksk_block.reverse(); - } - - Ok(new_ksk) - } + const TYPE_NAME: &'static str = "LweKeyswitchKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] @@ -52,6 +16,7 @@ pub enum LweKeyswitchKeyVersions where C::Element: UnsignedInteger, { - V0(LweKeyswitchKeyV0), - V1(LweKeyswitchKey), + V0(Deprecated>), + V1(Deprecated>), + V2(LweKeyswitchKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_multi_bit_bootstrap_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_multi_bit_bootstrap_key.rs index bced3f5f51..a34ee35575 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_multi_bit_bootstrap_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_multi_bit_bootstrap_key.rs @@ -1,19 +1,35 @@ use concrete_fft::c64; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{ Container, FourierLweMultiBitBootstrapKey, LweMultiBitBootstrapKey, UnsignedInteger, }; +impl Deprecable for LweMultiBitBootstrapKey +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "LweMultiBitBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum LweMultiBitBootstrapKeyVersions where C::Element: UnsignedInteger, { - V0(LweMultiBitBootstrapKey), + V0(Deprecated>), + V1(LweMultiBitBootstrapKey), +} + +impl> Deprecable for FourierLweMultiBitBootstrapKey { + const TYPE_NAME: &'static str = "FourierLweMultiBitBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum FourierLweMultiBitBootstrapKeyVersions> { - V0(FourierLweMultiBitBootstrapKey), + V0(Deprecated>), + V1(FourierLweMultiBitBootstrapKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_packing_keyswitch_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_packing_keyswitch_key.rs index 1c5ad9958a..a315ececac 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_packing_keyswitch_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_packing_keyswitch_key.rs @@ -1,53 +1,14 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; -use crate::core_crypto::prelude::{ - CiphertextModulus, Container, ContainerMut, ContiguousEntityContainerMut, DecompositionBaseLog, - DecompositionLevelCount, GlweSize, LwePackingKeyswitchKey, PolynomialSize, UnsignedInteger, -}; +use crate::core_crypto::prelude::{Container, LwePackingKeyswitchKey, UnsignedInteger}; -#[derive(Version)] -pub struct LwePackingKeyswitchKeyV0 +impl Deprecable for LwePackingKeyswitchKey where C::Element: UnsignedInteger, { - data: C, - decomp_base_log: DecompositionBaseLog, - decomp_level_count: DecompositionLevelCount, - output_glwe_size: GlweSize, - output_polynomial_size: PolynomialSize, - ciphertext_modulus: CiphertextModulus, -} - -impl> Upgrade> - for LwePackingKeyswitchKeyV0 -{ - type Error = std::convert::Infallible; - - fn upgrade(self) -> Result, Self::Error> { - let Self { - data, - decomp_base_log, - decomp_level_count, - output_glwe_size, - output_polynomial_size, - ciphertext_modulus, - } = self; - let mut new_pksk = LwePackingKeyswitchKey::from_container( - data, - decomp_base_log, - decomp_level_count, - output_glwe_size, - output_polynomial_size, - ciphertext_modulus, - ); - - // Invert levels - for mut pksk_block in new_pksk.iter_mut() { - pksk_block.reverse(); - } - - Ok(new_pksk) - } + const TYPE_NAME: &'static str = "LwePackingKeyswitchKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] @@ -55,6 +16,7 @@ pub enum LwePackingKeyswitchKeyVersions where C::Element: UnsignedInteger, { - V0(LwePackingKeyswitchKeyV0), - V1(LwePackingKeyswitchKey), + V0(Deprecated>), + V1(Deprecated>), + V2(LwePackingKeyswitchKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key.rs index 72daea0778..4be03b78d1 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key.rs @@ -1,13 +1,23 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{ Container, LwePrivateFunctionalPackingKeyswitchKey, UnsignedInteger, }; +impl Deprecable for LwePrivateFunctionalPackingKeyswitchKey +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "LwePrivateFunctionalPackingKeyswitchKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum LwePrivateFunctionalPackingKeyswitchKeyVersions where C::Element: UnsignedInteger, { - V0(LwePrivateFunctionalPackingKeyswitchKey), + V0(Deprecated>), + V1(LwePrivateFunctionalPackingKeyswitchKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key_list.rs b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key_list.rs index e2c7e7af97..0688cd471c 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key_list.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key_list.rs @@ -1,13 +1,23 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{ Container, LwePrivateFunctionalPackingKeyswitchKeyList, UnsignedInteger, }; +impl Deprecable for LwePrivateFunctionalPackingKeyswitchKeyList +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "LwePrivateFunctionalPackingKeyswitchKeyList"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum LwePrivateFunctionalPackingKeyswitchKeyListVersions where C::Element: UnsignedInteger, { - V0(LwePrivateFunctionalPackingKeyswitchKeyList), + V0(Deprecated>), + V1(LwePrivateFunctionalPackingKeyswitchKeyList), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext.rs b/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext.rs index 7f914152f3..e5a698223e 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, NttGgswCiphertext, UnsignedInteger}; +impl Deprecable for NttGgswCiphertext +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "NttGgswCiphertext"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum NttGgswCiphertextVersions where C::Element: UnsignedInteger, { - V0(NttGgswCiphertext), + V0(Deprecated>), + V1(NttGgswCiphertext), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext_list.rs b/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext_list.rs index 566fe1cb13..dd37c86b5c 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext_list.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext_list.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, NttGgswCiphertextList, UnsignedInteger}; +impl Deprecable for NttGgswCiphertextList +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "NttGgswCiphertextList"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum NttGgswCiphertextListVersions where C::Element: UnsignedInteger, { - V0(NttGgswCiphertextList), + V0(Deprecated>), + V1(NttGgswCiphertextList), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/ntt_lwe_bootstrap_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/ntt_lwe_bootstrap_key.rs index 00298afaf3..d431caa376 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/ntt_lwe_bootstrap_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/ntt_lwe_bootstrap_key.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, NttLweBootstrapKey, UnsignedInteger}; +impl Deprecable for NttLweBootstrapKey +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "NttLweBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum NttLweBootstrapKeyVersions where C::Element: UnsignedInteger, { - V0(NttLweBootstrapKey), + V0(Deprecated>), + V1(NttLweBootstrapKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext.rs b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext.rs index 2f74d911ad..dfbab7f1d4 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, SeededGgswCiphertext, UnsignedInteger}; +impl Deprecable for SeededGgswCiphertext +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "SeededGgswCiphertext"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum SeededGgswCiphertextVersions where C::Element: UnsignedInteger, { - V0(SeededGgswCiphertext), + V0(Deprecated>), + V1(SeededGgswCiphertext), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext_list.rs b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext_list.rs index ec989d2396..77f542da07 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext_list.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext_list.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, SeededGgswCiphertextList, UnsignedInteger}; +impl Deprecable for SeededGgswCiphertextList +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "SeededGgswCiphertextList"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum SeededGgswCiphertextListVersions where C::Element: UnsignedInteger, { - V0(SeededGgswCiphertextList), + V0(Deprecated>), + V1(SeededGgswCiphertextList), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_bootstrap_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_bootstrap_key.rs index 73b1565bee..35995e0b39 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_bootstrap_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_bootstrap_key.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, SeededLweBootstrapKey, UnsignedInteger}; +impl Deprecable for SeededLweBootstrapKey +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "SeededLweBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum SeededLweBootstrapKeyVersions where C::Element: UnsignedInteger, { - V0(SeededLweBootstrapKey), + V0(Deprecated>), + V1(SeededLweBootstrapKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_keyswitch_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_keyswitch_key.rs index 6bfb1b8cc7..6ae40ef116 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_keyswitch_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_keyswitch_key.rs @@ -8,7 +8,7 @@ where C::Element: UnsignedInteger, { const TYPE_NAME: &'static str = "SeededLweKeyswitchKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] @@ -17,5 +17,6 @@ where C::Element: UnsignedInteger, { V0(Deprecated>), - V1(SeededLweKeyswitchKey), + V1(Deprecated>), + V2(SeededLweKeyswitchKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_multi_bit_bootstrap_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_multi_bit_bootstrap_key.rs index df68227d70..bcccc1443e 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_multi_bit_bootstrap_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_multi_bit_bootstrap_key.rs @@ -1,11 +1,21 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, SeededLweMultiBitBootstrapKey, UnsignedInteger}; +impl Deprecable for SeededLweMultiBitBootstrapKey +where + C::Element: UnsignedInteger, +{ + const TYPE_NAME: &'static str = "SeededLweMultiBitBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum SeededLweMultiBitBootstrapKeyVersions where C::Element: UnsignedInteger, { - V0(SeededLweMultiBitBootstrapKey), + V0(Deprecated>), + V1(SeededLweMultiBitBootstrapKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_packing_keyswitch_key.rs b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_packing_keyswitch_key.rs index c7a9235dc8..15ff5c925a 100644 --- a/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_packing_keyswitch_key.rs +++ b/tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_packing_keyswitch_key.rs @@ -8,7 +8,7 @@ where C::Element: UnsignedInteger, { const TYPE_NAME: &'static str = "SeededLwePackingKeyswitchKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] @@ -17,5 +17,6 @@ where C::Element: UnsignedInteger, { V0(Deprecated>), - V1(SeededLwePackingKeyswitchKey), + V1(Deprecated>), + V2(SeededLwePackingKeyswitchKey), } diff --git a/tfhe/src/core_crypto/backward_compatibility/fft_impl/mod.rs b/tfhe/src/core_crypto/backward_compatibility/fft_impl/mod.rs index 368b0e1866..2de6f97382 100644 --- a/tfhe/src/core_crypto/backward_compatibility/fft_impl/mod.rs +++ b/tfhe/src/core_crypto/backward_compatibility/fft_impl/mod.rs @@ -1,3 +1,4 @@ +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::VersionsDispatch; use aligned_vec::ABox; @@ -60,22 +61,46 @@ impl> From> Deprecable for FourierLweBootstrapKey { + const TYPE_NAME: &'static str = "FourierLweBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum FourierLweBootstrapKeyVersions> { - V0(FourierLweBootstrapKey), + V0(Deprecated>), + V1(FourierLweBootstrapKey), +} + +impl> Deprecable for FourierGgswCiphertext { + const TYPE_NAME: &'static str = "FourierGgswCiphertext"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum FourierGgswCiphertextVersions> { - V0(FourierGgswCiphertext), + V0(Deprecated>), + V1(FourierGgswCiphertext), +} + +impl> Deprecable for Fourier128LweBootstrapKey { + const TYPE_NAME: &'static str = "Fourier128LweBootstrapKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum Fourier128LweBootstrapKeyVersions> { - V0(Fourier128LweBootstrapKey), + V0(Deprecated>), + V1(Fourier128LweBootstrapKey), +} + +impl> Deprecable for Fourier128GgswCiphertext { + const TYPE_NAME: &'static str = "Fourier128GgswCiphertext"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum Fourier128GgswCiphertextVersions> { - V0(Fourier128GgswCiphertext), + V0(Deprecated>), + V1(Fourier128GgswCiphertext), } diff --git a/tfhe/src/core_crypto/commons/traits/contiguous_entity_container.rs b/tfhe/src/core_crypto/commons/traits/contiguous_entity_container.rs index 7f34cfe47e..7e27a694d9 100644 --- a/tfhe/src/core_crypto/commons/traits/contiguous_entity_container.rs +++ b/tfhe/src/core_crypto/commons/traits/contiguous_entity_container.rs @@ -187,6 +187,16 @@ pub trait ContiguousEntityContainer: AsRef<[Self::Element]> { Self::SelfView::<'_>::create_from(sub_container, self_meta) } + fn first(&self) -> Option> { + let entity_count = self.entity_count(); + + if entity_count == 0 { + None + } else { + Some(self.get(0)) + } + } + fn last(&self) -> Option> { let entity_count = self.entity_count(); diff --git a/tfhe/src/core_crypto/entities/ntt_ggsw_ciphertext.rs b/tfhe/src/core_crypto/entities/ntt_ggsw_ciphertext.rs index f7edf035f5..32910421d5 100644 --- a/tfhe/src/core_crypto/entities/ntt_ggsw_ciphertext.rs +++ b/tfhe/src/core_crypto/entities/ntt_ggsw_ciphertext.rs @@ -176,16 +176,17 @@ impl> NttGgswCiphertext< pub fn into_levels( &self, ) -> impl DoubleEndedIterator> { + let decomposition_level_count = self.decomposition_level_count.0; self.data .as_ref() - .split_into(self.decomposition_level_count.0) + .split_into(decomposition_level_count) .enumerate() .map(move |(i, slice)| { NttGgswLevelMatrixView::from_container( slice, self.glwe_size, self.polynomial_size, - DecompositionLevel(i + 1), + DecompositionLevel(decomposition_level_count - i), ) }) } diff --git a/tfhe/src/core_crypto/experimental/algorithms/glwe_fast_keyswitch.rs b/tfhe/src/core_crypto/experimental/algorithms/glwe_fast_keyswitch.rs index 05229ae7a1..2258b5da32 100644 --- a/tfhe/src/core_crypto/experimental/algorithms/glwe_fast_keyswitch.rs +++ b/tfhe/src/core_crypto/experimental/algorithms/glwe_fast_keyswitch.rs @@ -215,7 +215,7 @@ pub fn glwe_fast_keyswitch( // We loop through the levels (we reverse to match the order of the decomposition // iterator.) - ggsw.into_levels().rev().for_each(|ggsw_decomp_matrix| { + ggsw.into_levels().for_each(|ggsw_decomp_matrix| { // We retrieve the decomposition of this level. let (glwe_level, glwe_decomp_term, mut substack2) = collect_next_term(&mut decomposition, &mut substack1, align); diff --git a/tfhe/src/core_crypto/experimental/algorithms/lwe_shrinking_keyswitch.rs b/tfhe/src/core_crypto/experimental/algorithms/lwe_shrinking_keyswitch.rs index 04cc741054..a91657f3de 100644 --- a/tfhe/src/core_crypto/experimental/algorithms/lwe_shrinking_keyswitch.rs +++ b/tfhe/src/core_crypto/experimental/algorithms/lwe_shrinking_keyswitch.rs @@ -174,8 +174,7 @@ pub fn shrinking_keyswitch_lwe_ciphertext PseudoFourierGgswCiphertextView<'a> { pub fn into_levels( self, ) -> impl DoubleEndedIterator> { + let decomposition_level_count = self.decomposition_level_count.0; self.fourier .data - .split_into(self.decomposition_level_count.0) + .split_into(decomposition_level_count) .enumerate() .map(move |(i, slice)| { PseudoFourierGgswLevelMatrixView::new( @@ -250,7 +251,7 @@ impl<'a> PseudoFourierGgswCiphertextView<'a> { self.glwe_size_in, self.glwe_size_out, self.fourier.polynomial_size, - DecompositionLevel(i + 1), + DecompositionLevel(decomposition_level_count - i), ) }) } diff --git a/tfhe/src/core_crypto/fft_impl/fft128/crypto/ggsw.rs b/tfhe/src/core_crypto/fft_impl/fft128/crypto/ggsw.rs index c221bdedee..e708b18dd4 100644 --- a/tfhe/src/core_crypto/fft_impl/fft128/crypto/ggsw.rs +++ b/tfhe/src/core_crypto/fft_impl/fft128/crypto/ggsw.rs @@ -148,11 +148,12 @@ impl> Fourier128GgswCiphertext { where C: Split, { + let decomposition_level_count = self.decomposition_level_count.0; izip!( - self.data_re0.split_into(self.decomposition_level_count.0), - self.data_re1.split_into(self.decomposition_level_count.0), - self.data_im0.split_into(self.decomposition_level_count.0), - self.data_im1.split_into(self.decomposition_level_count.0) + self.data_re0.split_into(decomposition_level_count), + self.data_re1.split_into(decomposition_level_count), + self.data_im0.split_into(decomposition_level_count), + self.data_im1.split_into(decomposition_level_count) ) .enumerate() .map(move |(i, (data_re0, data_re1, data_im0, data_im1))| { @@ -163,7 +164,7 @@ impl> Fourier128GgswCiphertext { data_im1, self.polynomial_size, self.glwe_size, - DecompositionLevel(i + 1), + DecompositionLevel(decomposition_level_count - i), ) }) } @@ -426,7 +427,7 @@ pub fn add_external_product_assign( // We loop through the levels (we reverse to match the order of the decomposition // iterator.) - for ggsw_decomp_matrix in ggsw.into_levels().rev() { + for ggsw_decomp_matrix in ggsw.into_levels() { // We retrieve the decomposition of this level. let (glwe_level, glwe_decomp_term, mut substack2) = collect_next_term(&mut decomposition, &mut substack1, align); diff --git a/tfhe/src/core_crypto/fft_impl/fft128_u128/crypto/ggsw.rs b/tfhe/src/core_crypto/fft_impl/fft128_u128/crypto/ggsw.rs index 789b4bda64..d28b05b927 100644 --- a/tfhe/src/core_crypto/fft_impl/fft128_u128/crypto/ggsw.rs +++ b/tfhe/src/core_crypto/fft_impl/fft128_u128/crypto/ggsw.rs @@ -108,7 +108,7 @@ pub fn add_external_product_assign_split> FourierGgswLevelRow { impl<'a> FourierGgswCiphertextView<'a> { /// Return an iterator over the level matrices. pub fn into_levels(self) -> impl DoubleEndedIterator> { + let decomposition_level_count = self.decomposition_level_count.0; self.fourier .data - .split_into(self.decomposition_level_count.0) + .split_into(decomposition_level_count) .enumerate() .map(move |(i, slice)| { FourierGgswLevelMatrixView::new( slice, self.glwe_size, self.fourier.polynomial_size, - DecompositionLevel(i + 1), + DecompositionLevel(decomposition_level_count - i), ) }) } @@ -524,7 +525,7 @@ pub fn add_external_product_assign( ); // We loop through the levels (we reverse to match the order of the decomposition iterator.) - ggsw.into_levels().rev().for_each(|ggsw_decomp_matrix| { + ggsw.into_levels().for_each(|ggsw_decomp_matrix| { // We retrieve the decomposition of this level. let (glwe_level, glwe_decomp_term, mut substack2) = collect_next_term(&mut decomposition, &mut substack1, align); diff --git a/tfhe/src/core_crypto/fft_impl/fft64/crypto/wop_pbs/mod.rs b/tfhe/src/core_crypto/fft_impl/fft64/crypto/wop_pbs/mod.rs index ba723458b4..c1db561878 100644 --- a/tfhe/src/core_crypto/fft_impl/fft64/crypto/wop_pbs/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/fft64/crypto/wop_pbs/mod.rs @@ -314,8 +314,8 @@ pub fn circuit_bootstrap_boolean>( let mut lwe_out_bs_buffer = LweCiphertext::from_container(&mut *lwe_out_bs_buffer_data, lwe_in.ciphertext_modulus()); - for (decomposition_level_minus_one, mut ggsw_level_matrix) in ggsw_out.iter_mut().enumerate() { - let decomposition_level = DecompositionLevel(decomposition_level_minus_one + 1); + for (output_index, mut ggsw_level_matrix) in ggsw_out.iter_mut().enumerate() { + let decomposition_level = DecompositionLevel(level_cbs.0 - output_index); homomorphic_shift_boolean( fourier_bsk, lwe_out_bs_buffer.as_mut_view(), diff --git a/tfhe/src/high_level_api/backward_compatibility/keys.rs b/tfhe/src/high_level_api/backward_compatibility/keys.rs index 1e2b3af345..52a2ce7db0 100644 --- a/tfhe/src/high_level_api/backward_compatibility/keys.rs +++ b/tfhe/src/high_level_api/backward_compatibility/keys.rs @@ -1,7 +1,6 @@ use crate::high_level_api::keys::*; use crate::Tag; use std::convert::Infallible; -use std::sync::Arc; use tfhe_versionable::deprecation::{Deprecable, Deprecated}; use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; @@ -28,66 +27,29 @@ impl Upgrade for ClientKeyV0 { } } -// This type was previously versioned using a manual implementation with a conversion -// to a type where the inner key was name `integer_key` -#[derive(Version)] -pub struct ServerKeyV0 { - pub(crate) integer_key: Arc, -} - -impl Upgrade for ServerKeyV0 { - type Error = Infallible; - - fn upgrade(self) -> Result { - Ok(ServerKeyV1 { - key: self.integer_key, - }) - } -} - -#[derive(Version)] -pub struct ServerKeyV1 { - pub(crate) key: Arc, -} - -impl Upgrade for ServerKeyV1 { - type Error = Infallible; - - fn upgrade(self) -> Result { - Ok(ServerKey { - key: self.key, - tag: Tag::default(), - }) - } +impl Deprecable for ServerKey { + const TYPE_NAME: &'static str = "ServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum ServerKeyVersions { - V0(ServerKeyV0), - V1(ServerKeyV1), - V2(ServerKey), + V0(Deprecated), + V1(Deprecated), + V2(Deprecated), + V3(ServerKey), } -#[derive(Version)] -pub struct CompressedServerKeyV0 { - pub(crate) integer_key: IntegerCompressedServerKey, -} - -impl Upgrade for CompressedServerKeyV0 { - type Error = Infallible; - - fn upgrade(self) -> Result { - Ok(CompressedServerKey { - integer_key: self.integer_key, - tag: Tag::default(), - }) - } +impl Deprecable for CompressedServerKey { + const TYPE_NAME: &'static str = "CompressedServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedServerKeyVersions { - V0(CompressedServerKeyV0), - V1(CompressedServerKey), + V0(Deprecated), + V1(Deprecated), + V2(CompressedServerKey), } #[derive(Version)] @@ -221,52 +183,28 @@ pub(crate) enum IntegerClientKeyVersions { impl Deprecable for IntegerServerKey { const TYPE_NAME: &'static str = "IntegerServerKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.8"; -} - -#[derive(Version)] -pub struct IntegerServerKeyV2 { - pub(crate) key: crate::integer::ServerKey, - pub(crate) cpk_key_switching_key_material: - Option, - pub(crate) compression_key: Option, - pub(crate) decompression_key: Option, -} - -impl Upgrade for IntegerServerKeyV2 { - type Error = Infallible; - - fn upgrade(self) -> Result { - Ok(IntegerServerKey { - key: self.key, - cpk_key_switching_key_material: self.cpk_key_switching_key_material, - compression_key: self - .compression_key - .map(|key| crate::integer::compression_keys::CompressionKey { key }), - decompression_key: self - .decompression_key - .map(|key| crate::integer::compression_keys::DecompressionKey { key }), - }) - } + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum IntegerServerKeyVersions { V0(Deprecated), V1(Deprecated), - V2(IntegerServerKeyV2), - V3(IntegerServerKey), + V2(Deprecated), + V3(Deprecated), + V4(IntegerServerKey), } impl Deprecable for IntegerCompressedServerKey { const TYPE_NAME: &'static str = "IntegerCompressedServerKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum IntegerCompressedServerKeyVersions { V0(Deprecated), - V1(IntegerCompressedServerKey), + V1(Deprecated), + V2(IntegerCompressedServerKey), } #[derive(VersionsDispatch)] @@ -281,7 +219,13 @@ pub(in crate::high_level_api) enum IntegerCompressedCompactPublicKeyVersions { V0(IntegerCompressedCompactPublicKey), } +impl Deprecable for KeySwitchingKey { + const TYPE_NAME: &'static str = "KeySwitchingKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum KeySwitchingKeyVersions { - V0(KeySwitchingKey), + V0(Deprecated), + V1(KeySwitchingKey), } diff --git a/tfhe/src/integer/backward_compatibility/key_switching_key.rs b/tfhe/src/integer/backward_compatibility/key_switching_key.rs index 19bc4a106b..41fc8ded7b 100644 --- a/tfhe/src/integer/backward_compatibility/key_switching_key.rs +++ b/tfhe/src/integer/backward_compatibility/key_switching_key.rs @@ -18,22 +18,24 @@ pub enum KeySwitchingKeyVersions { impl Deprecable for CompressedKeySwitchingKeyMaterial { const TYPE_NAME: &'static str = "CompressedKeySwitchingKeyMaterial"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyMaterialVersions { V0(Deprecated), - V1(CompressedKeySwitchingKeyMaterial), + V1(Deprecated), + V2(CompressedKeySwitchingKeyMaterial), } impl Deprecable for CompressedKeySwitchingKey { const TYPE_NAME: &'static str = "CompressedKeySwitchingKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyVersions { V0(Deprecated), - V1(CompressedKeySwitchingKey), + V1(Deprecated), + V2(CompressedKeySwitchingKey), } diff --git a/tfhe/src/integer/backward_compatibility/list_compression.rs b/tfhe/src/integer/backward_compatibility/list_compression.rs index aecd650fc2..2a76de9f78 100644 --- a/tfhe/src/integer/backward_compatibility/list_compression.rs +++ b/tfhe/src/integer/backward_compatibility/list_compression.rs @@ -17,18 +17,25 @@ pub enum DecompressionKeyVersions { impl Deprecable for CompressedCompressionKey { const TYPE_NAME: &'static str = "CompressedCompressionKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedCompressionKeyVersions { V0(Deprecated), - V1(CompressedCompressionKey), + V1(Deprecated), + V2(CompressedCompressionKey), +} + +impl Deprecable for CompressedDecompressionKey { + const TYPE_NAME: &'static str = "CompressedDecompressionKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedDecompressionKeyVersions { - V0(CompressedDecompressionKey), + V0(Deprecated), + V1(CompressedDecompressionKey), } #[derive(VersionsDispatch)] diff --git a/tfhe/src/integer/backward_compatibility/server_key/mod.rs b/tfhe/src/integer/backward_compatibility/server_key/mod.rs index b7e5c4cf56..db80188135 100644 --- a/tfhe/src/integer/backward_compatibility/server_key/mod.rs +++ b/tfhe/src/integer/backward_compatibility/server_key/mod.rs @@ -3,18 +3,25 @@ use tfhe_versionable::VersionsDispatch; use crate::integer::{CompressedServerKey, ServerKey}; +impl Deprecable for ServerKey { + const TYPE_NAME: &'static str = "ServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum ServerKeyVersions { - V0(ServerKey), + V0(Deprecated), + V1(ServerKey), } impl Deprecable for CompressedServerKey { const TYPE_NAME: &'static str = "CompressedServerKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedServerKeyVersions { V0(Deprecated), - V1(CompressedServerKey), + V1(Deprecated), + V2(CompressedServerKey), } diff --git a/tfhe/src/shortint/backward_compatibility/key_switching_key.rs b/tfhe/src/shortint/backward_compatibility/key_switching_key.rs index 602098306c..26cb3838ac 100644 --- a/tfhe/src/shortint/backward_compatibility/key_switching_key.rs +++ b/tfhe/src/shortint/backward_compatibility/key_switching_key.rs @@ -18,22 +18,24 @@ pub enum KeySwitchingKeyVersions { impl Deprecable for CompressedKeySwitchingKeyMaterial { const TYPE_NAME: &'static str = "CompressedKeySwitchingKeyMaterial"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyMaterialVersions { V0(Deprecated), - V1(CompressedKeySwitchingKeyMaterial), + V1(Deprecated), + V2(CompressedKeySwitchingKeyMaterial), } impl Deprecable for CompressedKeySwitchingKey { const TYPE_NAME: &'static str = "CompressedKeySwitchingKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyVersions { V0(Deprecated), - V1(CompressedKeySwitchingKey), + V1(Deprecated), + V2(CompressedKeySwitchingKey), } diff --git a/tfhe/src/shortint/backward_compatibility/list_compression.rs b/tfhe/src/shortint/backward_compatibility/list_compression.rs index 0931d09b5d..d66c636e1e 100644 --- a/tfhe/src/shortint/backward_compatibility/list_compression.rs +++ b/tfhe/src/shortint/backward_compatibility/list_compression.rs @@ -18,18 +18,25 @@ pub enum DecompressionKeyVersions { impl Deprecable for CompressedCompressionKey { const TYPE_NAME: &'static str = "CompressedCompressionKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedCompressionKeyVersions { V0(Deprecated), - V1(CompressedCompressionKey), + V1(Deprecated), + V2(CompressedCompressionKey), +} + +impl Deprecable for CompressedDecompressionKey { + const TYPE_NAME: &'static str = "CompressedDecompressionKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedDecompressionKeyVersions { - V0(CompressedDecompressionKey), + V0(Deprecated), + V1(CompressedDecompressionKey), } #[derive(VersionsDispatch)] diff --git a/tfhe/src/shortint/backward_compatibility/server_key/mod.rs b/tfhe/src/shortint/backward_compatibility/server_key/mod.rs index cab0a65001..002111fa42 100644 --- a/tfhe/src/shortint/backward_compatibility/server_key/mod.rs +++ b/tfhe/src/shortint/backward_compatibility/server_key/mod.rs @@ -9,23 +9,36 @@ pub enum SerializableShortintBootstrappingKeyVersions), } +impl Deprecable for ServerKey { + const TYPE_NAME: &'static str = "ServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; +} + #[derive(VersionsDispatch)] pub enum ServerKeyVersions { - V0(ServerKey), + V0(Deprecated), + V1(ServerKey), +} + +impl Deprecable for ShortintCompressedBootstrappingKey { + const TYPE_NAME: &'static str = "ShortintCompressedBootstrappingKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum ShortintCompressedBootstrappingKeyVersions { - V0(ShortintCompressedBootstrappingKey), + V0(Deprecated), + V1(ShortintCompressedBootstrappingKey), } impl Deprecable for CompressedServerKey { const TYPE_NAME: &'static str = "CompressedServerKey"; - const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; } #[derive(VersionsDispatch)] pub enum CompressedServerKeyVersions { V0(Deprecated), - V1(CompressedServerKey), + V1(Deprecated), + V2(CompressedServerKey), }