pub trait KeyDispersion: KeyKind {
    fn variance_key_coefficient(log2_modulus: u32) -> Variance;
    fn expectation_key_coefficient() -> f64;
    fn variance_key_coefficient_squared(log2_modulus: u32) -> Variance;
    fn expectation_key_coefficient_squared(log2_modulus: u32) -> f64;
    fn variance_odd_coefficient_in_polynomial_key_squared(
        poly_size: PolynomialSize,
        log2_modulus: u32
    ) -> Variance; fn variance_even_coefficient_in_polynomial_key_squared(
        poly_size: PolynomialSize,
        log2_modulus: u32
    ) -> Variance; fn squared_expectation_mean_in_polynomial_key_squared(
        poly_size: PolynomialSize,
        log2_modulus: u32
    ) -> f64; fn variance_coefficient_in_polynomial_key_times_key(
        poly_size: PolynomialSize,
        log2_modulus: u32
    ) -> Variance; fn square_expectation_mean_in_polynomial_key_times_key(
        poly_size: PolynomialSize
    ) -> f64; }
Expand description

This trait contains functions related to the dispersion of secret key coefficients, and operations related to the secret keys (e.g., products of secret keys).

Required Methods

Returns the variance of key coefficients.

Example
 use concrete_core::prelude::*;
 use concrete_npe::*;

 let var_out_1 =
     Variance::get_modular_variance(&GaussianKeyKind::variance_key_coefficient(64), 64);
 let expected_var_out_1 = 10.24;
 println!("{}", var_out_1);
 assert!((expected_var_out_1 - var_out_1).abs() < 0.0001);

Returns the expectation of key coefficients.

Example
 use concrete_core::prelude::*;
 use concrete_npe::*;

 type ui = u64;

 let expect_out_1 = BinaryKeyKind::expectation_key_coefficient();
 let expected_expect_out_1 = 0.5;
 println!("{}", expect_out_1);
 assert!((expected_expect_out_1 - expect_out_1).abs() < 0.0001);

Returns the variance of the squared key coefficients.

Example
 use concrete_core::prelude::*;
 use concrete_npe::*;

 let var_out_2 =
     Variance::get_modular_variance(&TernaryKeyKind::variance_key_coefficient_squared(64), 64);
 let expected_var_out_2 = 0.2222;
 println!("{}", var_out_2);
 assert!((expected_var_out_2 - var_out_2).abs() < 0.0001);

Returns the expectation of the squared key coefficients.

Example
 use concrete_core::prelude::*;
 use concrete_npe::*;

 let expect_out_2 = GaussianKeyKind::expectation_key_coefficient_squared(64);
 let expected_expect_out_2 = 10.24;
 println!("{}", expect_out_2);
 assert!((expected_expect_out_2 - expect_out_2).abs() < 0.0001);

Returns the variance of the odd coefficients of a polynomial key to the square.

Example
 use concrete_core::prelude::{PolynomialSize, *};
 use concrete_npe::*;

 let polynomial_size = PolynomialSize(1024);

 let var_odd_out_3 = Variance::get_modular_variance(
     &TernaryKeyKind::variance_odd_coefficient_in_polynomial_key_squared(polynomial_size, 64),
     64,
 );
 let expected_var_odd_out_3 = 910.2222;
 println!("{}", var_odd_out_3);
 assert!((expected_var_odd_out_3 - var_odd_out_3).abs() < 0.0001);

Returns the variance of the even coefficients of a polynomial key to the square

Example
 use concrete_core::prelude::{PolynomialSize, *};
 use concrete_npe::*;

 let polynomial_size = PolynomialSize(1024);

 let var_even_out_3 = Variance::get_modular_variance(
     &BinaryKeyKind::variance_even_coefficient_in_polynomial_key_squared(polynomial_size, 64),
     64,
 );
 let expected_var_even_out_3 = 383.75;
 println!("{}", var_even_out_3);
 assert!((expected_var_even_out_3 - var_even_out_3).abs() < 0.0001);

Returns the mean expectation of the coefficients of a polynomial key to the square.

Example
 use concrete_core::prelude::{PolynomialSize, *};
 use concrete_npe::*;

 let polynomial_size = PolynomialSize(1024);

 let expect_out_3 =
     GaussianKeyKind::squared_expectation_mean_in_polynomial_key_squared(polynomial_size, 64);
 let expected_expect_out_3 = 0.0;
 println!("{}", expect_out_3);
 assert!((expected_expect_out_3 - expect_out_3).abs() < 0.0001);

Returns the variance of the coefficients of a polynomial key resulting from the multiplication of two polynomial keys of the same key kind ($S_i \cdot S_j$ with $i,j$ different).

Example
 use concrete_core::prelude::{PolynomialSize, *};
 use concrete_npe::*;

 let polynomial_size = PolynomialSize(1024);

 let var_out_4 = Variance::get_modular_variance(
     &ZeroKeyKind::variance_coefficient_in_polynomial_key_times_key(polynomial_size, 64),
     64,
 );
 let expected_var_out_4 = 0.0;
 println!("{}", var_out_4);
 assert!((expected_var_out_4 - var_out_4).abs() < 0.0001);

Returns the mean expectation of the coefficients of a polynomial key resulting from the multiplication of two polynomial keys of the same key kind ($S_i \cdot S_j$ with $i,j$ different).

Example
 use concrete_core::prelude::{PolynomialSize, *};
 use concrete_npe::*;

 type ui = u64;
 let polynomial_size = PolynomialSize(2048);

 let expect_out_4 =
     BinaryKeyKind::square_expectation_mean_in_polynomial_key_times_key(polynomial_size);
 let expected_expect_out_4 = 87381.375;
 println!("{}", expect_out_4);
 assert!((expected_expect_out_4 - expect_out_4).abs() < 0.0001);

Implementations on Foreign Types

Implementations are provided for binary, ternary and Gaussian key kinds. The ZeroKeyKind is only for debug purposes.

Implementors