pub struct LwePackingKeyswitchKey64(/* private fields */);Expand description
A structure representing a packing keyswitch key with 64 bits of precision.
Trait Implementations§
Source§impl AbstractEntity for LwePackingKeyswitchKey64
impl AbstractEntity for LwePackingKeyswitchKey64
Source§type Kind = LwePackingKeyswitchKeyKind
type Kind = LwePackingKeyswitchKeyKind
The kind of the entity.
Source§impl Clone for LwePackingKeyswitchKey64
impl Clone for LwePackingKeyswitchKey64
Source§fn clone(&self) -> LwePackingKeyswitchKey64
fn clone(&self) -> LwePackingKeyswitchKey64
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LwePackingKeyswitchKey64
impl Debug for LwePackingKeyswitchKey64
Source§impl EntityDeserializationEngine<&[u8], LwePackingKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a packing keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LwePackingKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a packing keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LwePackingKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LwePackingKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let packing_keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(packing_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LwePackingKeyswitchKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LwePackingKeyswitchKey64
Unsafely deserializes an entity. Read more
Source§impl EntitySerializationEngine<LwePackingKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a packing keyswitch key entity.
impl EntitySerializationEngine<LwePackingKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a packing keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LwePackingKeyswitchKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LwePackingKeyswitchKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let packing_keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(packing_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LwePackingKeyswitchKey64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LwePackingKeyswitchKey64, ) -> Vec<u8> ⓘ
Unsafely serializes an entity. Read more
Source§impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for
DefaultEngine that operates on 64 bits integers.
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for
DefaultEngine that operates on 64 bits integers.
Source§fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64,
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector( &mut self, output: &mut GlweCiphertext64, input: &LweCiphertextVector64, ksk: &LwePackingKeyswitchKey64, ) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input_vector = vec![3_u64 << 50, 256];
// 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;
engine.discard_packing_keyswitch_lwe_ciphertext_vector(
&mut ciphertext_output,
&ciphertext_vector,
&packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
Source§unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64,
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext64, input: &LweCiphertextVector64, ksk: &LwePackingKeyswitchKey64, )
Unsafely packing keyswitches an LWE ciphertext vector. Read more
Source§impl LwePackingKeyswitchKeyEntity for LwePackingKeyswitchKey64
impl LwePackingKeyswitchKeyEntity for LwePackingKeyswitchKey64
Source§fn input_lwe_dimension(&self) -> LweDimension
fn input_lwe_dimension(&self) -> LweDimension
Returns the input LWE dimension of the key.
Source§fn output_glwe_dimension(&self) -> GlweDimension
fn output_glwe_dimension(&self) -> GlweDimension
Returns the output GLWE dimension of the key.
Source§fn output_polynomial_size(&self) -> PolynomialSize
fn output_polynomial_size(&self) -> PolynomialSize
Returns the output polynomial degree of the key.
Source§fn decomposition_level_count(&self) -> DecompositionLevelCount
fn decomposition_level_count(&self) -> DecompositionLevelCount
Returns the number of decomposition levels of the key.
Source§fn decomposition_base_log(&self) -> DecompositionBaseLog
fn decomposition_base_log(&self) -> DecompositionBaseLog
Returns the logarithm of the base used in the key.
Source§impl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePackingKeyswitchKey64> for DefaultEngine
§Description:
Implementation of LwePackingKeyswitchKeyGenerationEngine for DefaultEngine that
operates on 64 bits integers.
impl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePackingKeyswitchKey64> for DefaultEngine
§Description:
Implementation of LwePackingKeyswitchKeyGenerationEngine for DefaultEngine that
operates on 64 bits integers.
Source§fn generate_new_lwe_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance,
) -> Result<LwePackingKeyswitchKey64, LwePackingKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_packing_keyswitch_key( &mut self, input_key: &LweSecretKey64, output_key: &GlweSecretKey64, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, noise: Variance, ) -> Result<LwePackingKeyswitchKey64, LwePackingKeyswitchKeyGenerationError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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_glwe_dimension = GlweDimension(3);
let output_polynomial_size = PolynomialSize(512);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(
output_glwe_dimension,
output_polynomial_size
)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_glwe_dimension(), output_glwe_dimension);
assert_eq!(packing_keyswitch_key.output_polynomial_size(), output_polynomial_size);
Source§unsafe fn generate_new_lwe_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance,
) -> LwePackingKeyswitchKey64
unsafe fn generate_new_lwe_packing_keyswitch_key_unchecked( &mut self, input_key: &LweSecretKey64, output_key: &GlweSecretKey64, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, noise: Variance, ) -> LwePackingKeyswitchKey64
Unsafely generates a new packing keyswitch key. Read more
Source§impl PartialEq for LwePackingKeyswitchKey64
impl PartialEq for LwePackingKeyswitchKey64
impl Eq for LwePackingKeyswitchKey64
impl StructuralPartialEq for LwePackingKeyswitchKey64
Auto Trait Implementations§
impl Freeze for LwePackingKeyswitchKey64
impl RefUnwindSafe for LwePackingKeyswitchKey64
impl Send for LwePackingKeyswitchKey64
impl Sync for LwePackingKeyswitchKey64
impl Unpin for LwePackingKeyswitchKey64
impl UnwindSafe for LwePackingKeyswitchKey64
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more