From 1213526e24e9a642bc2ceee432a8a188d14f2d2c Mon Sep 17 00:00:00 2001 From: Nicolas Sarlin Date: Fri, 20 Sep 2024 11:36:07 +0200 Subject: [PATCH] feat(hl): impl Named for key types --- tfhe/src/high_level_api/keys/client.rs | 5 +++++ .../high_level_api/keys/key_switching_key.rs | 5 +++++ tfhe/src/high_level_api/keys/public.rs | 17 +++++++++++++++++ tfhe/src/high_level_api/keys/server.rs | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/tfhe/src/high_level_api/keys/client.rs b/tfhe/src/high_level_api/keys/client.rs index 60c97cc50a..d23486a8d5 100644 --- a/tfhe/src/high_level_api/keys/client.rs +++ b/tfhe/src/high_level_api/keys/client.rs @@ -7,6 +7,7 @@ use crate::high_level_api::backward_compatibility::keys::ClientKeyVersions; use crate::high_level_api::config::Config; use crate::high_level_api::keys::{CompactPrivateKey, IntegerClientKey}; use crate::integer::compression_keys::CompressionPrivateKeys; +use crate::named::Named; use crate::prelude::Tagged; use crate::shortint::MessageModulus; use crate::Tag; @@ -133,3 +134,7 @@ impl AsRef for ClientKey { &self.key.key } } + +impl Named for ClientKey { + const NAME: &'static str = "high_level_api::ClientKey"; +} diff --git a/tfhe/src/high_level_api/keys/key_switching_key.rs b/tfhe/src/high_level_api/keys/key_switching_key.rs index c8f927a640..2df59d683b 100644 --- a/tfhe/src/high_level_api/keys/key_switching_key.rs +++ b/tfhe/src/high_level_api/keys/key_switching_key.rs @@ -3,6 +3,7 @@ use tfhe_versionable::Versionize; use crate::backward_compatibility::keys::KeySwitchingKeyVersions; use crate::high_level_api::integers::{FheIntId, FheUintId}; use crate::integer::BooleanBlock; +use crate::named::Named; use crate::prelude::FheKeyswitch; pub use crate::shortint::parameters::key_switching::ShortintKeySwitchingParameters; use crate::{ClientKey, FheBool, FheInt, FheUint, ServerKey, Tag}; @@ -95,3 +96,7 @@ impl FheKeyswitch for KeySwitchingKey { FheBool::new(BooleanBlock::new_unchecked(casted), self.tag_out.clone()) } } + +impl Named for KeySwitchingKey { + const NAME: &'static str = "high_level_api::KeySwitchingKey"; +} diff --git a/tfhe/src/high_level_api/keys/public.rs b/tfhe/src/high_level_api/keys/public.rs index 722e7a4357..e7983818d8 100644 --- a/tfhe/src/high_level_api/keys/public.rs +++ b/tfhe/src/high_level_api/keys/public.rs @@ -21,6 +21,7 @@ use crate::backward_compatibility::keys::{ PublicKeyVersions, }; use crate::high_level_api::keys::{IntegerCompactPublicKey, IntegerCompressedCompactPublicKey}; +use crate::named::Named; use crate::prelude::Tagged; use crate::shortint::MessageModulus; use crate::{Error, Tag}; @@ -68,6 +69,10 @@ impl Tagged for PublicKey { } } +impl Named for PublicKey { + const NAME: &'static str = "high_level_api::PublicKey"; +} + /// Compressed classical public key. #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Versionize)] #[versionize(CompressedPublicKeyVersions)] @@ -115,6 +120,10 @@ impl Tagged for CompressedPublicKey { } } +impl Named for CompressedPublicKey { + const NAME: &'static str = "high_level_api::CompressedPublicKey"; +} + /// A more compact public key /// /// Compared to the [PublicKey], this one is much smaller @@ -168,6 +177,10 @@ impl Tagged for CompactPublicKey { } } +impl Named for CompactPublicKey { + const NAME: &'static str = "high_level_api::CompactPublicKey"; +} + /// Compressed variant of [CompactPublicKey] /// /// The compression of [CompactPublicKey] allows to save disk space @@ -223,3 +236,7 @@ impl Tagged for CompressedCompactPublicKey { &mut self.tag } } + +impl Named for CompressedCompactPublicKey { + const NAME: &'static str = "high_level_api::CompressedCompactPublicKey"; +} diff --git a/tfhe/src/high_level_api/keys/server.rs b/tfhe/src/high_level_api/keys/server.rs index 340485de79..894883ec1d 100644 --- a/tfhe/src/high_level_api/keys/server.rs +++ b/tfhe/src/high_level_api/keys/server.rs @@ -8,6 +8,7 @@ use crate::high_level_api::keys::{IntegerCompressedServerKey, IntegerServerKey}; use crate::integer::compression_keys::{ CompressedCompressionKey, CompressedDecompressionKey, CompressionKey, DecompressionKey, }; +use crate::named::Named; use crate::prelude::Tagged; use crate::shortint::MessageModulus; use crate::Tag; @@ -108,6 +109,10 @@ impl Tagged for ServerKey { } } +impl Named for ServerKey { + const NAME: &'static str = "high_level_api::ServerKey"; +} + impl AsRef for ServerKey { fn as_ref(&self) -> &crate::integer::ServerKey { &self.key.key @@ -255,6 +260,10 @@ impl Tagged for CompressedServerKey { } } +impl Named for CompressedServerKey { + const NAME: &'static str = "high_level_api::CompressedServerKey"; +} + #[cfg(feature = "gpu")] #[derive(Clone)] pub struct CudaServerKey {