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 bb9651d180..6bfb1b8cc7 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 @@ -1,22 +1,14 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, SeededLweKeyswitchKey, UnsignedInteger}; -#[derive(Version)] -pub struct UnsupportedSeededLweKeyswitchKeyV0; - -impl> Upgrade> - for UnsupportedSeededLweKeyswitchKeyV0 +impl Deprecable for SeededLweKeyswitchKey +where + C::Element: UnsignedInteger, { - type Error = crate::Error; - - fn upgrade(self) -> Result, Self::Error> { - Err(crate::Error::new( - "Unable to load SeededLweKeyswitchKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } + const TYPE_NAME: &'static str = "SeededLweKeyswitchKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] @@ -24,6 +16,6 @@ pub enum SeededLweKeyswitchKeyVersions where C::Element: UnsignedInteger, { - V0(UnsupportedSeededLweKeyswitchKeyV0), + V0(Deprecated>), V1(SeededLweKeyswitchKey), } 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 c74c492a9c..c7a9235dc8 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 @@ -1,22 +1,14 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::{Container, SeededLwePackingKeyswitchKey, UnsignedInteger}; -#[derive(Version)] -pub struct UnsupportedSeededLwePackingKeyswitchKeyV0; - -impl> - Upgrade> for UnsupportedSeededLwePackingKeyswitchKeyV0 +impl Deprecable for SeededLwePackingKeyswitchKey +where + C::Element: UnsignedInteger, { - type Error = crate::Error; - - fn upgrade(self) -> Result, Self::Error> { - Err(crate::Error::new( - "Unable to load SeededLwePackingKeyswitchKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } + const TYPE_NAME: &'static str = "SeededLwePackingKeyswitchKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] @@ -24,6 +16,6 @@ pub enum SeededLwePackingKeyswitchKeyVersions where C::Element: UnsignedInteger, { - V0(UnsupportedSeededLwePackingKeyswitchKeyV0), + V0(Deprecated>), V1(SeededLwePackingKeyswitchKey), } diff --git a/tfhe/src/high_level_api/backward_compatibility/keys.rs b/tfhe/src/high_level_api/backward_compatibility/keys.rs index 0f7d3fa50c..1e2b3af345 100644 --- a/tfhe/src/high_level_api/backward_compatibility/keys.rs +++ b/tfhe/src/high_level_api/backward_compatibility/keys.rs @@ -2,6 +2,7 @@ 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}; #[derive(VersionsDispatch)] @@ -183,34 +184,9 @@ pub(crate) enum IntegerConfigVersions { V0(IntegerConfig), } -#[derive(Version)] -pub struct UnsupportedIntegerClientKeyV0; - -#[derive(Version)] -pub struct UnsupportedIntegerClientKeyV1; - -impl Upgrade for UnsupportedIntegerClientKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load IntegerClientKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } -} - -impl Upgrade for UnsupportedIntegerClientKeyV1 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load IntegerClientKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for IntegerClientKey { + const TYPE_NAME: &'static str = "IntegerClientKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.8"; } #[derive(Version)] @@ -237,40 +213,15 @@ impl Upgrade for IntegerClientKeyV2 { #[derive(VersionsDispatch)] #[allow(unused)] pub(crate) enum IntegerClientKeyVersions { - V0(UnsupportedIntegerClientKeyV0), - V1(UnsupportedIntegerClientKeyV1), + V0(Deprecated), + V1(Deprecated), V2(IntegerClientKeyV2), V3(IntegerClientKey), } -#[derive(Version)] -pub struct UnsupportedIntegerServerKeyV0; - -#[derive(Version)] -pub struct UnsupportedIntegerServerKeyV1; - -impl Upgrade for UnsupportedIntegerServerKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load IntegerServerKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } -} - -impl Upgrade for UnsupportedIntegerServerKeyV1 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load IntegerServerKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for IntegerServerKey { + const TYPE_NAME: &'static str = "IntegerServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.8"; } #[derive(Version)] @@ -301,30 +252,20 @@ impl Upgrade for IntegerServerKeyV2 { #[derive(VersionsDispatch)] pub enum IntegerServerKeyVersions { - V0(UnsupportedIntegerServerKeyV0), - V1(UnsupportedIntegerServerKeyV1), + V0(Deprecated), + V1(Deprecated), V2(IntegerServerKeyV2), V3(IntegerServerKey), } -#[derive(Version)] -pub struct UnsupportedIntegerCompressedServerKeyV0; - -impl Upgrade for UnsupportedIntegerCompressedServerKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load IntegerCompressedServerKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for IntegerCompressedServerKey { + const TYPE_NAME: &'static str = "IntegerCompressedServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum IntegerCompressedServerKeyVersions { - V0(UnsupportedIntegerCompressedServerKeyV0), + V0(Deprecated), V1(IntegerCompressedServerKey), } diff --git a/tfhe/src/integer/backward_compatibility/key_switching_key.rs b/tfhe/src/integer/backward_compatibility/key_switching_key.rs index dfed143fe9..19bc4a106b 100644 --- a/tfhe/src/integer/backward_compatibility/key_switching_key.rs +++ b/tfhe/src/integer/backward_compatibility/key_switching_key.rs @@ -1,4 +1,5 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::integer::key_switching_key::{ CompressedKeySwitchingKey, CompressedKeySwitchingKeyMaterial, KeySwitchingKey, @@ -15,44 +16,24 @@ pub enum KeySwitchingKeyVersions { V0(KeySwitchingKey), } -#[derive(Version)] -pub struct UnsupportedCompressedKeySwitchingKeyMaterialV0; - -impl Upgrade for UnsupportedCompressedKeySwitchingKeyMaterialV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedKeySwitchingKeyMaterial, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedKeySwitchingKeyMaterial { + const TYPE_NAME: &'static str = "CompressedKeySwitchingKeyMaterial"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyMaterialVersions { - V0(UnsupportedCompressedKeySwitchingKeyMaterialV0), + V0(Deprecated), V1(CompressedKeySwitchingKeyMaterial), } -#[derive(Version)] -pub struct UnsupportedCompressedKeySwitchingKeyV0; - -impl Upgrade for UnsupportedCompressedKeySwitchingKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedKeySwitchingKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedKeySwitchingKey { + const TYPE_NAME: &'static str = "CompressedKeySwitchingKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyVersions { - V0(UnsupportedCompressedKeySwitchingKeyV0), + V0(Deprecated), V1(CompressedKeySwitchingKey), } diff --git a/tfhe/src/integer/backward_compatibility/list_compression.rs b/tfhe/src/integer/backward_compatibility/list_compression.rs index b73e8bcfa4..aecd650fc2 100644 --- a/tfhe/src/integer/backward_compatibility/list_compression.rs +++ b/tfhe/src/integer/backward_compatibility/list_compression.rs @@ -2,7 +2,8 @@ use crate::integer::compression_keys::{ CompressedCompressionKey, CompressedDecompressionKey, CompressionKey, CompressionPrivateKeys, DecompressionKey, }; -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; #[derive(VersionsDispatch)] pub enum CompressionKeyVersions { @@ -14,24 +15,14 @@ pub enum DecompressionKeyVersions { V0(DecompressionKey), } -#[derive(Version)] -pub struct UnsupportedCompressedCompressionKeyV0; - -impl Upgrade for UnsupportedCompressedCompressionKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedCompressionKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedCompressionKey { + const TYPE_NAME: &'static str = "CompressedCompressionKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedCompressionKeyVersions { - V0(UnsupportedCompressedCompressionKeyV0), + V0(Deprecated), V1(CompressedCompressionKey), } diff --git a/tfhe/src/integer/backward_compatibility/server_key/mod.rs b/tfhe/src/integer/backward_compatibility/server_key/mod.rs index 219d5ad253..b7e5c4cf56 100644 --- a/tfhe/src/integer/backward_compatibility/server_key/mod.rs +++ b/tfhe/src/integer/backward_compatibility/server_key/mod.rs @@ -1,4 +1,5 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::integer::{CompressedServerKey, ServerKey}; @@ -7,23 +8,13 @@ pub enum ServerKeyVersions { V0(ServerKey), } -#[derive(Version)] -pub struct UnsupportedCompressedServerKeyV0; - -impl Upgrade for UnsupportedCompressedServerKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedServerKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedServerKey { + const TYPE_NAME: &'static str = "CompressedServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedServerKeyVersions { - V0(UnsupportedCompressedServerKeyV0), + V0(Deprecated), V1(CompressedServerKey), } diff --git a/tfhe/src/shortint/backward_compatibility/key_switching_key.rs b/tfhe/src/shortint/backward_compatibility/key_switching_key.rs index 9a8d933fab..602098306c 100644 --- a/tfhe/src/shortint/backward_compatibility/key_switching_key.rs +++ b/tfhe/src/shortint/backward_compatibility/key_switching_key.rs @@ -1,4 +1,5 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::shortint::key_switching_key::{ CompressedKeySwitchingKeyMaterial, KeySwitchingKeyMaterial, @@ -15,44 +16,24 @@ pub enum KeySwitchingKeyVersions { V0(KeySwitchingKey), } -#[derive(Version)] -pub struct UnsupportedCompressedKeySwitchingKeyMaterialV0; - -impl Upgrade for UnsupportedCompressedKeySwitchingKeyMaterialV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedKeySwitchingKeyMaterial, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedKeySwitchingKeyMaterial { + const TYPE_NAME: &'static str = "CompressedKeySwitchingKeyMaterial"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyMaterialVersions { - V0(UnsupportedCompressedKeySwitchingKeyMaterialV0), + V0(Deprecated), V1(CompressedKeySwitchingKeyMaterial), } -#[derive(Version)] -pub struct UnsupportedCompressedKeySwitchingKeyV0; - -impl Upgrade for UnsupportedCompressedKeySwitchingKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedKeySwitchingKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedKeySwitchingKey { + const TYPE_NAME: &'static str = "CompressedKeySwitchingKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedKeySwitchingKeyVersions { - V0(UnsupportedCompressedKeySwitchingKeyV0), + V0(Deprecated), V1(CompressedKeySwitchingKey), } diff --git a/tfhe/src/shortint/backward_compatibility/list_compression.rs b/tfhe/src/shortint/backward_compatibility/list_compression.rs index a5959a16c3..0931d09b5d 100644 --- a/tfhe/src/shortint/backward_compatibility/list_compression.rs +++ b/tfhe/src/shortint/backward_compatibility/list_compression.rs @@ -1,4 +1,5 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::shortint::list_compression::{ CompressedCompressionKey, CompressedDecompressionKey, CompressionKey, CompressionPrivateKeys, @@ -15,24 +16,14 @@ pub enum DecompressionKeyVersions { V0(DecompressionKey), } -#[derive(Version)] -pub struct UnsupportedCompressedCompressionKeyV0; - -impl Upgrade for UnsupportedCompressedCompressionKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedCompressionKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedCompressionKey { + const TYPE_NAME: &'static str = "CompressedCompressionKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedCompressionKeyVersions { - V0(UnsupportedCompressedCompressionKeyV0), + V0(Deprecated), V1(CompressedCompressionKey), } diff --git a/tfhe/src/shortint/backward_compatibility/server_key/mod.rs b/tfhe/src/shortint/backward_compatibility/server_key/mod.rs index 6d1d295ade..cab0a65001 100644 --- a/tfhe/src/shortint/backward_compatibility/server_key/mod.rs +++ b/tfhe/src/shortint/backward_compatibility/server_key/mod.rs @@ -1,4 +1,5 @@ -use tfhe_versionable::{Upgrade, Version, VersionsDispatch}; +use tfhe_versionable::deprecation::{Deprecable, Deprecated}; +use tfhe_versionable::VersionsDispatch; use crate::core_crypto::prelude::Container; use crate::shortint::server_key::*; @@ -18,23 +19,13 @@ pub enum ShortintCompressedBootstrappingKeyVersions { V0(ShortintCompressedBootstrappingKey), } -#[derive(Version)] -pub struct UnsupportedCompressedServerKeyV0; - -impl Upgrade for UnsupportedCompressedServerKeyV0 { - type Error = crate::Error; - - fn upgrade(self) -> Result { - Err(crate::Error::new( - "Unable to load CompressedServerKey, \ - this format is unsupported by this TFHE-rs version." - .to_string(), - )) - } +impl Deprecable for CompressedServerKey { + const TYPE_NAME: &'static str = "CompressedServerKey"; + const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.9"; } #[derive(VersionsDispatch)] pub enum CompressedServerKeyVersions { - V0(UnsupportedCompressedServerKeyV0), + V0(Deprecated), V1(CompressedServerKey), }