pub struct LweCiphertextVectorMutView64<'a>(/* private fields */);Expand description
A structure representing a vector of LWE ciphertext views, with 64 bits of precision.
By view here, we mean that the entity does not own the data, but mutably 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. Mutable variant.
Trait Implementations§
Source§impl AbstractEntity for LweCiphertextVectorMutView64<'_>
impl AbstractEntity for LweCiphertextVectorMutView64<'_>
Source§type Kind = LweCiphertextVectorKind
type Kind = LweCiphertextVectorKind
Source§impl<'a> Debug for LweCiphertextVectorMutView64<'a>
impl<'a> Debug for LweCiphertextVectorMutView64<'a>
Source§impl<'b> EntitySerializationEngine<LweCiphertextVectorMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Mutable variant.
impl<'b> EntitySerializationEngine<LweCiphertextVectorMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Mutable variant.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVectorMutView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVectorMutView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
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 key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut raw_buffer = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
let view: LweCiphertextVectorMutView64 = engine.create_lwe_ciphertext_vector_from(
raw_buffer.as_mut_slice(),
lwe_dimension.to_lwe_size(),
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertextVector64 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVectorMutView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVectorMutView64<'b>, ) -> Vec<u8> ⓘ
Source§impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey64, LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextVectorMutView64<'_>> for FftEngine
§Description:
Implementation of LweCiphertextDiscardingBitExtractEngine for FftEngine that operates
on views containing 64 bits integers.
impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey64, LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextVectorMutView64<'_>> for FftEngine
§Description:
Implementation of LweCiphertextDiscardingBitExtractEngine for FftEngine that operates
on views containing 64 bits integers.
Source§fn discard_extract_bits_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &LweCiphertextView64<'_>,
bsk: &FftFourierLweBootstrapKey64,
ksk: &LweKeyswitchKey64,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog,
) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
fn discard_extract_bits_lwe_ciphertext( &mut self, output: &mut LweCiphertextVectorMutView64<'_>, input: &LweCiphertextView64<'_>, bsk: &FftFourierLweBootstrapKey64, ksk: &LweKeyswitchKey64, 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_u64 << 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: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let input_lwe_sk: LweSecretKey64 =
default_engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_sk.clone())?;
let output_lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let bsk: LweBootstrapKey64 = default_engine.generate_new_lwe_bootstrap_key(
&output_lwe_sk,
&glwe_sk,
dec_bl,
dec_lc,
noise,
)?;
let ksk: LweKeyswitchKey64 = default_engine.generate_new_lwe_keyswitch_key(
&input_lwe_sk,
&output_lwe_sk,
dec_lc,
dec_bl,
noise,
)?;
let bsk: FftFourierLweBootstrapKey64 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
let mut input_ct_container = vec![0u64; input_lwe_sk.lwe_dimension().to_lwe_size().0];
let mut input: LweCiphertextMutView64 =
default_engine.create_lwe_ciphertext_from(input_ct_container.as_mut_slice())?;
let mut output_ct_vec_container =
vec![0u64; output_lwe_sk.lwe_dimension().to_lwe_size().0 * extracted_bits_count.0];
let mut output: LweCiphertextVectorMutView64 = 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: LweCiphertextView64 = 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 LweCiphertextVectorMutView64<'_>,
input: &LweCiphertextView64<'_>,
bsk: &FftFourierLweBootstrapKey64,
ksk: &LweKeyswitchKey64,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog,
)
unsafe fn discard_extract_bits_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextVectorMutView64<'_>, input: &LweCiphertextView64<'_>, bsk: &FftFourierLweBootstrapKey64, ksk: &LweKeyswitchKey64, extracted_bits_count: ExtractedBitsCount, delta_log: DeltaLog, )
Source§impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorMutView64<'data>, &'data mut [u64]> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that
returns the underlying slice of a LweCiphertextVectorMutView64 consuming it in the process
impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorMutView64<'data>, &'data mut [u64]> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that
returns the underlying slice of a LweCiphertextVectorMutView64 consuming it in the process
Source§fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorMutView64<'data>,
) -> Result<&'data mut [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector( &mut self, ciphertext: LweCiphertextVectorMutView64<'data>, ) -> Result<&'data mut [u64], LweCiphertextVectorConsumingRetrievalError<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(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_ciphertext_count.0];
let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
// 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_vector_view: LweCiphertextVectorMutView64 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());Source§unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorMutView64<'data>,
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVectorMutView64<'data>, ) -> &'data mut [u64]
Source§impl<'data> LweCiphertextVectorCreationEngine<&'data mut [u64], LweCiphertextVectorMutView64<'data>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a
mutable LweCiphertextVectorMutView64 that does not own its memory.
impl<'data> LweCiphertextVectorCreationEngine<&'data mut [u64], LweCiphertextVectorMutView64<'data>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a
mutable LweCiphertextVectorMutView64 that does not own its memory.
Source§fn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u64],
lwe_size: LweSize,
) -> Result<LweCiphertextVectorMutView64<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from( &mut self, container: &'data mut [u64], lwe_size: LweSize, ) -> Result<LweCiphertextVectorMutView64<'data>, LweCiphertextVectorCreationError<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(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.0];
let slice = &mut 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_vector_view: LweCiphertextVectorMutView64 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;Source§unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u64],
lwe_size: LweSize,
) -> LweCiphertextVectorMutView64<'data>
unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: &'data mut [u64], lwe_size: LweSize, ) -> LweCiphertextVectorMutView64<'data>
Source§impl LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingEngine<LweCiphertextVectorView64<'_>, LweCiphertextVectorMutView64<'_>, FftFourierLweBootstrapKey64, PlaintextVector64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for FftEngine
impl LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingEngine<LweCiphertextVectorView64<'_>, LweCiphertextVectorMutView64<'_>, FftFourierLweBootstrapKey64, PlaintextVector64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for FftEngine
Source§fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &LweCiphertextVectorView64<'_>,
bsk: &FftFourierLweBootstrapKey64,
luts: &PlaintextVector64,
cbs_level_count: DecompositionLevelCount,
cbs_base_log: DecompositionBaseLog,
cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64,
) -> Result<(), LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingError<Self::EngineError>>
fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertextVectorMutView64<'_>, input: &LweCiphertextVectorView64<'_>, bsk: &FftFourierLweBootstrapKey64, luts: &PlaintextVector64, cbs_level_count: DecompositionLevelCount, cbs_base_log: DecompositionBaseLog, cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, ) -> Result<(), LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingError<Self::EngineError>>
§Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let polynomial_size = PolynomialSize(1024);
let glwe_dimension = GlweDimension(1);
let lwe_dimension = LweDimension(481);
let var_small = Variance::from_variance(2f64.powf(-80.0));
let var_big = Variance::from_variance(2f64.powf(-70.0));
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_small_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dimension)?;
let lwe_big_sk: LweSecretKey64 =
default_engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_sk.clone())?;
let bsk_level_count = DecompositionLevelCount(9);
let bsk_base_log = DecompositionBaseLog(4);
let std_bsk: LweBootstrapKey64 = default_parallel_engine.generate_new_lwe_bootstrap_key(
&lwe_small_sk,
&glwe_sk,
bsk_base_log,
bsk_level_count,
var_small,
)?;
let fourier_bsk: FftFourierLweBootstrapKey64 =
fft_engine.convert_lwe_bootstrap_key(&std_bsk)?;
let ksk_level_count = DecompositionLevelCount(9);
let ksk_base_log = DecompositionBaseLog(1);
let ksk_big_to_small: LweKeyswitchKey64 = default_engine.generate_new_lwe_keyswitch_key(
&lwe_big_sk,
&lwe_small_sk,
ksk_level_count,
ksk_base_log,
var_big,
)?;
let pfpksk_level_count = DecompositionLevelCount(9);
let pfpksk_base_log = DecompositionBaseLog(4);
let cbs_pfpksk: LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64 = default_engine
.generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&lwe_big_sk,
&glwe_sk,
pfpksk_base_log,
pfpksk_level_count,
var_small,
)?;
// We will have a message with 10 bits of information
let message_bits = 10;
let bits_to_extract = ExtractedBitsCount(message_bits);
// The value we encrypt is 42, we will extract the bits of this value and apply the
// circuit bootstrapping followed by the vertical packing on the extracted bits.
let cleartext = 42;
let delta_log_msg = DeltaLog(64 - message_bits);
let encoded_message = default_engine.create_plaintext_from(&(cleartext << delta_log_msg.0))?;
let lwe_in = default_engine.encrypt_lwe_ciphertext(&lwe_big_sk, &encoded_message, var_big)?;
// Bit extraction output, use the zero_encrypt engine to allocate a ciphertext vector
let mut bit_extraction_output = default_engine.zero_encrypt_lwe_ciphertext_vector(
&lwe_small_sk,
var_small,
LweCiphertextCount(bits_to_extract.0),
)?;
fft_engine.discard_extract_bits_lwe_ciphertext(
&mut bit_extraction_output,
&lwe_in,
&fourier_bsk,
&ksk_big_to_small,
bits_to_extract,
delta_log_msg,
)?;
// Though the delta log here is the same as the message delta log, in the general case they
// are different, so we create two DeltaLog parameters
let delta_log_lut = DeltaLog(64 - message_bits);
// Create a look-up table we want to apply during vertical packing, here just the identity
// with the proper encoding.
// Note that this particular table will not trigger the cmux tree from the vertical packing,
// adapt the LUT generation to your usage.
// Here we apply a single look-up table as we output a single ciphertext.
let number_of_luts_and_output_vp_ciphertexts = 1;
let lut_size = 1 << bits_to_extract.0;
let mut lut: Vec<u64> = Vec::with_capacity(lut_size);
for i in 0..lut_size {
lut.push((i as u64 % (1 << message_bits)) << delta_log_lut.0);
}
let lut_as_plaintext_vector = default_engine.create_plaintext_vector_from(lut.as_slice())?;
// We run on views, so we need a container for the output
let mut output_cbs_vp_ct_container = vec![
0u64;
lwe_big_sk.lwe_dimension().to_lwe_size().0
* number_of_luts_and_output_vp_ciphertexts
];
let mut output_cbs_vp_ct_mut_view: LweCiphertextVectorMutView64 = default_engine
.create_lwe_ciphertext_vector_from(
output_cbs_vp_ct_container.as_mut_slice(),
lwe_big_sk.lwe_dimension().to_lwe_size(),
)?;
// And we need to get a view on the bits extracted earlier that serve as inputs to the
// circuit bootstrap + vertical packing
let extracted_bits_lwe_size = bit_extraction_output.lwe_dimension().to_lwe_size();
let extracted_bits_container =
default_engine.consume_retrieve_lwe_ciphertext_vector(bit_extraction_output)?;
let cbs_vp_input_vector_view: LweCiphertextVectorView64 = default_engine
.create_lwe_ciphertext_vector_from(
extracted_bits_container.as_slice(),
extracted_bits_lwe_size,
)?;
let cbs_level_count = DecompositionLevelCount(4);
let cbs_base_log = DecompositionBaseLog(6);
fft_engine.discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector(
&mut output_cbs_vp_ct_mut_view,
&cbs_vp_input_vector_view,
&fourier_bsk,
&lut_as_plaintext_vector,
cbs_level_count,
cbs_base_log,
&cbs_pfpksk,
)?;
assert_eq!(output_cbs_vp_ct_mut_view.lwe_ciphertext_count().0, 1);
assert_eq!(
output_cbs_vp_ct_mut_view.lwe_dimension(),
LweDimension(glwe_dimension.0 * polynomial_size.0)
);
Source§unsafe fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &LweCiphertextVectorView64<'_>,
bsk: &FftFourierLweBootstrapKey64,
luts: &PlaintextVector64,
cbs_level_count: DecompositionLevelCount,
cbs_base_log: DecompositionBaseLog,
cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64,
)
unsafe fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVectorMutView64<'_>, input: &LweCiphertextVectorView64<'_>, bsk: &FftFourierLweBootstrapKey64, luts: &PlaintextVector64, cbs_level_count: DecompositionLevelCount, cbs_base_log: DecompositionBaseLog, cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, )
Source§impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVectorMutView64<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that
operates on 64 bits integers.
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVectorMutView64<'_>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that
operates on 64 bits integers.
Source§fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &PlaintextVector64,
noise: Variance,
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey64, output: &mut LweCiphertextVectorMutView64<'_>, input: &PlaintextVector64, noise: Variance, ) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
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 key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut output_ciphertext_vector_container = vec![0_64; lwe_dimension.to_lwe_size().0 *
lwe_count.0];
let mut ciphertext_vector: LweCiphertextVectorMutView64 =
engine.create_lwe_ciphertext_vector_from(&mut output_ciphertext_vector_container[..],
lwe_dimension.to_lwe_size())?;
engine.discard_encrypt_lwe_ciphertext_vector(&key, &mut ciphertext_vector,
&plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Source§unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &PlaintextVector64,
noise: Variance,
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, output: &mut LweCiphertextVectorMutView64<'_>, input: &PlaintextVector64, noise: Variance, )
Source§impl LweCiphertextVectorEntity for LweCiphertextVectorMutView64<'_>
impl LweCiphertextVectorEntity for LweCiphertextVectorMutView64<'_>
Source§fn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
Source§fn lwe_ciphertext_count(&self) -> LweCiphertextCount
fn lwe_ciphertext_count(&self) -> LweCiphertextCount
Source§impl<'a> PartialEq for LweCiphertextVectorMutView64<'a>
impl<'a> PartialEq for LweCiphertextVectorMutView64<'a>
Source§fn eq(&self, other: &LweCiphertextVectorMutView64<'a>) -> bool
fn eq(&self, other: &LweCiphertextVectorMutView64<'a>) -> bool
self and other values to be equal, and is used by ==.impl<'a> Eq for LweCiphertextVectorMutView64<'a>
impl<'a> StructuralPartialEq for LweCiphertextVectorMutView64<'a>
Auto Trait Implementations§
impl<'a> Freeze for LweCiphertextVectorMutView64<'a>
impl<'a> RefUnwindSafe for LweCiphertextVectorMutView64<'a>
impl<'a> Send for LweCiphertextVectorMutView64<'a>
impl<'a> Sync for LweCiphertextVectorMutView64<'a>
impl<'a> Unpin for LweCiphertextVectorMutView64<'a>
impl<'a> !UnwindSafe for LweCiphertextVectorMutView64<'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