Struct concrete_core::backends::default::entities::LweKeyswitchKey32
source · [−]pub struct LweKeyswitchKey32(_);
Expand description
A structure representing an LWE keyswitch key with 32 bits of precision.
Trait Implementations
sourceimpl AbstractEntity for LweKeyswitchKey32
impl AbstractEntity for LweKeyswitchKey32
type Kind = LweKeyswitchKeyKind
type Kind = LweKeyswitchKeyKind
The kind of the entity.
sourceimpl Clone for LweKeyswitchKey32
impl Clone for LweKeyswitchKey32
sourcefn clone(&self) -> LweKeyswitchKey32
fn clone(&self) -> LweKeyswitchKey32
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for LweKeyswitchKey32
impl Debug for LweKeyswitchKey32
sourceimpl DestructionEngine<LweKeyswitchKey32> for DefaultEngine
impl DestructionEngine<LweKeyswitchKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweKeyswitchKey32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweKeyswitchKey32)
Unsafely destroys an entity. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
// 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 input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&input_key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&output_key, noise)?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on views containing 32 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
// 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 input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext_1_container = vec![0_u32; input_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&input_key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut raw_ciphertext_2_container = vec![0_u32; output_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_2_container[..])?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweKeyswitchKeyCreationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
Description:
Implementation of LweKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
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 input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
unsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
Unsafely creates an LWE keyswitch key. Read more
sourceimpl LweKeyswitchKeyEntity for LweKeyswitchKey32
impl LweKeyswitchKeyEntity for LweKeyswitchKey32
type InputKeyDistribution = BinaryKeyDistribution
type InputKeyDistribution = BinaryKeyDistribution
The distribution of the key the input ciphertext is encrypted with.
type OutputKeyDistribution = BinaryKeyDistribution
type OutputKeyDistribution = BinaryKeyDistribution
The distribution of the key the output ciphertext is encrypted with.
sourcefn input_lwe_dimension(&self) -> LweDimension
fn input_lwe_dimension(&self) -> LweDimension
Returns the input LWE dimension of the key.
sourcefn output_lwe_dimension(&self) -> LweDimension
fn output_lwe_dimension(&self) -> LweDimension
Returns the output lew dimension of the key.
sourcefn decomposition_level_count(&self) -> DecompositionLevelCount
fn decomposition_level_count(&self) -> DecompositionLevelCount
Returns the number of decomposition levels of the key.
sourcefn decomposition_base_log(&self) -> DecompositionBaseLog
fn decomposition_base_log(&self) -> DecompositionBaseLog
Returns the logarithm of the base used in the key.
sourceimpl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine
impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine
sourcefn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
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 input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let keyswitch_key = engine.transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(seeded_keyswitch_key)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> LweKeyswitchKey32
unsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> LweKeyswitchKey32
Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
sourceimpl PartialEq<LweKeyswitchKey32> for LweKeyswitchKey32
impl PartialEq<LweKeyswitchKey32> for LweKeyswitchKey32
sourcefn eq(&self, other: &LweKeyswitchKey32) -> bool
fn eq(&self, other: &LweKeyswitchKey32) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &LweKeyswitchKey32) -> bool
fn ne(&self, other: &LweKeyswitchKey32) -> bool
This method tests for !=
.
impl Eq for LweKeyswitchKey32
impl StructuralEq for LweKeyswitchKey32
impl StructuralPartialEq for LweKeyswitchKey32
Auto Trait Implementations
impl RefUnwindSafe for LweKeyswitchKey32
impl Send for LweKeyswitchKey32
impl Sync for LweKeyswitchKey32
impl Unpin for LweKeyswitchKey32
impl UnwindSafe for LweKeyswitchKey32
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more