pub struct LweCiphertextVector32(/* private fields */);Expand description
A structure representing a vector of LWE ciphertexts with 32 bits of precision.
Trait Implementations§
Source§impl AbstractEntity for LweCiphertextVector32
impl AbstractEntity for LweCiphertextVector32
Source§type Kind = LweCiphertextVectorKind
type Kind = LweCiphertextVectorKind
Source§impl Clone for LweCiphertextVector32
impl Clone for LweCiphertextVector32
Source§fn clone(&self) -> LweCiphertextVector32
fn clone(&self) -> LweCiphertextVector32
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LweCiphertextVector32
impl Debug for LweCiphertextVector32
Source§impl EntityDeserializationEngine<&[u8], LweCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], LweCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCiphertextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCiphertextVector32, EntityDeserializationError<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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweCiphertextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweCiphertextVector32
Source§impl EntitySerializationEngine<LweCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector entity.
impl EntitySerializationEngine<LweCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVector32, ) -> 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVector32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVector32, ) -> 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 LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that
returns the underlying slice of a LweCiphertextVector32 consuming it in the process
impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that
returns the underlying slice of a LweCiphertextVector32 consuming it in the process
Source§fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector32,
) -> Result<Vec<u32>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector( &mut self, ciphertext: LweCiphertextVector32, ) -> Result<Vec<u32>, 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
use concrete_core::commons::crypto::lwe::LweCiphertext;
let lwe_size = LweSize(128);
let lwe_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.0];
let original_vec_ptr = owned_container.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: LweCiphertextVector32 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());Source§unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVector32,
) -> Vec<u32>
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVector32, ) -> Vec<u32>
Source§impl LweCiphertextVectorCreationEngine<Vec<u32>, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a
LweCiphertextVector32.
impl LweCiphertextVectorCreationEngine<Vec<u32>, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a
LweCiphertextVector32.
Source§fn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u32>,
lwe_size: LweSize,
) -> Result<LweCiphertextVector32, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from( &mut self, container: Vec<u32>, lwe_size: LweSize, ) -> Result<LweCiphertextVector32, LweCiphertextVectorCreationError<Self::EngineError>>
§Example:
use concrete_core::prelude::*;
// 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_u32; lwe_size.0 * lwe_count.0];
// 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: LweCiphertextVector32 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;Source§unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u32>,
lwe_size: LweSize,
) -> LweCiphertextVector32
unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: Vec<u32>, lwe_size: LweSize, ) -> LweCiphertextVector32
Source§impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that operates on
32 bits integers.
impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that operates on
32 bits integers.
Source§fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32,
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey32, input: &LweCiphertextVector32, ) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 18];
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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(18)
);
Source§unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32,
) -> PlaintextVector32
unsafe fn decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, input: &LweCiphertextVector32, ) -> PlaintextVector32
Source§impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingAdditionEngine for DefaultEngine
that operates on 32 bits integers.
impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingAdditionEngine for DefaultEngine
that operates on 32 bits integers.
Source§fn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32,
) -> Result<(), LweCiphertextVectorDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertextVector32, input_1: &LweCiphertextVector32, input_2: &LweCiphertextVector32, ) -> Result<(), LweCiphertextVectorDiscardingAdditionError<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_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_add_lwe_ciphertext_vector(
&mut output_ciphertext_vector,
&ciphertext_vector,
&ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32,
)
unsafe fn discard_add_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input_1: &LweCiphertextVector32, input_2: &LweCiphertextVector32, )
Source§impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine for
DefaultEngine that operates on 32 bits integers.
impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine for
DefaultEngine that operates on 32 bits integers.
Source§fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32,
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
fn discard_affine_transform_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertext32, inputs: &LweCiphertextVector32, weights: &CleartextVector32, bias: &Plaintext32, ) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<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_vector = vec![3_u32 << 20; 8];
let weights_input = vec![2_u32; 8];
let bias_input = 8_u32 << 20;
let noise = Variance::from_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 weights: CleartextVector32 = engine.create_cleartext_vector_from(&input_vector)?;
let bias: Plaintext32 = engine.create_plaintext_from(&bias_input)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_affine_transform_lwe_ciphertext_vector(
&mut output_ciphertext,
&ciphertext_vector,
&weights,
&bias,
)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32,
)
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertext32, inputs: &LweCiphertextVector32, weights: &CleartextVector32, bias: &Plaintext32, )
Source§impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine for DefaultEngine that
operates on 32 bits integers.
impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine for DefaultEngine that
operates on 32 bits integers.
Source§fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32,
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey32, output: &mut PlaintextVector32, input: &LweCiphertextVector32, ) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 18];
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 mut plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_lwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));
Source§unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32,
)
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, output: &mut PlaintextVector32, input: &LweCiphertextVector32, )
Source§impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that
operates on 32 bits integers.
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that
operates on 32 bits integers.
Source§fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance,
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey32, output: &mut LweCiphertextVector32, input: &PlaintextVector32, noise: Variance, ) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;
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: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance,
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, output: &mut LweCiphertextVector32, input: &PlaintextVector32, noise: Variance, )
Source§impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingSubtractionEngine for DefaultEngine
that operates on 32 bits integers.
impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDiscardingSubtractionEngine for DefaultEngine
that operates on 32 bits integers.
Source§fn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32,
) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertextVector32, input_1: &LweCiphertextVector32, input_2: &LweCiphertextVector32, ) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<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_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_sub_lwe_ciphertext_vector(
&mut output_ciphertext_vector,
&ciphertext_vector,
&ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Source§unsafe fn discard_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32,
)
unsafe fn discard_sub_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input_1: &LweCiphertextVector32, input_2: &LweCiphertextVector32, )
Source§impl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorEncryptionEngine for DefaultEngine that operates on
32 bits integers.
impl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorEncryptionEngine for DefaultEngine that operates on
32 bits integers.
Source§fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance,
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Source§unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance,
) -> LweCiphertextVector32
unsafe fn encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> LweCiphertextVector32
Source§impl LweCiphertextVectorEntity for LweCiphertextVector32
impl LweCiphertextVectorEntity for LweCiphertextVector32
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 LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorFusingAdditionEngine for DefaultEngine
that operates on 32 bits integers.
impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorFusingAdditionEngine for DefaultEngine
that operates on 32 bits integers.
Source§fn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32,
) -> Result<(), LweCiphertextVectorFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertextVector32, ) -> Result<(), LweCiphertextVectorFusingAdditionError<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_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.fuse_add_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Source§unsafe fn fuse_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32,
)
unsafe fn fuse_add_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertextVector32, )
Source§impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorFusingSubtractionEngine for DefaultEngine
that operates on 32 bits integers.
impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorFusingSubtractionEngine for DefaultEngine
that operates on 32 bits integers.
Source§fn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32,
) -> Result<(), LweCiphertextVectorFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertextVector32, ) -> Result<(), LweCiphertextVectorFusingSubtractionError<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_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.fuse_sub_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Source§unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32,
)
unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertextVector32, )
Source§impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for
DefaultEngine that operates on 32 bits integers.
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for
DefaultEngine that operates on 32 bits integers.
Source§fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &LwePackingKeyswitchKey32,
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector( &mut self, output: &mut GlweCiphertext32, input: &LweCiphertextVector32, ksk: &LwePackingKeyswitchKey32, ) -> 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 20 bits)
let input_vector = vec![3_u32 << 20, 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: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
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 GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &LwePackingKeyswitchKey32,
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext32, input: &LweCiphertextVector32, ksk: &LwePackingKeyswitchKey32, )
Source§impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
§Description:
Implementation of
LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine for
DefaultEngine that operates on 32 bits integers.
impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
§Description:
Implementation of
LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine for
DefaultEngine that operates on 32 bits integers.
Source§fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32,
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<Self::EngineError>>
fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector( &mut self, output: &mut GlweCiphertext32, input: &LweCiphertextVector32, pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32, ) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<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 20 bits)
let input_vector = vec![3_u32 << 20, 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: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let val = vec![1_u32; output_key.polynomial_size().0];
let polynomial: CleartextVector32 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
StandardDev(noise.get_standard_dev()),
&|x| x,
&polynomial,
)?;
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_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut ciphertext_output,
&ciphertext_vector,
&private_functional_packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
Source§unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32,
)
unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext32, input: &LweCiphertextVector32, pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32, )
Source§impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine
Source§fn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector32,
) -> Result<PlaintextVector32, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_lwe_ciphertext_vector( &mut self, input: &LweCiphertextVector32, ) -> Result<PlaintextVector32, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u32 << 20; 3];
// 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 plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector32 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
let output: PlaintextVector32 =
engine.trivially_decrypt_lwe_ciphertext_vector(&ciphertext_vector)?;
assert_eq!(output.plaintext_count(), PlaintextCount(3));
Source§unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
input: &LweCiphertextVector32,
) -> PlaintextVector32
unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked( &mut self, input: &LweCiphertextVector32, ) -> PlaintextVector32
Source§impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine
Source§fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32,
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext_vector( &mut self, lwe_size: LweSize, input: &PlaintextVector32, ) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u32 << 20; 3];
// 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 plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector32 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
assert_eq!(ciphertext_vector.lwe_dimension().to_lwe_size(), lwe_size);
assert_eq!(
ciphertext_vector.lwe_ciphertext_count().0,
plaintext_vector.plaintext_count().0
);
Source§unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32,
) -> LweCiphertextVector32
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked( &mut self, lwe_size: LweSize, input: &PlaintextVector32, ) -> LweCiphertextVector32
Source§impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine for DefaultEngine that
operates on 32 bits integers.
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine for DefaultEngine that
operates on 32 bits integers.
Source§fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount,
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey32, noise: Variance, count: LweCiphertextCount, ) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<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(2);
let ciphertext_count = LweCiphertextCount(3);
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 ciphertext_vector =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
Source§unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount,
) -> LweCiphertextVector32
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, noise: Variance, count: LweCiphertextCount, ) -> LweCiphertextVector32
Source§impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultParallelEngine
§Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine for DefaultParallelEngine that
operates on 32 bits integers.
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultParallelEngine
§Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine for DefaultParallelEngine that
operates on 32 bits integers.
Source§fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount,
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey32, noise: Variance, count: LweCiphertextCount, ) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<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(2);
let ciphertext_count = LweCiphertextCount(3);
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 mut par_engine = DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let ciphertext_vector =
par_engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
Source§unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount,
) -> LweCiphertextVector32
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, noise: Variance, count: LweCiphertextCount, ) -> LweCiphertextVector32
Source§impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine for
DefaultEngine that operates on 32 bits integers.
impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine
§Description:
Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine for
DefaultEngine that operates on 32 bits integers.
Source§fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32,
) -> Result<LweCiphertextVector32, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector( &mut self, lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32, ) -> Result<LweCiphertextVector32, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
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_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut seeded_ciphertext_vector: LweSeededCiphertextVector32 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let ciphertext_vector = engine
.transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
seeded_ciphertext_vector,
)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
Source§unsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32,
) -> LweCiphertextVector32
unsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked( &mut self, lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32, ) -> LweCiphertextVector32
Source§impl PartialEq for LweCiphertextVector32
impl PartialEq for LweCiphertextVector32
impl Eq for LweCiphertextVector32
impl StructuralPartialEq for LweCiphertextVector32
Auto Trait Implementations§
impl Freeze for LweCiphertextVector32
impl RefUnwindSafe for LweCiphertextVector32
impl Send for LweCiphertextVector32
impl Sync for LweCiphertextVector32
impl Unpin for LweCiphertextVector32
impl UnwindSafe for LweCiphertextVector32
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