Struct concrete_core::backends::core::entities::LweCiphertext64
source · [−]pub struct LweCiphertext64(_);
Expand description
A structure representing an LWE ciphertext with 64 bits of precision.
Trait Implementations
type Kind = LweCiphertextKind
type Kind = LweCiphertextKind
The kind of the entity.
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
fn destroy(
&mut self,
entity: LweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for CoreEngine
that operates on 64 bits integers.
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext64 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(cleartext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
Description:
Implementation of LweCiphertextCleartextFusingMultiplicationEngine
for CoreEngine
that
operates on 64 bits integers.
fn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
fn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext64 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_mul_lwe_ciphertext_cleartext(&mut ciphertext, &cleartext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(cleartext)?;
unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
)
unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
Description:
Implementation of LweCiphertextDecryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext)?;
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Plaintext64
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Plaintext64
Unsafely decrypts an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextDiscardingAdditionEngine
for CoreEngine
that operates on
64 bits integers.
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 7_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
let mut ciphertext_3 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
)
Unsafely adds two LWE ciphertexts. Read more
Description:
Implementation of LweCiphertextDiscardingBootstrapEngine
for CoreEngine
that operates on
64 bits integers.
fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
acc: &GlweCiphertext64,
bsk: &FourierLweBootstrapKey64
) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
acc: &GlweCiphertext64,
bsk: &FourierLweBootstrapKey64
) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, lwe_dim_output, glwe_dim, poly_size) = (
LweDimension(4),
LweDimension(1024),
GlweDimension(1),
PolynomialSize(1024),
);
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
// A constant function is applied during the bootstrap
let lut = vec![8_u64 << 50; poly_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: FourierLweBootstrapKey64 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let lwe_sk_output: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dim_output)?;
let plaintext = engine.create_plaintext(&input)?;
let plaintext_vector = engine.create_plaintext_vector(&lut)?;
let acc = engine.encrypt_glwe_ciphertext(&glwe_sk, &plaintext_vector, noise)?;
let input = engine.encrypt_lwe_ciphertext(&lwe_sk, &plaintext, noise)?;
let mut output = engine.encrypt_lwe_ciphertext(&lwe_sk_output, &plaintext, noise)?;
engine.discard_bootstrap_lwe_ciphertext(&mut output, &input, &acc, &bsk)?;
assert_eq!(output.lwe_dimension(), lwe_dim_output);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
engine.destroy(lwe_sk_output)?;
engine.destroy(plaintext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(acc)?;
engine.destroy(input)?;
engine.destroy(output)?;
unsafe fn discard_bootstrap_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
acc: &GlweCiphertext64,
bsk: &FourierLweBootstrapKey64
)
unsafe fn discard_bootstrap_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
acc: &GlweCiphertext64,
bsk: &FourierLweBootstrapKey64
)
Unsafely bootstrap an LWE ciphertext . Read more
Description:
Implementation of LweCiphertextDiscardingDecryptionEngine
for CoreEngine
that operates
on 64 bits integers.
fn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_decrypt_lwe_ciphertext(&key, &mut plaintext, &ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
unsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
)
unsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
)
Unsafely decrypts an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for CoreEngine
that operates
on 64 bits integers.
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextDiscardingExtractionEngine
for CoreEngine
that operates
on 64 bits integers.
fn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
fn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
GlweDimension, LweDimension, MonomialIndex, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
// The target LWE dimension should be equal to the polynomial size + 1
// since we're going to extract one sample from the GLWE ciphertext
let lwe_dimension = LweDimension(8);
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// We're going to extract the first one
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let glwe_key: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let glwe_ciphertext = engine.encrypt_glwe_ciphertext(&glwe_key, &plaintext_vector, noise)?;
// We first create an LWE ciphertext encrypting zeros
let mut lwe_ciphertext = engine.zero_encrypt_lwe_ciphertext(&lwe_key, noise)?;
// Then we extract the first sample from the GLWE ciphertext to store it into the LWE
engine.discard_extract_lwe_ciphertext(
&mut lwe_ciphertext,
&glwe_ciphertext,
MonomialIndex(0),
)?;
assert_eq!(lwe_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(glwe_key)?;
engine.destroy(lwe_key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(glwe_ciphertext)?;
engine.destroy(lwe_ciphertext)?;
unsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
)
unsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
)
Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for CoreEngine
that operates on
64 bits integers.
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let mut engine = CoreEngine::new()?;
let input_key: LweSecretKey64 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&input_key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&output_key, noise)?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
)
Unsafely keyswitch an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextDiscardingNegationEngine
for CoreEngine
that operates on
64 bits integers.
fn discard_neg_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingNegationError<Self::EngineError>>
fn discard_neg_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingNegationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_neg_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
unsafe fn discard_neg_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
unsafe fn discard_neg_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
Unsafely negates an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextEncryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
unsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweCiphertext64
unsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweCiphertext64
Unsafely encrypts an LWE ciphertext. Read more
The distribution of the key the ciphertext was encrypted with.
Returns the LWE dimension of the ciphertext.
Description:
Implementation of LweCiphertextFusingAdditionEngine
for CoreEngine
that operates on
64 bits integers.
fn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 5_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
engine.fuse_add_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(ciphertext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_2)?;
unsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
unsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
Unsafely add an LWE ciphertext to an other. Read more
Description:
Implementation of LweCiphertextFusingNegationEngine
for CoreEngine
that operates on
64 bits integers.
fn fuse_neg_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext64
) -> Result<(), LweCiphertextFusingNegationError<Self::EngineError>>
fn fuse_neg_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext64
) -> Result<(), LweCiphertextFusingNegationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_neg_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
Unsafely negates an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine
for CoreEngine
that
operates on 64 bits integers.
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
)
Unsafely adds a plaintext to an LWE ciphertext. Read more
Description:
Implementation of LweCiphertextPlaintextFusingAdditionEngine
for CoreEngine
that
operates on 64 bits integers.
fn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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 40 bits)
let input_1 = 3_u64 << 40;
let input_2 = 5_u64 << 40;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
engine.fuse_add_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext)?;
unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
)
unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
)
Unsafely add a plaintext to an LWE ciphertext. Read more
fn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> Result<LweCiphertext64, LweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> Result<LweCiphertext64, LweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{CiphertextCount, LweSize};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = 3_u64 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext64 = engine.create_plaintext(&input)?;
let ciphertext: LweCiphertext64 =
engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;
assert_eq!(ciphertext.lwe_dimension().to_lwe_size(), lwe_size);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
unsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> LweCiphertext64
unsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> LweCiphertext64
Unsafely creates the trivial LWE encryption of the plaintext. Read more
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for CoreEngine
that operates on 64 bits integers.
fn 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_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector64 = engine.create_cleartext_vector(&input_vector)?;
let bias: Plaintext64 = engine.create_plaintext(&bias_input)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&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);
engine.destroy(key)?;
engine.destroy(weights)?;
engine.destroy(bias)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext)?;
unsafe 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
)
Unsafely performs the affine transform of an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextZeroEncryptionEngine
for CoreEngine
that
operates on 64 bits integers.
fn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
unsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> LweCiphertext64
unsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> LweCiphertext64
Safely encrypts zero into an LWE ciphertext. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for LweCiphertext64
impl Send for LweCiphertext64
impl Sync for LweCiphertext64
impl Unpin for LweCiphertext64
impl UnwindSafe for LweCiphertext64
Blanket Implementations
Mutably borrows from an owned value. Read more