pub struct LweKeyswitchKey32(/* private fields */);Expand description
A structure representing an LWE keyswitch key with 32 bits of precision.
Trait Implementations§
Source§impl AbstractEntity for LweKeyswitchKey32
impl AbstractEntity for LweKeyswitchKey32
Source§type Kind = LweKeyswitchKeyKind
type Kind = LweKeyswitchKeyKind
Source§impl Clone for LweKeyswitchKey32
impl Clone for LweKeyswitchKey32
Source§fn clone(&self) -> LweKeyswitchKey32
fn clone(&self) -> LweKeyswitchKey32
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LweKeyswitchKey32
impl Debug for LweKeyswitchKey32
Source§impl EntityDeserializationEngine<&[u8], LweKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LweKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweKeyswitchKey32, 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: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let 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(&keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweKeyswitchKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweKeyswitchKey32
Source§impl EntitySerializationEngine<LweKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE keyswitch key entity.
impl EntitySerializationEngine<LweKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LweKeyswitchKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweKeyswitchKey32, ) -> 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: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let 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(&keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweKeyswitchKey32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweKeyswitchKey32) -> Vec<u8> ⓘ
Source§impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey32, LweKeyswitchKey32, LweCiphertext32, LweCiphertextVector32> for FftEngine
§Description:
Implementation of LweCiphertextDiscardingBitExtractEngine for FftEngine that operates
on 32 bits integers.
impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey32, LweKeyswitchKey32, LweCiphertext32, LweCiphertextVector32> for FftEngine
§Description:
Implementation of LweCiphertextDiscardingBitExtractEngine for FftEngine that operates
on 32 bits integers.
Source§fn discard_extract_bits_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertext32,
bsk: &FftFourierLweBootstrapKey32,
ksk: &LweKeyswitchKey32,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog,
) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
fn discard_extract_bits_lwe_ciphertext( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertext32, bsk: &FftFourierLweBootstrapKey32, ksk: &LweKeyswitchKey32, extracted_bits_count: ExtractedBitsCount, delta_log: DeltaLog, ) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
§Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// 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, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(1), PolynomialSize(512));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let extracted_bits_count = ExtractedBitsCount(1);
let delta_log = DeltaLog(5);
let noise = Variance(2_f64.powf(-50.));
let large_lwe_dim = LweDimension(glwe_dim.0 * poly_size.0);
// Unix seeder must be given a secret input.
// Here we just give it 0, and rely on /dev/random only for tests.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let input_lwe_sk: LweSecretKey32 =
default_engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_sk.clone())?;
let output_lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let bsk: LweBootstrapKey32 = default_engine.generate_new_lwe_bootstrap_key(
&output_lwe_sk,
&glwe_sk,
dec_bl,
dec_lc,
noise,
)?;
let ksk: LweKeyswitchKey32 = default_engine.generate_new_lwe_keyswitch_key(
&input_lwe_sk,
&output_lwe_sk,
dec_lc,
dec_bl,
noise,
)?;
let bsk: FftFourierLweBootstrapKey32 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
let input = default_engine.encrypt_lwe_ciphertext(&input_lwe_sk, &plaintext, noise)?;
let mut output = default_engine.zero_encrypt_lwe_ciphertext_vector(
&output_lwe_sk,
noise,
LweCiphertextCount(extracted_bits_count.0),
)?;
fft_engine.discard_extract_bits_lwe_ciphertext(
&mut output,
&input,
&bsk,
&ksk,
extracted_bits_count,
delta_log,
)?;
assert_eq!(output.lwe_dimension(), lwe_dim);
assert_eq!(
output.lwe_ciphertext_count(),
LweCiphertextCount(extracted_bits_count.0)
);
Source§unsafe fn discard_extract_bits_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertext32,
bsk: &FftFourierLweBootstrapKey32,
ksk: &LweKeyswitchKey32,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog,
)
unsafe fn discard_extract_bits_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertext32, bsk: &FftFourierLweBootstrapKey32, ksk: &LweKeyswitchKey32, extracted_bits_count: ExtractedBitsCount, delta_log: DeltaLog, )
Source§impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey32, LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextVectorMutView32<'_>> for FftEngine
§Description:
Implementation of LweCiphertextDiscardingBitExtractEngine for FftEngine that operates
on views containing 32 bits integers.
impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey32, LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextVectorMutView32<'_>> for FftEngine
§Description:
Implementation of LweCiphertextDiscardingBitExtractEngine for FftEngine that operates
on views containing 32 bits integers.
Source§fn discard_extract_bits_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextVectorMutView32<'_>,
input: &LweCiphertextView32<'_>,
bsk: &FftFourierLweBootstrapKey32,
ksk: &LweKeyswitchKey32,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog,
) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
fn discard_extract_bits_lwe_ciphertext( &mut self, output: &mut LweCiphertextVectorMutView32<'_>, input: &LweCiphertextView32<'_>, bsk: &FftFourierLweBootstrapKey32, ksk: &LweKeyswitchKey32, extracted_bits_count: ExtractedBitsCount, delta_log: DeltaLog, ) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
§Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// 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, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(1), PolynomialSize(512));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let extracted_bits_count = ExtractedBitsCount(1);
let delta_log = DeltaLog(5);
let noise = Variance(2_f64.powf(-50.));
let large_lwe_dim = LweDimension(glwe_dim.0 * poly_size.0);
// Unix seeder must be given a secret input.
// Here we just give it 0, and rely on /dev/random only for tests.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let input_lwe_sk: LweSecretKey32 =
default_engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_sk.clone())?;
let output_lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let bsk: LweBootstrapKey32 = default_engine.generate_new_lwe_bootstrap_key(
&output_lwe_sk,
&glwe_sk,
dec_bl,
dec_lc,
noise,
)?;
let ksk: LweKeyswitchKey32 = default_engine.generate_new_lwe_keyswitch_key(
&input_lwe_sk,
&output_lwe_sk,
dec_lc,
dec_bl,
noise,
)?;
let bsk: FftFourierLweBootstrapKey32 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
let mut input_ct_container = vec![0u32; input_lwe_sk.lwe_dimension().to_lwe_size().0];
let mut input: LweCiphertextMutView32 =
default_engine.create_lwe_ciphertext_from(input_ct_container.as_mut_slice())?;
let mut output_ct_vec_container =
vec![0u32; output_lwe_sk.lwe_dimension().to_lwe_size().0 * extracted_bits_count.0];
let mut output: LweCiphertextVectorMutView32 = default_engine
.create_lwe_ciphertext_vector_from(
output_ct_vec_container.as_mut_slice(),
output_lwe_sk.lwe_dimension().to_lwe_size(),
)?;
default_engine.discard_encrypt_lwe_ciphertext(&input_lwe_sk, &mut input, &plaintext, noise)?;
let input_slice = default_engine.consume_retrieve_lwe_ciphertext(input)?;
let input: LweCiphertextView32 = default_engine.create_lwe_ciphertext_from(&input_slice[..])?;
fft_engine.discard_extract_bits_lwe_ciphertext(
&mut output,
&input,
&bsk,
&ksk,
extracted_bits_count,
delta_log,
)?;
assert_eq!(output.lwe_dimension(), lwe_dim);
assert_eq!(
output.lwe_ciphertext_count(),
LweCiphertextCount(extracted_bits_count.0)
);
Source§unsafe fn discard_extract_bits_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextVectorMutView32<'_>,
input: &LweCiphertextView32<'_>,
bsk: &FftFourierLweBootstrapKey32,
ksk: &LweKeyswitchKey32,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog,
)
unsafe fn discard_extract_bits_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextVectorMutView32<'_>, input: &LweCiphertextView32<'_>, bsk: &FftFourierLweBootstrapKey32, ksk: &LweKeyswitchKey32, extracted_bits_count: ExtractedBitsCount, delta_log: DeltaLog, )
Source§impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates
on 32 bits integers.
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates
on 32 bits integers.
Source§fn 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_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.));
// 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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext_from(&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);
Source§unsafe 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, )
Source§impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates
on views containing 32 bits integers.
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates
on views containing 32 bits integers.
Source§fn 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_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.));
// 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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext_from(&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_from(&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_from(&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_from(&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);
Source§unsafe 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, )
Source§impl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey32, Vec<u32>> for DefaultEngine
impl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey32, Vec<u32>> for DefaultEngine
Source§fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKey32,
) -> Result<Vec<u32>, LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key( &mut self, keyswitch_key: LweKeyswitchKey32, ) -> Result<Vec<u32>, LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
§Example:
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(-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 owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let original_vec_ptr = owned_container.as_ptr();
let keyswitch_key: LweKeyswitchKey32 = engine.create_lwe_keyswitch_key_from(
owned_container,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_container = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Source§unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKey32,
) -> Vec<u32>
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKey32, ) -> Vec<u32>
Source§impl LweKeyswitchKeyCreationEngine<Vec<u32>, LweKeyswitchKey32> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<Vec<u32>, LweKeyswitchKey32> for DefaultEngine
Source§fn create_lwe_keyswitch_key_from(
&mut self,
container: Vec<u32>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from( &mut self, container: Vec<u32>, output_lwe_dimension: LweDimension, decomposition_base_log: DecompositionBaseLog, decomposition_level_count: DecompositionLevelCount, ) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
§Example:
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(-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 owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKey32 = engine.create_lwe_keyswitch_key_from(
owned_container,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Source§unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: Vec<u32>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
) -> LweKeyswitchKey32
unsafe fn create_lwe_keyswitch_key_from_unchecked( &mut self, container: Vec<u32>, output_lwe_dimension: LweDimension, decomposition_base_log: DecompositionBaseLog, decomposition_level_count: DecompositionLevelCount, ) -> LweKeyswitchKey32
Source§impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey32, LweKeyswitchKeyMutView32<'_>> for DefaultEngine
impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey32, LweKeyswitchKeyMutView32<'_>> for DefaultEngine
Source§fn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView32<'_>,
input: &LweKeyswitchKey32,
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_keyswitch_key( &mut self, output: &mut LweKeyswitchKeyMutView32<'_>, input: &LweKeyswitchKey32, ) -> Result<(), LweKeyswitchKeyDiscardingConversionError<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_lwe_dimension = LweDimension(3);
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: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut owned_container = vec![
0_u32;
decomposition_level_count.0 * output_lwe_dimension.to_lwe_size().0 * input_lwe_dimension.0
];
let mut out_ksk_mut_view: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
assert_eq!(
assert_eq!(out_ksk_mut_view.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(out_ksk_mut_view.output_lwe_dimension(), output_lwe_dimension);
Source§unsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView32<'_>,
input: &LweKeyswitchKey32,
)
unsafe fn discard_convert_lwe_keyswitch_key_unchecked( &mut self, output: &mut LweKeyswitchKeyMutView32<'_>, input: &LweKeyswitchKey32, )
Source§impl LweKeyswitchKeyEntity for LweKeyswitchKey32
impl LweKeyswitchKeyEntity for LweKeyswitchKey32
Source§fn input_lwe_dimension(&self) -> LweDimension
fn input_lwe_dimension(&self) -> LweDimension
Source§fn output_lwe_dimension(&self) -> LweDimension
fn output_lwe_dimension(&self) -> LweDimension
Source§fn decomposition_level_count(&self) -> DecompositionLevelCount
fn decomposition_level_count(&self) -> DecompositionLevelCount
Source§fn decomposition_base_log(&self) -> DecompositionBaseLog
fn decomposition_base_log(&self) -> DecompositionBaseLog
Source§impl LweKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
§Description:
Implementation of LweKeyswitchKeyGenerationEngine for DefaultEngine that
operates on 32 bits integers.
impl LweKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
§Description:
Implementation of LweKeyswitchKeyGenerationEngine for DefaultEngine that
operates on 32 bits integers.
Source§fn generate_new_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance,
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_keyswitch_key( &mut self, input_key: &LweSecretKey32, output_key: &LweSecretKey32, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, noise: Variance, ) -> Result<LweKeyswitchKey32, LweKeyswitchKeyGenerationError<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_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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_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);
Source§unsafe fn generate_new_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 generate_new_lwe_keyswitch_key_unchecked( &mut self, input_key: &LweSecretKey32, output_key: &LweSecretKey32, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, noise: Variance, ) -> LweKeyswitchKey32
Source§impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine
impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine
Source§fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32,
) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationError<Self::EngineError>>
fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key( &mut self, lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32, ) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationError<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_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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.generate_new_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);
Source§unsafe 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
Source§impl PartialEq for LweKeyswitchKey32
impl PartialEq for LweKeyswitchKey32
impl Eq for LweKeyswitchKey32
impl StructuralPartialEq for LweKeyswitchKey32
Auto Trait Implementations§
impl Freeze for LweKeyswitchKey32
impl RefUnwindSafe for LweKeyswitchKey32
impl Send for LweKeyswitchKey32
impl Sync for LweKeyswitchKey32
impl Unpin for LweKeyswitchKey32
impl UnwindSafe for LweKeyswitchKey32
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
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>
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>
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