[−][src]Trait concrete_lib::operators::crypto::secret_key::SecretKey
Required methods
fn get_bit(binary_key: &[Self], n: usize) -> bool
fn get_bit_monomial(
binary_key: &[Self],
polynomial_size: usize,
mask_index: usize,
monomial_index: usize
) -> bool
binary_key: &[Self],
polynomial_size: usize,
mask_index: usize,
monomial_index: usize
) -> bool
fn convert_key_to_boolean_slice(
boolean_slice: &mut [bool],
sk: &[Self],
sk_nb_bits: usize
)
boolean_slice: &mut [bool],
sk: &[Self],
sk_nb_bits: usize
)
fn print(sk: &[Self], dimension: usize, polynomial_size: usize)
fn print_ring(sk: &[Self], dimension: usize, polynomial_size: usize)
fn get_secret_key_length(dimension: usize, polynomial_size: usize) -> usize
Implementations on Foreign Types
impl SecretKey for u32
[src]
fn get_bit(binary_key: &[u32], n: usize) -> bool
[src]
Returns the n-th bit (a boolean) of a binary key viewed as a key for a LWE sample
Arguments
binary_key
- a Torus slice representing the binary keyn
- the index of the wanted bit
Output
- the n-th bit of k as a boolean
Example
use concrete_lib::operators::crypto::SecretKey; type Torus = u32; // settings let size: usize = 100; // allocation of a secret key let mut sk: Vec<Torus> = vec![0; size]; // ... (fill the secret key with random) // we want the 7-th (counting from zero) bit of the scret key let bit: bool = SecretKey::get_bit(&sk, 7);
fn get_bit_monomial(
binary_key: &[u32],
polynomial_size: usize,
mask_index: usize,
monomial_index: usize
) -> bool
[src]
binary_key: &[u32],
polynomial_size: usize,
mask_index: usize,
monomial_index: usize
) -> bool
Returns the bit coefficient of the monomial of degree monomial_degree, from the mask_index-th polynomial in the binary polynomial of the RLWE secret key binary_key
Example
- the binary polynomial RLWE secret key binary_key is: (0 + 1X, 1 + 1X, 1 + 0X, 0 + 1X)
- we can see that polynomial_size := 2
- get_bit_monomial(binary_key,polynomial_size,3,0) outputs False because binary_key[3]=0 + 1*X, and the coefficient of X^0 is 0
Arguments
binary_key
- a Torus slice representing a binary polynomial RLWE secret keypolynomial_size
- the number of coefficients in polynomialsmask_index
- a mask indexmonomial_degree
- a degree of a monomial
Output
- the bit coefficient (as a boolean) of the degree monomial_degree monomial of the mask_index-th polynomial in binary_key
Example
use concrete_lib::operators::crypto::SecretKey; type Torus = u32; // settings let size: usize = 100; let polynomial_size: usize = 16; // allocation of a secret key let mut sk: Vec<Torus> = vec![0; size]; // ... (fill the secret key with random) // we want the constant coefficient of the 3-th (counting from zero) polynomial // stored in the scret key if we look at it as a list of degree < 16 polynomials let bit: bool = SecretKey::get_bit_monomial(&sk, polynomial_size, 3, 0);
fn convert_key_to_boolean_slice(
boolean_slice: &mut [bool],
sk: &[u32],
sk_nb_bits: usize
)
[src]
boolean_slice: &mut [bool],
sk: &[u32],
sk_nb_bits: usize
)
Convert a binary key stored in a Torus slice into a boolean slice
Arguments
boolean_slice
- a boolean slice (output)sk
- a Torus slice storing a secret keysk_nb_bits
- the number of bits in the secret key
Example
use concrete_lib::operators::crypto::{secret_key, SecretKey}; type Torus = u32; // settings let dimension: usize = 64; let polynomial_size: usize = 256; let sk_size: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); // allocation of a secret key let mut sk: Vec<Torus> = vec![0; sk_size]; // ... (fill the secret key with random) // allocation of the result let mut bs: Vec<bool> = vec![false; dimension * polynomial_size]; // conversion SecretKey::convert_key_to_boolean_slice(&mut bs, &sk, dimension * polynomial_size);
fn print(sk: &[u32], dimension: usize, polynomial_size: usize)
[src]
Print the key as a string of bits, convenient for seeing a key as a LWE keys there is a space every 8 bits
Arguments
sk
- a Torus slice representing a binary keydimension
- size of the maskpolynomial_size
- number of coefficients in polynomials
Example
use concrete_lib::operators::crypto::{secret_key, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u32; // settings let dimension: usize = 3; let polynomial_size: usize = 2; let sk_size: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); // creation of a random polynomial let mut sk: Vec<Torus> = vec![0; sk_size]; Tensor::uniform_random_default(&mut sk); // print SecretKey::print(&sk, dimension, polynomial_size); // stdout: // [BINARY_KEY] key: 101101
fn print_ring(sk: &[u32], dimension: usize, polynomial_size: usize)
[src]
Print the key as a string of binary polynomials, convenient for seeing a key as a RLWE keys
Arguments
sk
- a Torus slice representing a binary keydimension
- size of the maskpolynomial_size
- number of coefficients in polynomials
Example
use concrete_lib::operators::crypto::{secret_key, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u32; // settings let dimension: usize = 3; let polynomial_size: usize = 2; let sk_size: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); // creation of a random polynomial let mut sk: Vec<Torus> = vec![0; sk_size]; Tensor::uniform_random_default(&mut sk); // print SecretKey::print_ring(&sk, dimension, polynomial_size); // stdout: // [BINARY_KEY] key: // 1 + 1 X // 1 + 0 X // 1 + 0 X
fn get_secret_key_length(dimension: usize, polynomial_size: usize) -> usize
[src]
Returns the number of Torus element needed to represent a binary key for LWE / RLWE samples according to the dimension of the mask and the size of the polynomials when dealing with LWE keys, set polynomial_size to 1
Arguments
dimension
- size of the maskpolynomial_size
- number of coefficients in polynomials
Output
- the length of the Torus slice we need to store this kind of binary key
Example
use concrete_lib::operators::crypto::SecretKey; type Torus = u32; // or u64 // settings let dimension: usize = 128; let polynomial_size: usize = 1024; let length = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size);
impl SecretKey for u64
[src]
fn get_bit(binary_key: &[u64], n: usize) -> bool
[src]
Returns the n-th bit (a boolean) of a binary key viewed as a key for a LWE sample
Arguments
binary_key
- a Torus slice representing the binary keyn
- the index of the wanted bit
Output
- the n-th bit of k as a boolean
Example
use concrete_lib::operators::crypto::SecretKey; type Torus = u64; // settings let size: usize = 100; // allocation of a secret key let mut sk: Vec<Torus> = vec![0; size]; // ... (fill the secret key with random) // we want the 7-th (counting from zero) bit of the scret key let bit: bool = SecretKey::get_bit(&sk, 7);
fn get_bit_monomial(
binary_key: &[u64],
polynomial_size: usize,
mask_index: usize,
monomial_index: usize
) -> bool
[src]
binary_key: &[u64],
polynomial_size: usize,
mask_index: usize,
monomial_index: usize
) -> bool
Returns the bit coefficient of the monomial of degree monomial_degree, from the mask_index-th polynomial in the binary polynomial of the RLWE secret key binary_key
Example
- the binary polynomial RLWE secret key binary_key is: (0 + 1X, 1 + 1X, 1 + 0X, 0 + 1X)
- we can see that polynomial_size := 2
- get_bit_monomial(binary_key,polynomial_size,3,0) outputs False because binary_key[3]=0 + 1*X, and the coefficient of X^0 is 0
Arguments
binary_key
- a Torus slice representing a binary polynomial RLWE secret keypolynomial_size
- the number of coefficients in polynomialsmask_index
- a mask indexmonomial_degree
- a degree of a monomial
Output
- the bit coefficient (as a boolean) of the degree monomial_degree monomial of the mask_index-th polynomial in binary_key
Example
use concrete_lib::operators::crypto::SecretKey; type Torus = u64; // settings let size: usize = 100; let polynomial_size: usize = 16; // allocation of a secret key let mut sk: Vec<Torus> = vec![0; size]; // ... (fill the secret key with random) // we want the constant coefficient of the 3-th (counting from zero) polynomial // stored in the scret key if we look at it as a list of degree < 16 polynomials let bit: bool = SecretKey::get_bit_monomial(&sk, polynomial_size, 3, 0);
fn convert_key_to_boolean_slice(
boolean_slice: &mut [bool],
sk: &[u64],
sk_nb_bits: usize
)
[src]
boolean_slice: &mut [bool],
sk: &[u64],
sk_nb_bits: usize
)
Convert a binary key stored in a Torus slice into a boolean slice
Arguments
boolean_slice
- a boolean slice (output)sk
- a Torus slice storing a secret keysk_nb_bits
- the number of bits in the secret key
Example
use concrete_lib::operators::crypto::{secret_key, SecretKey}; type Torus = u64; // settings let dimension: usize = 64; let polynomial_size: usize = 256; let sk_size: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); // allocation of a secret key let mut sk: Vec<Torus> = vec![0; sk_size]; // ... (fill the secret key with random) // allocation of the result let mut bs: Vec<bool> = vec![false; dimension * polynomial_size]; // conversion SecretKey::convert_key_to_boolean_slice(&mut bs, &sk, dimension * polynomial_size);
fn print(sk: &[u64], dimension: usize, polynomial_size: usize)
[src]
Print the key as a string of bits, convenient for seeing a key as a LWE keys there is a space every 8 bits
Arguments
sk
- a Torus slice representing a binary keydimension
- size of the maskpolynomial_size
- number of coefficients in polynomials
Example
use concrete_lib::operators::crypto::{secret_key, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u64; // settings let dimension: usize = 3; let polynomial_size: usize = 2; let sk_size: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); // creation of a random polynomial let mut sk: Vec<Torus> = vec![0; sk_size]; Tensor::uniform_random_default(&mut sk); // print SecretKey::print(&sk, dimension, polynomial_size); // stdout: // [BINARY_KEY] key: 101101
fn print_ring(sk: &[u64], dimension: usize, polynomial_size: usize)
[src]
Print the key as a string of binary polynomials, convenient for seeing a key as a RLWE keys
Arguments
sk
- a Torus slice representing a binary keydimension
- size of the maskpolynomial_size
- number of coefficients in polynomials
Example
use concrete_lib::operators::crypto::{secret_key, SecretKey}; use concrete_lib::operators::math::Tensor; type Torus = u64; // settings let dimension: usize = 3; let polynomial_size: usize = 2; let sk_size: usize = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size); // creation of a random polynomial let mut sk: Vec<Torus> = vec![0; sk_size]; Tensor::uniform_random_default(&mut sk); // print SecretKey::print_ring(&sk, dimension, polynomial_size); // stdout: // [BINARY_KEY] key: // 1 + 1 X // 1 + 0 X // 1 + 0 X
fn get_secret_key_length(dimension: usize, polynomial_size: usize) -> usize
[src]
Returns the number of Torus element needed to represent a binary key for LWE / RLWE samples according to the dimension of the mask and the size of the polynomials when dealing with LWE keys, set polynomial_size to 1
Arguments
dimension
- size of the maskpolynomial_size
- number of coefficients in polynomials
Output
- the length of the Torus slice we need to store this kind of binary key
Example
use concrete_lib::operators::crypto::SecretKey; type Torus = u32; // or u64 // settings let dimension: usize = 128; let polynomial_size: usize = 1024; let length = <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size);