From c48f8c5d4c2ccecca5b7e4543d3d349a7d2880d4 Mon Sep 17 00:00:00 2001 From: tmontaigu Date: Thu, 14 Nov 2024 10:42:50 +0100 Subject: [PATCH] chore: add parameters getters for CompactPublicKey types --- tfhe/src/high_level_api/keys/inner.rs | 8 ++++++++ tfhe/src/high_level_api/keys/public.rs | 8 ++++++++ tfhe/src/integer/public_key/compact.rs | 12 ++++++++++++ tfhe/src/shortint/public_key/compact.rs | 8 ++++++++ 4 files changed, 36 insertions(+) diff --git a/tfhe/src/high_level_api/keys/inner.rs b/tfhe/src/high_level_api/keys/inner.rs index f3dcc691ab..7f2f47561e 100644 --- a/tfhe/src/high_level_api/keys/inner.rs +++ b/tfhe/src/high_level_api/keys/inner.rs @@ -416,6 +416,10 @@ impl IntegerCompactPublicKey { pub fn from_raw_parts(key: CompactPublicKey) -> Self { Self { key } } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } #[derive(Clone, Debug, Serialize, Deserialize, Versionize)] @@ -455,6 +459,10 @@ impl IntegerCompressedCompactPublicKey { key: CompressedCompactPublicKey::decompress(&self.key), } } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } #[allow(clippy::struct_field_names)] diff --git a/tfhe/src/high_level_api/keys/public.rs b/tfhe/src/high_level_api/keys/public.rs index c9019fc364..1060d18c73 100644 --- a/tfhe/src/high_level_api/keys/public.rs +++ b/tfhe/src/high_level_api/keys/public.rs @@ -167,6 +167,10 @@ impl CompactPublicKey { tag, } } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } impl Tagged for CompactPublicKey { @@ -227,6 +231,10 @@ impl CompressedCompactPublicKey { tag: self.tag.clone(), } } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } impl Tagged for CompressedCompactPublicKey { diff --git a/tfhe/src/integer/public_key/compact.rs b/tfhe/src/integer/public_key/compact.rs index 307c03476a..940f36a9eb 100644 --- a/tfhe/src/integer/public_key/compact.rs +++ b/tfhe/src/integer/public_key/compact.rs @@ -34,6 +34,10 @@ impl> CompactPrivateKey { pub fn key(&self) -> &ShortintCompactPrivateKey { &self.key } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } impl CompactPrivateKey> { @@ -158,6 +162,10 @@ impl CompactPublicKey { pub fn size_bytes(&self) -> usize { self.key.size_bytes() } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Versionize)] @@ -203,6 +211,10 @@ impl CompressedCompactPublicKey { key: self.key.decompress(), } } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.key.parameters() + } } impl ParameterSetConformant for CompactPublicKey { diff --git a/tfhe/src/shortint/public_key/compact.rs b/tfhe/src/shortint/public_key/compact.rs index eaae438a2e..557934b652 100644 --- a/tfhe/src/shortint/public_key/compact.rs +++ b/tfhe/src/shortint/public_key/compact.rs @@ -466,6 +466,10 @@ impl CompactPublicKey { pub fn size_bytes(&self) -> usize { self.key.size_bytes() } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.parameters + } } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Versionize)] @@ -552,6 +556,10 @@ impl CompressedCompactPublicKey { parameters: self.parameters, } } + + pub fn parameters(&self) -> CompactPublicKeyEncryptionParameters { + self.parameters + } } impl ParameterSetConformant for CompactPublicKey {