[−][src]Trait concrete_lib::operators::crypto::rlwe::RLWE
Required methods
fn sk_encrypt(
t_res: &mut [Self],
sk: &[Self],
t_mu: &[Self],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
t_res: &mut [Self],
sk: &[Self],
t_mu: &[Self],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
fn zero_encryption(
t_res: &mut [Self],
sk: &[Self],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
t_res: &mut [Self],
sk: &[Self],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
fn compute_phase(
t_res: &mut [Self],
sk: &[Self],
t_ct: &[Self],
dimension: usize,
polynomial_size: usize
)
t_res: &mut [Self],
sk: &[Self],
t_ct: &[Self],
dimension: usize,
polynomial_size: usize
)
fn add_gadgetmatrix(
t_res: &mut [Self],
mu: Self,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
t_res: &mut [Self],
mu: Self,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
fn add_gadgetmatrix_generic(
t_res: &mut [Self],
mu: Self,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
t_res: &mut [Self],
mu: Self,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
Implementations on Foreign Types
impl RLWE for u32
[src]
fn sk_encrypt(
t_res: &mut [u32],
sk: &[u32],
t_mu: &[u32],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
[src]
t_res: &mut [u32],
sk: &[u32],
t_mu: &[u32],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
Encrypts a bunch of messages with the same secret key into several RLWE samples, and fill each slot of each sample
Arguments
t_res
-the computed RLWE (output)sk
- the secret key to encrypt the messaget_mu
- the encoded messages to be encrypteddimension
- size of the rlwe maskpolynomial_size: usize
- number of coefficients in polynomialsstd_dev
- standard deviation of the encryption noise
Example
use concrete_lib::operators::crypto::{RLWE, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u32; // settings let mut nb_ct: usize = 10; let mut dimension: usize = 20; let mut polynomial_size: usize = 128; // generates a secret key let sk_len: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); let mut sk: Vec<Torus> = vec![0; sk_len]; Tensor::uniform_random_default(&mut sk); // allocation for messages let mut messages: Vec<Torus> = vec![0; nb_ct * polynomial_size]; // ... (fill the messages) // allocation for the ciphertexts let mut ciphertexts: Vec<Torus> = vec![0; nb_ct * (dimension + 1) * polynomial_size]; // encryption RLWE::sk_encrypt( &mut ciphertexts, &sk, &messages, dimension as usize, polynomial_size, 0.00003, );
fn zero_encryption(
t_res: &mut [u32],
sk: &[u32],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
[src]
t_res: &mut [u32],
sk: &[u32],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
Writes encryptions of zeros in a list of ciphertexts
Arguments
t_res
- the computed RLWE samples (output)sk
- the secret key to encrypt the messagedimension
- size of the rlwe maskpolynomial_size
- number of coefficients in polynomialsstd_dev
- standard deviation of the encryption noise
Example
use concrete_lib::operators::crypto::{RLWE, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u32; // settings let mut nb_ct: usize = 10; let mut dimension: usize = 20; let mut polynomial_size: usize = 128; // generates a secret key let sk_len: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); let mut sk: Vec<Torus> = vec![0; sk_len]; Tensor::uniform_random_default(&mut sk); // allocation for the ciphertexts let mut ciphertexts: Vec<Torus> = vec![0; nb_ct * (dimension + 1) * polynomial_size]; // encryption RLWE::zero_encryption( &mut ciphertexts, &sk, dimension as usize, polynomial_size, 0.00003, );
fn compute_phase(
t_res: &mut [u32],
sk: &[u32],
t_in: &[u32],
dimension: usize,
polynomial_size: usize
)
[src]
t_res: &mut [u32],
sk: &[u32],
t_in: &[u32],
dimension: usize,
polynomial_size: usize
)
Decrypt a bunch of ciphertext encrypted with the same key
Arguments
t_res
- Torus slice containing the decryption of the LWE (output)sk
- torus slice representing a boolean slice, the secret key for encryptiont_in
- Torus slice containing the input ciphertextsdimension
- size of the rlwe maskpolynomial_size
- number of coefficients in polynomials
Example
use concrete_lib::operators::crypto::{RLWE, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u32; // settings let mut nb_ct: usize = 10; let mut dimension: usize = 20; let mut polynomial_size: usize = 128; // generates a secret key let sk_len: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); let mut sk: Vec<Torus> = vec![0; sk_len]; Tensor::uniform_random_default(&mut sk); // allocation for the ciphertexts let mut ciphertexts: Vec<Torus> = vec![0; nb_ct * (dimension + 1) * polynomial_size]; // ... (fill the ciphertexts) // allocation for the decrypted messages let mut decryptions: Vec<Torus> = vec![0; nb_ct * polynomial_size]; // encryption RLWE::compute_phase( &mut decryptions, &sk, &ciphertexts, dimension, polynomial_size, );
fn add_gadgetmatrix(
t_res: &mut [u32],
mu: u32,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
[src]
t_res: &mut [u32],
mu: u32,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
Add one gadget matrix to a well sized set of RLWE samples
Arguments
t_res
- the RLWE samples (output)mu
- a messagedimension
- size of the maskpolynomial_size
- max degree of the polynomials + 1base_log
- number of bits for the base B (B=2^base_log)level
- number of blocks of the gadget matrix Example
use concrete_lib::operators::crypto::{rgsw, RLWE}; type Torus = u32; // settings let dimension: usize = 128; let polynomial_size: usize = 256; let level: usize = 3; let base_log: usize = 4; // compute the sizes for the allocation of the list or rlwe let trgsw_size: usize = rgsw::get_trgsw_size(dimension, polynomial_size, 1, level) ; // allocation of the list of rlwe samples let mut trgsw: Vec<Torus> = vec![0; trgsw_size]; // ... (fill the rlwe samples) let bit = 1; // add the gadget matrix RLWE::add_gadgetmatrix( &mut trgsw, bit as Torus, dimension, polynomial_size, base_log, level, );
fn add_gadgetmatrix_generic(
t_res: &mut [u32],
mu: u32,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
[src]
t_res: &mut [u32],
mu: u32,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
impl RLWE for u64
[src]
fn sk_encrypt(
t_res: &mut [u64],
sk: &[u64],
t_mu: &[u64],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
[src]
t_res: &mut [u64],
sk: &[u64],
t_mu: &[u64],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
Encrypts a bunch of messages with the same secret key into several RLWE samples, and fill each slot of each sample
Arguments
t_res
-the computed RLWE (output)sk
- the secret key to encrypt the messaget_mu
- the encoded messages to be encrypteddimension
- size of the rlwe maskpolynomial_size: usize
- number of coefficients in polynomialsstd_dev
- standard deviation of the encryption noise
Example
use concrete_lib::operators::crypto::{RLWE, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u64; // settings let mut nb_ct: usize = 10; let mut dimension: usize = 20; let mut polynomial_size: usize = 128; // generates a secret key let sk_len: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); let mut sk: Vec<Torus> = vec![0; sk_len]; Tensor::uniform_random_default(&mut sk); // allocation for messages let mut messages: Vec<Torus> = vec![0; nb_ct * polynomial_size]; // ... (fill the messages) // allocation for the ciphertexts let mut ciphertexts: Vec<Torus> = vec![0; nb_ct * (dimension + 1) * polynomial_size]; // encryption RLWE::sk_encrypt( &mut ciphertexts, &sk, &messages, dimension as usize, polynomial_size, 0.00003, );
fn zero_encryption(
t_res: &mut [u64],
sk: &[u64],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
[src]
t_res: &mut [u64],
sk: &[u64],
dimension: usize,
polynomial_size: usize,
std_dev: f64
)
Writes encryptions of zeros in a list of ciphertexts
Arguments
t_res
- the computed RLWE samples (output)sk
- the secret key to encrypt the messagedimension
- size of the rlwe maskpolynomial_size
- number of coefficients in polynomialsstd_dev
- standard deviation of the encryption noise
Example
use concrete_lib::operators::crypto::{RLWE, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u64; // settings let mut nb_ct: usize = 10; let mut dimension: usize = 20; let mut polynomial_size: usize = 128; // generates a secret key let sk_len: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); let mut sk: Vec<Torus> = vec![0; sk_len]; Tensor::uniform_random_default(&mut sk); // allocation for the ciphertexts let mut ciphertexts: Vec<Torus> = vec![0; nb_ct * (dimension + 1) * polynomial_size]; // encryption RLWE::zero_encryption( &mut ciphertexts, &sk, dimension as usize, polynomial_size, 0.00003, );
fn compute_phase(
t_res: &mut [u64],
sk: &[u64],
t_in: &[u64],
dimension: usize,
polynomial_size: usize
)
[src]
t_res: &mut [u64],
sk: &[u64],
t_in: &[u64],
dimension: usize,
polynomial_size: usize
)
Decrypt a bunch of ciphertext encrypted with the same key
Arguments
t_res
- Torus slice containing the decryption of the LWE (output)sk
- torus slice representing a boolean slice, the secret key for encryptiont_in
- Torus slice containing the input ciphertextsdimension
- size of the rlwe maskpolynomial_size
- number of coefficients in polynomials
Example
use concrete_lib::operators::crypto::{RLWE, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u64; // settings let mut nb_ct: usize = 10; let mut dimension: usize = 20; let mut polynomial_size: usize = 128; // generates a secret key let sk_len: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); let mut sk: Vec<Torus> = vec![0; sk_len]; Tensor::uniform_random_default(&mut sk); // allocation for the ciphertexts let mut ciphertexts: Vec<Torus> = vec![0; nb_ct * (dimension + 1) * polynomial_size]; // ... (fill the ciphertexts) // allocation for the decrypted messages let mut decryptions: Vec<Torus> = vec![0; nb_ct * polynomial_size]; // encryption RLWE::compute_phase( &mut decryptions, &sk, &ciphertexts, dimension, polynomial_size, );
fn add_gadgetmatrix(
t_res: &mut [u64],
mu: u64,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
[src]
t_res: &mut [u64],
mu: u64,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
Add one gadget matrix to a well sized set of RLWE samples
Arguments
t_res
- the RLWE samples (output)mu
- a messagedimension
- size of the maskpolynomial_size
- max degree of the polynomials + 1base_log
- number of bits for the base B (B=2^base_log)level
- number of blocks of the gadget matrix Example
use concrete_lib::operators::crypto::{rgsw, RLWE}; type Torus = u64; // settings let dimension: usize = 128; let polynomial_size: usize = 256; let level: usize = 3; let base_log: usize = 4; // compute the sizes for the allocation of the list or rlwe let trgsw_size: usize = rgsw::get_trgsw_size(dimension, polynomial_size, 1, level) ; // allocation of the list of rlwe samples let mut trgsw: Vec<Torus> = vec![0; trgsw_size]; // ... (fill the rlwe samples) let bit = 1; // add the gadget matrix RLWE::add_gadgetmatrix( &mut trgsw, bit as Torus, dimension, polynomial_size, base_log, level, );
fn add_gadgetmatrix_generic(
t_res: &mut [u64],
mu: u64,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)
[src]
t_res: &mut [u64],
mu: u64,
dimension: usize,
polynomial_size: usize,
base_log: usize,
level: usize
)