pub struct ClientKey { /* private fields */ }Expand description
A structure containing the client key, which must be kept secret.
In more details, it contains:
lwe_secret_key- an LWE secret key, used to encrypt the inputs and decrypt the outputs. This secret key is also used in the generation of bootstrapping and key switching keys.glwe_secret_key- a GLWE secret key, used to generate the bootstrapping keys and key switching keys.parameters- the cryptographic parameter set.
Implementations§
Source§impl ClientKey
impl ClientKey
Sourcepub fn encrypt(&self, message: bool) -> Ciphertext
pub fn encrypt(&self, message: bool) -> Ciphertext
Encrypts a Boolean message using the client key.
§Example
use concrete_boolean::prelude::*;
// Generate the client key and the server key:
let (cks, mut sks) = gen_keys();
// Encryption of one message:
let ct = cks.encrypt(true);
// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(true, dec);Sourcepub fn decrypt(&self, ct: &Ciphertext) -> bool
pub fn decrypt(&self, ct: &Ciphertext) -> bool
Decrypts a ciphertext encrypting a Boolean message using the client key.
§Example
use concrete_boolean::prelude::*;
// Generate the client key and the server key:
let (cks, mut sks) = gen_keys();
// Encryption of one message:
let ct = cks.encrypt(true);
// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(true, dec);Sourcepub fn new(parameter_set: &BooleanParameters) -> ClientKey
pub fn new(parameter_set: &BooleanParameters) -> ClientKey
Allocates and generates a client key.
§Panic
This will panic when the “cuda” feature is enabled and the parameters uses a GlweDimension > 1 (as it is not yet supported by the cuda backend).
§Example
use concrete_boolean::client_key::ClientKey;
use concrete_boolean::parameters::TFHE_LIB_PARAMETERS;
use concrete_boolean::prelude::*;
// Generate the client key:
let cks = ClientKey::new(&TFHE_LIB_PARAMETERS);Trait Implementations§
Source§impl<'de> Deserialize<'de> for ClientKey
impl<'de> Deserialize<'de> for ClientKey
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ClientKey
impl RefUnwindSafe for ClientKey
impl Send for ClientKey
impl Sync for ClientKey
impl Unpin for ClientKey
impl UnwindSafe for ClientKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more