pub struct LweCiphertextView32<'a>(/* private fields */);Expand description
A structure representing an LWE ciphertext view, with 32 bits of precision.
By view here, we mean that the entity does not own the data, but immutably borrows it.
§Notes:
This view is not Clone as Clone for a slice is not defined. It is not Deserialize either, as Deserialize of a slice is not defined. Immutable variant.
Trait Implementations§
Source§impl AbstractEntity for LweCiphertextView32<'_>
impl AbstractEntity for LweCiphertextView32<'_>
Source§type Kind = LweCiphertextKind
type Kind = LweCiphertextKind
Source§impl<'a> Debug for LweCiphertextView32<'a>
impl<'a> Debug for LweCiphertextView32<'a>
Source§impl<'b> EntitySerializationEngine<LweCiphertextView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext view entity.
impl<'b> EntitySerializationEngine<LweCiphertextView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext view entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
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 key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let raw_buffer = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
let view: LweCiphertextView32 = engine.create_lwe_ciphertext_from(raw_buffer.as_slice())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertext32 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextView32<'b>, ) -> Vec<u8> ⓘ
Source§impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView32<'_>, Cleartext32, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine
that operates on views containing 32 bits integers.
impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView32<'_>, Cleartext32, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine
that operates on views containing 32 bits integers.
Source§fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Cleartext32,
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &Cleartext32, ) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
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 cleartext: Cleartext32 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&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 ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Cleartext32,
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &Cleartext32, )
Source§impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextView32<'data>, &'data [u32]> for DefaultEngine
§Description:
Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns
the underlying container of a LweCiphertextView32 consuming it in the process
impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextView32<'data>, &'data [u32]> for DefaultEngine
§Description:
Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns
the underlying container of a LweCiphertextView32 consuming it in the process
Source§fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextView32<'data>,
) -> Result<&'data [u32], LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext( &mut self, ciphertext: LweCiphertextView32<'data>, ) -> Result<&'data [u32], LweCiphertextConsumingRetrievalError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweSize, *};
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext_from(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);Source§unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextView32<'data>,
) -> &'data [u32]
unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertextView32<'data>, ) -> &'data [u32]
Source§impl<'data> LweCiphertextCreationEngine<&'data [u32], LweCiphertextView32<'data>> for DefaultEngine
§Description:
Implementation of LweCiphertextCreationEngine for DefaultEngine which returns an
immutable LweCiphertextView32 that does not own its memory.
impl<'data> LweCiphertextCreationEngine<&'data [u32], LweCiphertextView32<'data>> for DefaultEngine
§Description:
Implementation of LweCiphertextCreationEngine for DefaultEngine which returns an
immutable LweCiphertextView32 that does not own its memory.
Source§fn create_lwe_ciphertext_from(
&mut self,
container: &'data [u32],
) -> Result<LweCiphertextView32<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from( &mut self, container: &'data [u32], ) -> Result<LweCiphertextView32<'data>, LweCiphertextCreationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweSize, *};
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext_from(slice)?;Source§unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u32],
) -> LweCiphertextView32<'data>
unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: &'data [u32], ) -> LweCiphertextView32<'data>
Source§impl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertextView32<'_>, Plaintext32> for DefaultEngine
§Description:
Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on
an LweCiphertextView32 containing 32 bits integers.
impl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertextView32<'_>, Plaintext32> for DefaultEngine
§Description:
Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on
an LweCiphertextView32 containing 32 bits integers.
Source§fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextView32<'_>,
) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext( &mut self, key: &LweSecretKey32, input: &LweCiphertextView32<'_>, ) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
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 key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut raw_ciphertext = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut raw_ciphertext[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_view, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
let ciphertext_view: LweCiphertextView32 =
engine.create_lwe_ciphertext_from(&raw_ciphertext[..])?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
Source§unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextView32<'_>,
) -> Plaintext32
unsafe fn decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, input: &LweCiphertextView32<'_>, ) -> Plaintext32
Source§impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates
on views containing 32 bits integers.
impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates
on views containing 32 bits integers.
Source§fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &LweCiphertextView32<'_>,
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &LweCiphertextView32<'_>, ) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_u32 << 20;
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 key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&input_2)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext_1, noise)?;
let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_2, &plaintext_2, 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 raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView32 =
engine.create_lwe_ciphertext_from(&raw_ciphertext_2[..])?;
let mut ciphertext_3_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_3: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_3_container[..])?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &LweCiphertextView32<'_>,
)
unsafe fn discard_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &LweCiphertextView32<'_>, )
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 LweCiphertextDiscardingBootstrapEngine<FftFourierLweBootstrapKey32, GlweCiphertextView32<'_>, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for FftEngine
§Description
Implementation of LweCiphertextDiscardingBootstrapEngine for FftEngine that operates
on 32 bit integers.
impl LweCiphertextDiscardingBootstrapEngine<FftFourierLweBootstrapKey32, GlweCiphertextView32<'_>, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for FftEngine
§Description
Implementation of LweCiphertextDiscardingBootstrapEngine for FftEngine that operates
on 32 bit integers.
Source§fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
acc: &GlweCiphertextView32<'_>,
bsk: &FftFourierLweBootstrapKey32,
) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
fn discard_bootstrap_lwe_ciphertext( &mut self, output: &mut LweCiphertextMutView32<'_>, input: &LweCiphertextView32<'_>, acc: &GlweCiphertextView32<'_>, bsk: &FftFourierLweBootstrapKey32, ) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
§Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// Here a hard-set encoding is applied (shift by 20 bits)
use concrete_core::backends::fft::engines::FftEngine;
use concrete_core::backends::fft::entities::FftFourierLweBootstrapKey32;
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.));
// 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 fft_engine = FftEngine::new(())?;
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_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let bsk: FftFourierLweBootstrapKey32 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let lwe_sk_output: LweSecretKey32 =
default_engine.generate_new_lwe_secret_key(lwe_dim_output)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
let plaintext_vector = default_engine.create_plaintext_vector_from(&lut)?;
let acc = default_engine
.trivially_encrypt_glwe_ciphertext(glwe_dim.to_glwe_size(), &plaintext_vector)?;
// Get the GlweCiphertext as a View
let raw_glwe = default_engine.consume_retrieve_glwe_ciphertext(acc)?;
let acc: GlweCiphertextView32 =
default_engine.create_glwe_ciphertext_from(&raw_glwe[..], poly_size)?;
let mut raw_input_container = vec![0_u32; lwe_sk.lwe_dimension().to_lwe_size().0];
let input: LweCiphertextMutView32 =
default_engine.create_lwe_ciphertext_from(&mut raw_input_container[..])?;
let input = default_engine.encrypt_lwe_ciphertext(&lwe_sk, &plaintext, noise)?;
// Convert MutView to View
let raw_input = default_engine.consume_retrieve_lwe_ciphertext(input)?;
let input = default_engine.create_lwe_ciphertext_from(&raw_input[..])?;
let mut raw_output_container = vec![0_u32; lwe_sk_output.lwe_dimension().to_lwe_size().0];
let mut output = default_engine.create_lwe_ciphertext_from(&mut raw_output_container[..])?;
fft_engine.discard_bootstrap_lwe_ciphertext(&mut output, &input, &acc, &bsk)?;
assert_eq!(output.lwe_dimension(), lwe_dim_output);
Source§unsafe fn discard_bootstrap_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
acc: &GlweCiphertextView32<'_>,
bsk: &FftFourierLweBootstrapKey32,
)
unsafe fn discard_bootstrap_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input: &LweCiphertextView32<'_>, acc: &GlweCiphertextView32<'_>, bsk: &FftFourierLweBootstrapKey32, )
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 LweCiphertextDiscardingOppositeEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates
on views containing 32 bits integers.
impl LweCiphertextDiscardingOppositeEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates
on views containing 32 bits integers.
Source§fn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
fn discard_opp_lwe_ciphertext( &mut self, output: &mut LweCiphertextMutView32<'_>, input: &LweCiphertextView32<'_>, ) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
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 key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&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 ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
)
unsafe fn discard_opp_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input: &LweCiphertextView32<'_>, )
Source§impl LweCiphertextEntity for LweCiphertextView32<'_>
impl LweCiphertextEntity for LweCiphertextView32<'_>
Source§fn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
Source§impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView32<'_>, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that
operates on views containing 32 bits integers.
impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView32<'_>, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that
operates on views containing 32 bits integers.
Source§fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Plaintext32,
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &Plaintext32, ) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
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 key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&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 ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2 = engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Plaintext32,
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &Plaintext32, )
Source§impl<'a> PartialEq for LweCiphertextView32<'a>
impl<'a> PartialEq for LweCiphertextView32<'a>
impl<'a> Eq for LweCiphertextView32<'a>
impl<'a> StructuralPartialEq for LweCiphertextView32<'a>
Auto Trait Implementations§
impl<'a> Freeze for LweCiphertextView32<'a>
impl<'a> RefUnwindSafe for LweCiphertextView32<'a>
impl<'a> Send for LweCiphertextView32<'a>
impl<'a> Sync for LweCiphertextView32<'a>
impl<'a> Unpin for LweCiphertextView32<'a>
impl<'a> UnwindSafe for LweCiphertextView32<'a>
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> 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