Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hl): impl Named for key types #1564

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tfhe/src/high_level_api/keys/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -133,3 +134,7 @@ impl AsRef<crate::integer::ClientKey> for ClientKey {
&self.key.key
}
}

impl Named for ClientKey {
const NAME: &'static str = "high_level_api::ClientKey";
}
5 changes: 5 additions & 0 deletions tfhe/src/high_level_api/keys/key_switching_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -95,3 +96,7 @@ impl FheKeyswitch<FheBool> for KeySwitchingKey {
FheBool::new(BooleanBlock::new_unchecked(casted), self.tag_out.clone())
}
}

impl Named for KeySwitchingKey {
const NAME: &'static str = "high_level_api::KeySwitchingKey";
}
17 changes: 17 additions & 0 deletions tfhe/src/high_level_api/keys/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -223,3 +236,7 @@ impl Tagged for CompressedCompactPublicKey {
&mut self.tag
}
}

impl Named for CompressedCompactPublicKey {
const NAME: &'static str = "high_level_api::CompressedCompactPublicKey";
}
9 changes: 9 additions & 0 deletions tfhe/src/high_level_api/keys/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,6 +109,10 @@ impl Tagged for ServerKey {
}
}

impl Named for ServerKey {
const NAME: &'static str = "high_level_api::ServerKey";
}

impl AsRef<crate::integer::ServerKey> for ServerKey {
fn as_ref(&self) -> &crate::integer::ServerKey {
&self.key.key
Expand Down Expand Up @@ -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 {
Expand Down
Loading