pub struct CrtMultiClientKey { /* private fields */ }Expand description
Client key for CRT decomposition.
As opposed to crate::ClientKey and crate::CrtClientKey, not all blocks in the ciphertext will use the same parameters.
Implementations§
Source§impl CrtMultiClientKey
impl CrtMultiClientKey
Sourcepub fn new_many_keys(parameter_set: &[Parameters]) -> CrtMultiClientKey
pub fn new_many_keys(parameter_set: &[Parameters]) -> CrtMultiClientKey
Create a client key.
§Example
use concrete_integer::CrtMultiClientKey;
use concrete_shortint::parameters::{
DEFAULT_PARAMETERS, PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_3_CARRY_3,
};
// Generate the client key:
let cks = CrtMultiClientKey::new_many_keys(&[PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_3_CARRY_3]);Sourcepub fn encrypt(
&self,
message: &u64,
base_vec: &[u64],
keys_id: &[KeyId],
) -> CrtMultiCiphertext
pub fn encrypt( &self, message: &u64, base_vec: &[u64], keys_id: &[KeyId], ) -> CrtMultiCiphertext
Encrypts an integer using the CRT decomposition, where each block is associated to dedicated key.
§Example
use concrete_integer::{gen_key_id, CrtMultiClientKey};
use concrete_shortint::parameters::{PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_3_CARRY_3};
// Generate the client key:
let cks = CrtMultiClientKey::new_many_keys(&[PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_3_CARRY_3]);
let msg = 15_u64;
// Encryption of one message:
let basis: Vec<u64> = vec![2, 3, 5];
// The first two blocks are encrypted using the first key,
// the third block with the second key
let keys_id = gen_key_id(&[0, 0, 1]);
let ct = cks.encrypt(&msg, &basis, &keys_id);
// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(msg, dec);Sourcepub fn decrypt(&self, ctxt: &CrtMultiCiphertext) -> u64
pub fn decrypt(&self, ctxt: &CrtMultiCiphertext) -> u64
Decrypts an integer in the multi-key CRT settings.
§Example
use concrete_integer::{gen_key_id, CrtMultiClientKey};
use concrete_shortint::parameters::{PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_3_CARRY_3};
// Generate the client key:
let cks = CrtMultiClientKey::new_many_keys(&[PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_3_CARRY_3]);
let msg = 27_u64;
// Encryption of one message:
let basis: Vec<u64> = vec![2, 3, 5];
// The first two blocks are encrypted using the first key,
// the third block with the second key
let keys_id = gen_key_id(&[0, 0, 1]);
let ct = cks.encrypt(&msg, &basis, &keys_id);
// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(msg, dec);Trait Implementations§
Source§impl Clone for CrtMultiClientKey
impl Clone for CrtMultiClientKey
Source§fn clone(&self) -> CrtMultiClientKey
fn clone(&self) -> CrtMultiClientKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CrtMultiClientKey
impl Debug for CrtMultiClientKey
Source§impl<'de> Deserialize<'de> for CrtMultiClientKey
impl<'de> Deserialize<'de> for CrtMultiClientKey
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
Source§impl From<Vec<ClientKey>> for CrtMultiClientKey
Creates a CrtMultiClientKey from a vector of shortint keys.
impl From<Vec<ClientKey>> for CrtMultiClientKey
Creates a CrtMultiClientKey from a vector of shortint keys.
Each key will encrypt one block (in order).
Source§impl PartialEq for CrtMultiClientKey
impl PartialEq for CrtMultiClientKey
Source§impl Serialize for CrtMultiClientKey
impl Serialize for CrtMultiClientKey
impl StructuralPartialEq for CrtMultiClientKey
Auto Trait Implementations§
impl Freeze for CrtMultiClientKey
impl RefUnwindSafe for CrtMultiClientKey
impl Send for CrtMultiClientKey
impl Sync for CrtMultiClientKey
impl Unpin for CrtMultiClientKey
impl UnwindSafe for CrtMultiClientKey
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