Struct concrete_core::backends::core::entities::FourierLweBootstrapKey32
source · [−]pub struct FourierLweBootstrapKey32(_);
Expand description
A structure representing an LWE bootstrap key with 32 bits of precision, in the fourier domain.
Trait Implementations
type Kind = LweBootstrapKeyKind
type Kind = LweBootstrapKeyKind
The kind of the entity.
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
fn destroy(
&mut self,
entity: FourierLweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: FourierLweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
Description:
Implementation of LweBootstrapKeyConversionEngine
for CoreEngine
that operates on
32 bits integers. It converts a bootstrap key from the standard to the Fourier domain.
fn convert_lwe_bootstrap_key(
&mut self,
input: &LweBootstrapKey32
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyConversionError<Self::EngineError>>
fn convert_lwe_bootstrap_key(
&mut self,
input: &LweBootstrapKey32
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyConversionError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FourierLweBootstrapKey32 = engine.convert_lwe_bootstrap_key(&bsk)?;
assert_eq!(fourier_bsk.glwe_dimension(), glwe_dim);
assert_eq!(fourier_bsk.polynomial_size(), poly_size);
assert_eq!(fourier_bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(fourier_bsk.decomposition_base_log(), dec_bl);
assert_eq!(fourier_bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
engine.destroy(fourier_bsk)?;
unsafe fn convert_lwe_bootstrap_key_unchecked(
&mut self,
input: &LweBootstrapKey32
) -> FourierLweBootstrapKey32
unsafe fn convert_lwe_bootstrap_key_unchecked(
&mut self,
input: &LweBootstrapKey32
) -> FourierLweBootstrapKey32
Unsafely converts an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyCreationEngine
for CoreEngine
that operates on
32 bits integers. It outputs a bootstrap key in the Fourier domain.
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: FourierLweBootstrapKey32 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> FourierLweBootstrapKey32
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> FourierLweBootstrapKey32
Unsafely creates an LWE bootstrap key. Read more
The distribution of key the input ciphertext is encrypted with.
The distribution of the key the output ciphertext is encrypted with.
Returns the GLWE dimension of the key.
Returns the polynomial size of the key.
Returns the input LWE dimension of the key.
Returns the number of decomposition levels of the key.
Returns the logarithm of the base used in the key.
Returns the output LWE dimension of the key.
Description:
Implementation of LweCiphertextDiscardingBootstrapEngine
for CoreEngine
that operates on
32 bits integers.
fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, lwe_dim_output, glwe_dim, poly_size) = (
LweDimension(4),
LweDimension(1024),
GlweDimension(1),
PolynomialSize(1024),
);
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
// A constant function is applied during the bootstrap
let lut = vec![8_u32 << 20; poly_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: FourierLweBootstrapKey32 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let lwe_sk_output: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim_output)?;
let plaintext = engine.create_plaintext(&input)?;
let plaintext_vector = engine.create_plaintext_vector(&lut)?;
let acc = engine.encrypt_glwe_ciphertext(&glwe_sk, &plaintext_vector, noise)?;
let input = engine.encrypt_lwe_ciphertext(&lwe_sk, &plaintext, noise)?;
let mut output = engine.zero_encrypt_lwe_ciphertext(&lwe_sk_output, noise)?;
engine.discard_bootstrap_lwe_ciphertext(&mut output, &input, &acc, &bsk)?;
assert_eq!(output.lwe_dimension(), lwe_dim_output);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
engine.destroy(lwe_sk_output)?;
engine.destroy(plaintext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(acc)?;
engine.destroy(input)?;
engine.destroy(output)?;
unsafe fn discard_bootstrap_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
)
unsafe fn discard_bootstrap_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
)
Unsafely bootstrap an LWE ciphertext . Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for FourierLweBootstrapKey32
impl Send for FourierLweBootstrapKey32
impl Sync for FourierLweBootstrapKey32
impl Unpin for FourierLweBootstrapKey32
impl UnwindSafe for FourierLweBootstrapKey32
Blanket Implementations
Mutably borrows from an owned value. Read more