pub struct ClientKey { /* private fields */ }
Expand description

A structure containing the client key, which must be kept secret.

Implementations

Allocates and generates a client key.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

// Generate the client key associated to integers over 4 blocks
// of messages with modulus over 2 bits
let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2, 4);

Allocates and generates a client key from an existing shortint client key.

Example
use concrete_integer::client_key::{ClientKey, VecLength};
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

let shortint_cks = concrete_shortint::ClientKey::new(PARAM_MESSAGE_2_CARRY_2);
let cks = ClientKey::from_shortint(shortint_cks, VecLength(4));

Returns the parameters used by the client key.

Encrypts a integer message using the client key.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

let mut cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2, 4);

let msg = 12_u64;

// Encryption of one message:
let ct = cks.encrypt(msg);

// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(msg, dec);

Encrypts a integer message using the client key.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

let mut cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2, 4);

let msg = 12_u64;

// Encryption of one message:
let ct = cks.encrypt_without_padding(msg);

// Decryption:
let dec = cks.decrypt_without_padding(&ct);
assert_eq!(msg, dec);

Encrypts one block.

This returns a shortint ciphertext.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

let mut cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2, 4);

let msg = 2_u64;

// Encryption of one message:
let ct = cks.encrypt_one_block(msg);

// Decryption:
let dec = cks.decrypt_one_block(&ct);
assert_eq!(msg, dec);

Decrypts one block.

This takes a shortint ciphertext as input.

Decrypts a ciphertext encrypting an integer message + carries using the client key.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::DEFAULT_PARAMETERS;

let cks = ClientKey::new(DEFAULT_PARAMETERS, 4);

let msg = 12_u64;

// Encryption of one message:
let ct = cks.encrypt(msg);

// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(msg, dec);

Decrypts a ciphertext encrypting an integer message + carries using the client key.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::DEFAULT_PARAMETERS;

let cks = ClientKey::new(DEFAULT_PARAMETERS, 4);

let msg = 12_u64;

// Encryption of one message:
let ct = cks.encrypt(msg);

// Decryption:
let dec = cks.decrypt(&ct);
assert_eq!(msg, dec);

Encrypts a small integer message using the client key.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2, 3);

let msg = 13_u64;

// Encryption of one message:
let basis: Vec<u64> = vec![2, 3, 5];
let ct = cks.encrypt_crt(msg, basis);

// Decryption:
let dec = cks.decrypt_crt(&ct);
assert_eq!(msg, dec);

Decrypts a ciphertext encrypting an integer message + carries using the client key.

Example
use concrete_integer::ciphertext::Ciphertext;
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;

// Generate the client key and the server key:
let mut cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2, 3);

let msg = 27_u64;
let basis: Vec<u64> = vec![2, 3, 5];
// Encryption of one message:
let mut ct = cks.encrypt_crt(msg, basis);

// Decryption:
let dec = cks.decrypt_crt(&ct);
assert_eq!(msg, dec);

Encrypts a small integer message using the client key and some moduli without padding bit.

Example
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_3_CARRY_3;

let cks = ClientKey::new(PARAM_MESSAGE_3_CARRY_3, 3);

let msg = 13_u64;

// Encryption of one message:
let basis: Vec<u64> = vec![2, 3, 5];
let ct = cks.encrypt_crt_not_power_of_two(msg, basis);

// Decryption:
let dec = cks.decrypt_crt_not_power_of_two(&ct);
assert_eq!(msg, dec);

Decrypts a ciphertext encrypting an integer message with some moduli basis without padding bit.

Example
use concrete_integer::ciphertext::Ciphertext;
use concrete_integer::client_key::ClientKey;
use concrete_shortint::parameters::PARAM_MESSAGE_3_CARRY_3;

// Generate the client key and the server key:
let mut cks = ClientKey::new(PARAM_MESSAGE_3_CARRY_3, 3);

let msg = 27_u64;
let basis: Vec<u64> = vec![2, 3, 5];
// Encryption of one message:
let mut ct = cks.encrypt_crt(msg, basis);

// Decryption:
let dec = cks.decrypt_crt(&ct);
assert_eq!(msg, dec);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.