Struct concrete_core::backends::default::entities::LweCiphertextVector32
source · [−]pub struct LweCiphertextVector32(_);
Expand description
A structure representing a vector of LWE ciphertexts with 32 bits of precision.
Trait Implementations
sourceimpl AbstractEntity for LweCiphertextVector32
impl AbstractEntity for LweCiphertextVector32
type Kind = LweCiphertextVectorKind
type Kind = LweCiphertextVectorKind
sourceimpl Clone for LweCiphertextVector32
impl Clone for LweCiphertextVector32
sourcefn clone(&self) -> LweCiphertextVector32
fn clone(&self) -> LweCiphertextVector32
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for LweCiphertextVector32
impl Debug for LweCiphertextVector32
sourceimpl EntityDeserializationEngine<&[u8], LweCiphertextVector32> for DefaultSerializationEngine
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.
sourcefn 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);
sourceunsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8]
) -> LweCiphertextVector32
unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8]
) -> LweCiphertextVector32
sourceimpl EntitySerializationEngine<LweCiphertextVector32, Vec<u8, Global>> for DefaultSerializationEngine
impl EntitySerializationEngine<LweCiphertextVector32, Vec<u8, Global>> for DefaultSerializationEngine
Description:
Implementation of EntitySerializationEngine
for DefaultSerializationEngine
that operates
on 32 bits integers. It serializes a LWE ciphertext vector entity.
sourcefn 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);
sourceunsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVector32
) -> Vec<u8>
unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVector32
) -> Vec<u8>
sourceimpl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey32, LweKeyswitchKey32, LweCiphertext32, LweCiphertextVector32> for FftEngine
impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey32, LweKeyswitchKey32, LweCiphertext32, LweCiphertextVector32> for FftEngine
Description:
Implementation of LweCiphertextDiscardingBitExtractEngine
for FftEngine
that operates
on 32 bits integers.
sourcefn 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)
);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32, Global>> for DefaultEngine
impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32, Global>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVector32
consuming it in the process
sourcefn 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());
sourceunsafe 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>
sourceimpl LweCiphertextVectorCreationEngine<Vec<u32, Global>, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorCreationEngine<Vec<u32, Global>, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
LweCiphertextVector32
.
sourcefn 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)?;
sourceunsafe 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
sourceimpl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDecryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn 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)
);
sourceunsafe 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
sourceimpl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAdditionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn 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));
sourceunsafe 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
)
sourceimpl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn 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!(
sourceunsafe 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
)
sourceimpl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingSubtractionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn 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!(
sourceunsafe 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
sourceimpl LweCiphertextVectorEntity for LweCiphertextVector32
impl LweCiphertextVectorEntity for LweCiphertextVector32
sourcefn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
sourcefn lwe_ciphertext_count(&self) -> LweCiphertextCount
fn lwe_ciphertext_count(&self) -> LweCiphertextCount
sourceimpl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingAdditionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingSubtractionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of
LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
)
sourceimpl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine
sourcefn 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));
sourceunsafe 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
sourceimpl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine
sourcefn 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
);
sourceunsafe 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
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultParallelEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultParallelEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultParallelEngine
that
operates on 32 bits integers.
sourcefn 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);
sourceunsafe 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
sourceimpl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn 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);