pub struct ClientKey {
    pub parameters: Parameters,
    /* 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.

Fields

parameters: Parameters

Implementations

Generates a client key.

Example
use concrete_shortint::client_key::ClientKey;
use concrete_shortint::parameters::Parameters;

// Generate the client key:
let cks = ClientKey::new(Parameters::default());

Encrypts a small integer message using the client key.

The input message is reduced to the encrypted message space modulus

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

let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2);

// Encryption of one message that is within the encrypted message modulus:
let msg = 3;
let ct = cks.encrypt(msg);

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

// Encryption of one message that is outside the encrypted message modulus:
let msg = 5;
let ct = cks.encrypt(msg);

let dec = cks.decrypt(&ct);
let modulus = cks.parameters.message_modulus.0 as u64;
assert_eq!(msg % modulus, dec);

Encrypts a small integer message using the client key with a specific message modulus

Example
use concrete_shortint::parameters::MessageModulus;
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 3;

// Encryption of one message:
let ct = cks.encrypt_with_message_modulus(msg, MessageModulus(6));

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

Encrypts an integer without reducing the input message modulus the message space

Example
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 7;
let ct = cks.unchecked_encrypt(msg);
// |       ct        |
// | carry | message |
// |-------|---------|
// |  0 1  |   1 1   |

let dec = cks.decrypt_message_and_carry(&ct);
assert_eq!(msg, dec);

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

Example
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 3;

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

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

Decrypts a ciphertext encrypting a message using the client key.

Example
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 3;

// 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 without padding bit.

The input message is reduced to the encrypted message space modulus

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

let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2);

// Encryption of one message that is within the encrypted message modulus:
let msg = 6;
let ct = cks.encrypt_without_padding(msg);

let dec = cks.decrypt_message_and_carry_without_padding(&ct);
assert_eq!(msg, dec);

Decrypts a ciphertext encrypting an integer message and carries using the client key, where the ciphertext is assumed to not have any padding bit.

Example
use concrete_shortint::parameters::PARAM_MESSAGE_1_CARRY_1;
use concrete_shortint::ClientKey;

// Generate the client key
let cks = ClientKey::new(PARAM_MESSAGE_1_CARRY_1);

let msg = 3;

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

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

Decrypts a ciphertext encrypting an integer message using the client key, where the ciphertext is assumed to not have any padding bit.

Example
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 7;
let modulus = 4;

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

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

Encrypts a small integer message using the client key without padding bit with some modulus.

The input message is reduced to the encrypted message space modulus

Example
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 2;
let modulus = 3;

// Encryption of one message:
let ct = cks.encrypt_native_crt(msg, modulus);

// Decryption:
let dec = cks.decrypt_message_native_crt(&ct, modulus);
assert_eq!(msg, dec % modulus as u64);

Decrypts a ciphertext encrypting an integer message using the client key, where the ciphertext is assumed to not have any padding bit and is related to some modulus.

Example
use concrete_shortint::{ClientKey, Parameters};

// Generate the client key
let cks = ClientKey::new(Parameters::default());

let msg = 1;
let modulus = 3;

// Encryption of one message:
let ct = cks.encrypt_native_crt(msg, modulus);

// Decryption:
let dec = cks.decrypt_message_native_crt(&ct, modulus);
assert_eq!(msg, dec % modulus as u64);

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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
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.