Struct concrete_core::backends::default::entities::LweCiphertextVector64
source · [−]pub struct LweCiphertextVector64(_);
Expand description
A structure representing a vector of LWE ciphertexts with 64 bits of precision.
Trait Implementations
sourceimpl AbstractEntity for LweCiphertextVector64
impl AbstractEntity for LweCiphertextVector64
type Kind = LweCiphertextVectorKind
type Kind = LweCiphertextVectorKind
sourceimpl Clone for LweCiphertextVector64
impl Clone for LweCiphertextVector64
sourcefn clone(&self) -> LweCiphertextVector64
fn clone(&self) -> LweCiphertextVector64
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for LweCiphertextVector64
impl Debug for LweCiphertextVector64
sourceimpl EntityDeserializationEngine<&[u8], LweCiphertextVector64> for DefaultSerializationEngine
impl EntityDeserializationEngine<&[u8], LweCiphertextVector64> for DefaultSerializationEngine
Description:
Implementation of EntityDeserializationEngine
for DefaultSerializationEngine
that
operates on 64 bits integers. It deserializes a LWE ciphertext vector entity.
sourcefn deserialize(
&mut self,
serialized: &[u8]
) -> Result<LweCiphertextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize(
&mut self,
serialized: &[u8]
) -> Result<LweCiphertextVector64, 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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut 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]
) -> LweCiphertextVector64
unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8]
) -> LweCiphertextVector64
sourceimpl EntitySerializationEngine<LweCiphertextVector64, Vec<u8, Global>> for DefaultSerializationEngine
impl EntitySerializationEngine<LweCiphertextVector64, Vec<u8, Global>> for DefaultSerializationEngine
Description:
Implementation of EntitySerializationEngine
for DefaultSerializationEngine
that operates
on 64 bits integers. It serializes a LWE ciphertext vector entity.
sourcefn serialize(
&mut self,
entity: &LweCiphertextVector64
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize(
&mut self,
entity: &LweCiphertextVector64
) -> 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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut 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: &LweCiphertextVector64
) -> Vec<u8>
unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVector64
) -> Vec<u8>
sourceimpl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey64, LweKeyswitchKey64, LweCiphertext64, LweCiphertextVector64> for FftEngine
impl LweCiphertextDiscardingBitExtractEngine<FftFourierLweBootstrapKey64, LweKeyswitchKey64, LweCiphertext64, LweCiphertextVector64> for FftEngine
Description:
Implementation of LweCiphertextDiscardingBitExtractEngine
for FftEngine
that operates
on 64 bits integers.
sourcefn discard_extract_bits_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertext64,
bsk: &FftFourierLweBootstrapKey64,
ksk: &LweKeyswitchKey64,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog
) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
fn discard_extract_bits_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertext64,
bsk: &FftFourierLweBootstrapKey64,
ksk: &LweKeyswitchKey64,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog
) -> Result<(), LweCiphertextDiscardingBitExtractError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u64 << 50;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(1), PolynomialSize(512));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let extracted_bits_count = ExtractedBitsCount(1);
let delta_log = DeltaLog(5);
let noise = Variance(2_f64.powf(-50.));
let large_lwe_dim = LweDimension(glwe_dim.0 * poly_size.0);
// Unix seeder must be given a secret input.
// Here we just give it 0, and rely on /dev/random only for tests.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let input_lwe_sk: LweSecretKey64 =
default_engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_sk.clone())?;
let output_lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let bsk: LweBootstrapKey64 = default_engine.generate_new_lwe_bootstrap_key(
&output_lwe_sk,
&glwe_sk,
dec_bl,
dec_lc,
noise,
)?;
let ksk: LweKeyswitchKey64 = default_engine.generate_new_lwe_keyswitch_key(
&input_lwe_sk,
&output_lwe_sk,
dec_lc,
dec_bl,
noise,
)?;
let bsk: FftFourierLweBootstrapKey64 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
let 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 LweCiphertextVector64,
input: &LweCiphertext64,
bsk: &FftFourierLweBootstrapKey64,
ksk: &LweKeyswitchKey64,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog
)
unsafe fn discard_extract_bits_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertext64,
bsk: &FftFourierLweBootstrapKey64,
ksk: &LweKeyswitchKey64,
extracted_bits_count: ExtractedBitsCount,
delta_log: DeltaLog
)
sourceimpl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector64, Vec<u64, Global>> for DefaultEngine
impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector64, Vec<u64, Global>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVector64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector64
) -> Result<Vec<u64>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector64
) -> Result<Vec<u64>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
use concrete_core::commons::crypto::lwe::LweCiphertext;
let lwe_size = LweSize(128);
let lwe_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; 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: LweCiphertextVector64 =
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: LweCiphertextVector64
) -> Vec<u64>
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVector64
) -> Vec<u64>
sourceimpl LweCiphertextVectorCreationEngine<Vec<u64, Global>, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorCreationEngine<Vec<u64, Global>, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
LweCiphertextVector64
.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> Result<LweCiphertextVector64, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> Result<LweCiphertextVector64, 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_u64; 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: LweCiphertextVector64 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> LweCiphertextVector64
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> LweCiphertextVector64
sourceimpl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDecryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, 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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector: LweCiphertextVector64 =
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: &LweSecretKey64,
input: &LweCiphertextVector64
) -> PlaintextVector64
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> PlaintextVector64
sourceimpl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAdditionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> 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_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = 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 LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
unsafe fn discard_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
sourceimpl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector64, CleartextVector64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector64, CleartextVector64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
) -> 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_u64 << 50; 8];
let weights_input = vec![2_u64; 8];
let bias_input = 8_u64 << 50;
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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector64 = engine.create_cleartext_vector_from(&input_vector)?;
let bias: Plaintext64 = engine.create_plaintext_from(&bias_input)?;
let plaintext_vector: PlaintextVector64 = 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 LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
)
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
)
sourceimpl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
) -> 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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector: LweCiphertextVector64 =
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: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
)
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
)
sourceimpl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.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: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
sourceimpl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingSubtractionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> 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_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = 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 LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
unsafe fn discard_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
sourceimpl LweCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweCiphertextVector64, LweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweCiphertextVector64, 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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
sourceunsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweCiphertextVector64
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweCiphertextVector64
sourceimpl LweCiphertextVectorEntity for LweCiphertextVector64
impl LweCiphertextVectorEntity for LweCiphertextVector64
sourcefn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
sourcefn lwe_ciphertext_count(&self) -> LweCiphertextCount
fn lwe_ciphertext_count(&self) -> LweCiphertextCount
sourceimpl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingAdditionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> 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_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = 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 LweCiphertextVector64,
input: &LweCiphertextVector64
)
unsafe fn fuse_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
)
sourceimpl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingSubtractionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> 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_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = 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 LweCiphertextVector64,
input: &LweCiphertextVector64
)
unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
) -> 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 50 bits)
let input_vector = vec![3_u64 << 50, 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
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 GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of
LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<Self::EngineError>>
fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
) -> 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 50 bits)
let input_vector = vec![3_u64 << 50, 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let val = vec![1_u64; output_key.polynomial_size().0];
let polynomial: CleartextVector64 = 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 GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
)
unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
)
sourceimpl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector64, PlaintextVector64> for DefaultEngine
sourcefn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, 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_u64 << 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: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector64 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
let output: PlaintextVector64 =
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: &LweCiphertextVector64
) -> PlaintextVector64
unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
input: &LweCiphertextVector64
) -> PlaintextVector64
sourceimpl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, LweCiphertextVector64> for DefaultEngine
sourcefn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> Result<LweCiphertextVector64, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> Result<LweCiphertextVector64, 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_u64 << 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: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector64 =
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: &PlaintextVector64
) -> LweCiphertextVector64
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> LweCiphertextVector64
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, 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: LweSecretKey64 = 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: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultParallelEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultParallelEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultParallelEngine
that
operates on 64 bits integers.
sourcefn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, 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: LweSecretKey64 = 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: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
sourceimpl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> Result<LweCiphertextVector64, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> Result<LweCiphertextVector64, 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 50 bits)
let input = vec![3_u64 << 50; 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: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut seeded_ciphertext_vector: LweSeededCiphertextVector64 =
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);