Struct concrete::vector_rlwe::VectorRLWE[][src]

pub struct VectorRLWE {
    pub ciphertexts: GlweList<Vec<Torus>>,
    pub variances: Vec<f64>,
    pub dimension: usize,
    pub polynomial_size: usize,
    pub nb_ciphertexts: usize,
    pub encoders: Vec<Encoder>,
}
Expand description

Structure containing a list of RLWE ciphertexts They all have the same dimension (i.e. the length of the RLWE mask). They all have the same number of coefficients in each of their polynomials (which is described by polynomial_size). polynomial_size has to be a power of 2. nb_ciphertexts has to be at least 1.

Attributes

  • ciphertexts - the concatenation of all the RLWE ciphertexts of the list
  • variances - the variances of the noise of each RLWE ciphertext of the list
  • dimension - the length the RLWE mask
  • polynomial_size - the number of coefficients in a polynomial
  • nb_ciphertexts - the number of RLWE ciphertexts present in the list
  • encoders - the encoders of each RLWE ciphertext of the list

Fields

ciphertexts: GlweList<Vec<Torus>>variances: Vec<f64>dimension: usizepolynomial_size: usizenb_ciphertexts: usizeencoders: Vec<Encoder>

Implementations

Instantiate a new VectorRLWE filled with zeros from a polynomial size, a dimension and a number of ciphertexts

Arguments
  • polynomial_size - the number of coefficients in polynomials
  • dimension - the length the RLWE mask
  • nb_ciphertexts - the number of RLWE ciphertexts to be stored in the structure
Output
  • a new instantiation of an VectorRLWE
  • NotPowerOfTwoError if polynomial_size is not a power of 2
  • ZeroCiphertextsInStructureError if we try to create a structure with no ciphertext in it
Example
use concrete::*;

// creates a list of 3 empty RLWE ciphertexts with a polynomial size of 630 and a dimension of 1
let empty_ciphertexts = VectorRLWE::zero(1024, 1, 3).unwrap();

Encrypt several raw plaintexts (list of Torus element instead of a struct Plaintext) with the provided key and standard deviation into one RLWE ciphertext The slots of the RLWE ciphertext are filled with the provided plaintexts and if there are less plaintexts than slots, we pad with zeros

Arguments
  • sk - an LWE secret key
  • plaintexts - a list of plaintexts
  • params - RLWE parameters
Output
  • a new instantiation of an VectorRLWE encrypting the plaintexts provided in one ciphertext RLWE
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode
let enc_messages = encoder.encode(&messages).unwrap();

// encrypt and decrypt
let ct = VectorRLWE::encrypt_packed(&sk, &enc_messages).unwrap();

Encode and encrypt several messages with the provided key into one RLWE ciphertext It means that the polynomial encrypted is P(X)=m0+m1X+m2X^2 … with (m0, m1, m2, …) the messages that have been encoded

Arguments
  • sk - an LWE secret key
  • messages - a list of messages
  • encoder - an encoder
Output
  • a new instantiation of an VectorRLWE encrypting the plaintexts provided in one RLWE ciphertext
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode and encrypt
let ct = VectorRLWE::encode_encrypt_packed(&sk, &messages, &encoder).unwrap();

Encode and encrypt n messages with the provided key into n RLWE ciphertext with only the constant coefficient filled with the message It means that the polynomial encrypted is P(X)=m with m the message that has been encoded

Arguments
  • sk - an LWE secret key
  • plaintexts - a list of plaintexts
Output
  • a new instantiation of an VectorRLWE encrypting the plaintexts provided in as many RLWE ciphertexts as there was messages
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode
let enc_messages = encoder.encode(&messages).unwrap();

// encrypt and decrypt
let ct = VectorRLWE::encrypt(&sk, &enc_messages).unwrap();

Encode and encrypt n messages with the provided key into n RLWE ciphertext with only the constant coefficient filled with the message It means that the polynomial encrypted is P(X)=m with m the the message that have been encoded

Arguments
  • sk - an LWE secret key
  • messages - a list of messages
  • encoder - an encoder
Output
  • a new instantiation of an VectorRLWE encrypting the plaintexts provided in as many RLWE ciphertexts as there was messages
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encrypt and decrypt
let ct = VectorRLWE::encode_encrypt(&sk, &messages, &encoder).unwrap();

Encrypt several raw plaintexts (list of Torus element instead of a struct Plaintext) with the provided key and standard deviation into several ciphertexts RLWE (each coefficient of the polynomial plaintexts is filled)

Arguments
  • sk - an LWE secret key
  • plaintexts - a list of plaintexts
Output
  • WrongSizeError if the plaintext slice length is not a multiple of polynomial size
  • NoNoiseInCiphertextError if the noise distribution is too small for the integer representation

Compute the decryption of each ciphertext

Argument
  • sk - an glwe secret key
Output
  • an array of f64
  • PolynomialSizeError - if the polynomial size of the secret key and the polynomial size of the RLWE ciphertext are different
  • DimensionError - if the dimension of the secret key and the dimension of the RLWE cipertext are different
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode
let enc_messages = encoder.encode(&messages).unwrap();

// encrypt and decrypt
let ct = VectorRLWE::encrypt(&sk, &enc_messages).unwrap();
let res = ct.decrypt_decode(&sk).unwrap();

Compute the decryption of each ciphertext in a rounding setting

Argument
  • sk - an glwe secret key
Output
  • an array of f64
  • PolynomialSizeError - if the polynomial size of the secret key and the polynomial size of the RLWE ciphertext are different
  • DimensionError - if the dimension of the secret key and the dimension of the RLWE cipertext are different
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode
let enc_messages = encoder.encode(&messages).unwrap();

// encrypt and decrypt
let ct = VectorRLWE::encrypt(&sk, &enc_messages).unwrap();
let res = ct.decrypt_decode(&sk).unwrap();

Compute the decryption of each ciphertext and returns also the associated encoder if nb=3 we return the coefficient 0 of the ciphertext 0, the coefficient 1 of the ciphertext 0 and the coefficient 2 of the ciphertext 0

Argument
  • sk - an glwe secret key
  • nb - the number of coeff we want to decrypt
Output
  • an array of f64
  • an array of encoders
  • PolynomialSizeError - if the polynomial size of the secret key and the polynomial size of the RLWE ciphertext are different
  • DimensionError - if the dimension of the secret key and the dimension of the RLWE cipertext are different
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode
let enc_messages = encoder.encode(&messages).unwrap();

// encrypt and decrypt
let ct = VectorRLWE::encrypt(&sk, &enc_messages).unwrap();
let (res, encoders) = ct.decrypt_with_encoders(&sk).unwrap();

Extract the n_coeff-th coefficient of the n_ciphertext-th RLWE ciphertext

Argument
  • n_coeff - the desired coefficient, starts at zero
  • n_ciphertext - the desired RLWE ciphertext, starts at zero
Output
  • the desired LWE as a VectorRLWE structure
  • IndexError - if the requested ciphertext does not exist
  • MonomialError - if the requested monomial does not exist
Example
use concrete::*;
// generate a secret key
let dimension: usize = 1;
let polynomial_size: usize = 1024;
let log_std_dev: i32 = -20;
let sk = RLWESecretKey::new(&RLWE128_1024_1);

// random settings for the encoder and some random messages
let (min, max) = (-43., -10.);
let (precision, padding) = (5, 2);
let encoder = Encoder::new(min, max, precision, padding).unwrap();
let messages: Vec<f64> = vec![-39.69, -19.37, -40.74, -41.26, -35.77];

// encode and encrypt
let ct = VectorRLWE::encode_encrypt_packed(&sk, &messages, &encoder).unwrap();

// convert into LWE secret key
let lwe_sk = sk.to_lwe_secret_key();

// extract a filled coefficient
let n_coeff = 2;
let n_ct = 0;
let res = ct.extract_1_lwe(n_coeff, n_ct).unwrap();

Add small messages to a VectorRLWE ciphertext and does not change the encoding but changes the bodies of the ciphertexts the first message is added to the first coefficient that has a valid encoder the second message is added to the second coefficient that has a valid encoder …

Argument
  • messages - a list of messages as f64
Output
  • A new VectorRLWE
  • NotEnoughValidEncoderError - if messages is bigger than the number of valid encoders

Add small messages to a VectorRLWE ciphertext and does not change the encoding but changes the bodies of the ciphertexts the first message is added to the first coefficient that has a valid encoder the second message is added to the second coefficient that has a valid encoder …

Argument
  • messages - a list of messages as f64
Output
  • NotEnoughValidEncoderError - if messages is bigger than the number of valid encoders

Add messages to an VectorRLWE ciphertext and translate the interval of a distance equal to the message but does not change either the bodies or the masks of the ciphertexts the first message is added to the first coefficient that has a valid encoder the second message is added to the second coefficient that has a valid encoder …

Argument
  • messages - a list of messages as f64
Output
  • a new VectorRLWE
  • NotEnoughValidEncoderError - if messages is bigger than the number of valid encoders

Add messages to an VectorRLWE ciphertext and translate the interval of a distance equal to the message but does not change either the bodies or the masks of the ciphertexts the first message is added to the first coefficient that has a valid encoder the second message is added to the second coefficient that has a valid encoder …

Argument
  • messages - a list of messages as f64
  • NotEnoughValidEncoderError - if messages is bigger than the number of valid encoders

Compute an homomorphic addition between two VectorRLWE ciphertexts and the center of the output Encoder is the sum of the two centers of the input Encoders

Arguments
  • ct - an VectorRLWE struct
Output
  • a new VectorRLWE
  • DimensionError - if the ciphertexts have incompatible dimensions
  • PolynomialSizeError - if the ciphertexts have incompatible polynomial size
  • DeltaError - if the ciphertext encoders have incompatible deltas

Compute an homomorphic addition between two VectorRLWE ciphertexts and the center of the output Encoder is the sum of the two centers of the input Encoders

Arguments
  • ct - an VectorRLWE struct
Output
  • DimensionError - if the ciphertexts have incompatible dimensions
  • PolynomialSizeError - if the ciphertexts have incompatible polynomial size
  • DeltaError - if the ciphertext encoders have incompatible deltas

Compute an addition between two VectorRLWE ciphertexts by eating one bit of padding

Argument
  • ct - an VectorRLWE struct
Output
  • DimensionError - if the ciphertexts have incompatible dimensions
  • PolynomialSizeError - if the ciphertexts have incompatible polynomial size
  • PaddingError - if the ciphertexts ave incompatible paddings
  • NotEnoughPaddingError - if there is no padding
  • DeltaError - if the ciphertexts have incompatile deltas

Compute an addition between two VectorRLWE ciphertexts by eating one bit of padding

Argument
  • ct - an VectorRLWE struct
Output
  • a new VectorRLWE
  • DimensionError - if the ciphertexts have incompatible dimensions
  • PolynomialSizeError - if the ciphertexts have incompatible polynomial size
  • PaddingError - if the ciphertexts ave incompatible paddings
  • NotEnoughPaddingError - if there is no padding
  • DeltaError - if the ciphertexts have incompatile deltas

Compute an addition between two VectorRLWE ciphertexts by eating one bit of padding

Argument
  • ct - an VectorRLWE struct
Output
  • a new VectorRLWE
  • DimensionError - if the ciphertexts have incompatible dimensions
  • PolynomialSizeError - if the ciphertexts have incompatible polynomial size
  • PaddingError - if the ciphertexts ave incompatible paddings
  • NotEnoughPaddingError - if there is no padding
  • DeltaError - if the ciphertexts have incompatile deltas
  • InvalidEncoderError - if one of the ciphertext have an invalid encoder

Compute an addition between two VectorRLWE ciphertexts by eating one bit of padding

Argument
  • ct - an VectorRLWE struct
Output
  • DimensionError - if the ciphertexts have incompatible dimensions
  • PolynomialSizeError - if the ciphertexts have incompatible polynomial size
  • PaddingError - if the ciphertexts ave incompatible paddings
  • NotEnoughPaddingError - if there is no padding
  • DeltaError - if the ciphertexts have incompatile deltas

Multiply VectorRLWE ciphertexts with small integer messages and does not change the encoding but changes the bodies and masks of the ciphertexts

Argument
  • messages - a list of integer messages as Torus elements

Multiply each VectorRLWE ciphertext with a real constant and do change the encoding and the ciphertexts by consuming some bits of padding it needs to have the same number of constant than ciphertexts it also needs that the input encoding all contained zero in their intervals the output precision is the minimum between the input and the number of bits of padding consumed

Argument
  • scale - a positive scaling factor which has to be greater that any of the messages.abs()
  • nb_bit_padding - the number of bits of padding to be consumed
  • messages - a list of real messages as f64
Output

Multiply each VectorRLWE ciphertext with a real constant and do change the encoding and the ciphertexts by consuming some bits of padding it needs to have the same number of constant than ciphertexts it also needs that the input encoding all contained zero in their intervals the output precision is the minimum between the input and the number of bits of padding consumed

Argument
  • scale - a positive scaling factor which has to be greater that any of the messages.abs()
  • nb_bit_padding - the number of bits of padding to be consumed
  • messages - a list of real messages as f64
Output
  • NbCTError - if the ciphertext and the constants have not the same number of samples
  • ConstantMaximumError - if the absolute value of a coefficient in constants is bigger than max_constant
  • ZeroInIntervalError - if 0 is not in the encoder interval
  • NotEnoughPaddingError - if there is not enough padding for the operation

Return the number of valid encoders (i.e. how many messages are carried in those RLWE ciphertexts)

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

Print needed pieces of information about an VectorRLWE

Formats the value using the given formatter. 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

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. 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.