Struct concrete_core::backends::default::engines::DefaultParallelEngine
source · [−]pub struct DefaultParallelEngine { /* private fields */ }
Trait Implementations
sourceimpl AbstractEngine for DefaultParallelEngine
impl AbstractEngine for DefaultParallelEngine
type EngineError = DefaultParallelError
type EngineError = DefaultParallelError
type Parameters = Box<dyn Seeder + 'static, Global>
type Parameters = Box<dyn Seeder + 'static, Global>
sourcefn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>
fn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>
sourceimpl LweBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweBootstrapKey32> for DefaultParallelEngine
impl LweBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweBootstrapKey32> for DefaultParallelEngine
Description:
Implementation of LweBootstrapKeyGenerationEngine
for DefaultParallelEngine
that
operates on 32 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// 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.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 = default_parallel_engine
.generate_new_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);
sourceunsafe fn generate_new_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
unsafe fn generate_new_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
sourceimpl LweBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultParallelEngine
impl LweBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultParallelEngine
Description:
Implementation of LweBootstrapKeyGenerationEngine
for DefaultParallelEngine
that
operates on 64 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// 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.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 = default_parallel_engine
.generate_new_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);
sourceunsafe fn generate_new_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
unsafe fn generate_new_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultParallelEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultParallelEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultParallelEngine
that
operates on 32 bits integers.
sourcefn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut par_engine = DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let ciphertext_vector =
par_engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
sourceunsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultParallelEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultParallelEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultParallelEngine
that
operates on 64 bits integers.
sourcefn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut par_engine = DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let ciphertext_vector =
par_engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
sourceunsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
sourceimpl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey32, GlweSecretKey32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultParallelEngine
impl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey32, GlweSecretKey32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultParallelEngine
Description:
Implementation of LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine
for DefaultParallelEngine
that operates on 32 bits integers.
sourcefn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension,FunctionalPackingKeyswitchKeyCount
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = default_engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;
let cbs_private_functional_packing_keyswitch_key:
LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32 =
default_engine
.generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&input_key,
&output_key,
decomposition_base_log,
decomposition_level_count,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(cbs_private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.key_count().0,
output_glwe_dimension.to_glwe_size().0);
sourceunsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32
unsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32
sourceimpl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey64, GlweSecretKey64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultParallelEngine
impl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey64, GlweSecretKey64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultParallelEngine
Description:
Implementation of LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine
for DefaultParallelEngine
that operates on 64 bits integers.
sourcefn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension,FunctionalPackingKeyswitchKeyCount
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = default_engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;
let cbs_private_functional_packing_keyswitch_key:
LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64 =
default_engine
.generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&input_key,
&output_key,
decomposition_base_log,
decomposition_level_count,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(cbs_private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.key_count().0,
output_glwe_dimension.to_glwe_size().0);
sourceunsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64
unsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64
sourceimpl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultParallelEngine
impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultParallelEngine
Description:
Implementation of LwePublicKeyGenerationEngine
for DefaultParallelEngine
that operates
on 32 bits integers.
sourcefn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey32, LwePublicKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey32, LwePublicKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, LwePublicKeyZeroEncryptionCount, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let noise = Variance(2_f64.powf(-50.));
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(42);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut par_engine = DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey32 = par_engine.generate_new_lwe_public_key(
&lwe_secret_key,
noise,
lwe_public_key_zero_encryption_count,
)?;
assert_eq!(public_key.lwe_dimension(), lwe_dimension);
assert_eq!(
public_key.lwe_zero_encryption_count(),
lwe_public_key_zero_encryption_count
);
sourceunsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey32
unsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey32
sourceimpl LwePublicKeyGenerationEngine<LweSecretKey64, LwePublicKey64> for DefaultParallelEngine
impl LwePublicKeyGenerationEngine<LweSecretKey64, LwePublicKey64> for DefaultParallelEngine
Description:
Implementation of LwePublicKeyGenerationEngine
for DefaultParallelEngine
that operates
on 64 bits integers.
sourcefn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey64, LwePublicKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey64, LwePublicKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, LwePublicKeyZeroEncryptionCount, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let noise = Variance(2_f64.powf(-50.));
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(42);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut par_engine = DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey64 = par_engine.generate_new_lwe_public_key(
&lwe_secret_key,
noise,
lwe_public_key_zero_encryption_count,
)?;
assert_eq!(public_key.lwe_dimension(), lwe_dimension);
assert_eq!(
public_key.lwe_zero_encryption_count(),
lwe_public_key_zero_encryption_count
);
sourceunsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey64
unsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey64
sourceimpl LweSeededBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweSeededBootstrapKey32> for DefaultParallelEngine
impl LweSeededBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweSeededBootstrapKey32> for DefaultParallelEngine
Description:
Implementation of LweSeededBootstrapKeyGenerationEngine
for DefaultParallelEngine
that
operates on 32 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey32, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey32, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// 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.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweSeededBootstrapKey32 = default_parallel_engine
.generate_new_lwe_seeded_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);
sourceunsafe fn generate_new_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey32
unsafe fn generate_new_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey32
sourceimpl LweSeededBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultParallelEngine
impl LweSeededBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultParallelEngine
Description:
Implementation of LweSeededBootstrapKeyGenerationEngine
for DefaultParallelEngine
that
operates on 64 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// 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.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweSeededBootstrapKey64 = default_parallel_engine
.generate_new_lwe_seeded_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);