Struct concrete_core::backends::default::entities::LweSecretKey64
source · [−]pub struct LweSecretKey64(_);
Expand description
A structure representing an LWE secret key with 64 bits of precision.
Trait Implementations
sourceimpl AbstractEntity for LweSecretKey64
impl AbstractEntity for LweSecretKey64
type Kind = LweSecretKeyKind
type Kind = LweSecretKeyKind
The kind of the entity.
sourceimpl Clone for LweSecretKey64
impl Clone for LweSecretKey64
sourcefn clone(&self) -> LweSecretKey64
fn clone(&self) -> LweSecretKey64
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for LweSecretKey64
impl Debug for LweSecretKey64
sourceimpl DestructionEngine<LweSecretKey64> for DefaultEngine
impl DestructionEngine<LweSecretKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut LweSecretKey64)
unsafe fn destroy_unchecked(&mut self, entity: &mut LweSecretKey64)
Unsafely destroys an entity. Read more
sourceimpl GlweToLweSecretKeyTransformationEngine<GlweSecretKey64, LweSecretKey64> for DefaultEngine
impl GlweToLweSecretKeyTransformationEngine<GlweSecretKey64, LweSecretKey64> for DefaultEngine
sourcefn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransformationEngineError<Self::EngineError>>
fn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// 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 glwe_secret_key: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
let lwe_secret_key = engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
engine.destroy(lwe_secret_key)?;
sourceunsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> LweSecretKey64
unsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> LweSecretKey64
Unsafely transforms a GLWE secret key into an LWE secret key Read more
sourceimpl LweBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultEngine
impl LweBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultEngine
Description:
Implementation of LweBootstrapKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
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 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: LweBootstrapKey64 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
Unsafely creates an LWE bootstrap key. Read more
sourceimpl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextDecryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn 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.));
// 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.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)?;
sourceunsafe 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
sourceimpl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertextView64<'_>, Plaintext64> for DefaultEngine
impl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertextView64<'_>, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextDecryptionEngine
for DefaultEngine
that operates on
an LweCiphertextView64
containing 64 bits integers.
sourcefn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> 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 20 bits)
let input = 3_u64 << 20;
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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut raw_ciphertext[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_view, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
let ciphertext_view: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext[..])?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_view)?;
engine.destroy(decrypted_plaintext)?;
sourceunsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Plaintext64
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Plaintext64
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextDiscardingDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingDecryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn 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.));
// 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.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)?;
sourceunsafe 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
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn 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.));
// 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.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)?;
sourceunsafe 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
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
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.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut output_cipertext_container = vec![0_64; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut output_cipertext_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(output_ciphertext)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextEncryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn 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.));
// 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.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)?;
sourceunsafe 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
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_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
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; 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&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)
);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
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
Unsafely decrypts an LWE ciphertext vector. Read more
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_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
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; 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.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&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));
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
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
)
Unsafely decrypts an LWE ciphertext vector. Read more
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_commons::dispersion::Variance;
use concrete_commons::parameters::{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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&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!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
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
)
Unsafely encryprs an LWE ciphertext vector. Read more
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_commons::dispersion::Variance;
use concrete_commons::parameters::{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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&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!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
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
Unsafely encrypts an LWE ciphertext vector. Read more
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_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, 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 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.create_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);
engine.destroy(key)?;
engine.destroy(ciphertext_vector)?;
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
Unsafely encrypts zeros in an LWE ciphertext vector. Read more
sourceimpl LweCiphertextZeroEncryptionEngine<LweSecretKey64, LweCiphertext64> for DefaultEngine
impl LweCiphertextZeroEncryptionEngine<LweSecretKey64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextZeroEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn 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.));
// 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.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)?;
sourceunsafe 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
sourceimpl LweKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine
Description:
Implementation of LweKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyCreationError<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.));
// 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.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,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey64
unsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey64
Unsafely creates an LWE keyswitch key. Read more
sourceimpl LweSecretKeyCreationEngine<LweSecretKey64> for DefaultEngine
impl LweSecretKeyCreationEngine<LweSecretKey64> for DefaultEngine
Description:
Implementation of LweSecretKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey64, LweSecretKeyCreationError<Self::EngineError>>
fn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey64, LweSecretKeyCreationError<Self::EngineError>>
Example:
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(6);
// 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 lwe_secret_key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
engine.destroy(lwe_secret_key)?;
sourceunsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey64
unsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey64
Unsafely creates an LWE secret key. Read more
sourceimpl LweSecretKeyEntity for LweSecretKey64
impl LweSecretKeyEntity for LweSecretKey64
type KeyDistribution = BinaryKeyDistribution
type KeyDistribution = BinaryKeyDistribution
The distribution of this key.
sourcefn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
Returns the LWE dimension of the key.
sourceimpl LweSeededBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultEngine
impl LweSeededBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn create_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
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 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: LweSeededBootstrapKey64 =
engine.create_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn create_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey64
unsafe fn create_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey64
Unsafely creates a seeded LWE bootstrap key. Read more
sourceimpl LweSeededCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweSeededCiphertext64> for DefaultEngine
impl LweSeededCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweSeededCiphertext64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextEncryptionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn encrypt_lwe_seeded_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweSeededCiphertext64, LweSeededCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_seeded_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweSeededCiphertext64, LweSeededCiphertextEncryptionError<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.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_lwe_seeded_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweSeededCiphertext64
unsafe fn encrypt_lwe_seeded_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweSeededCiphertext64
Unsafely encrypts a seeded LWE ciphertext. Read more
sourceimpl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweSeededCiphertextVector64> for DefaultEngine
impl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweSeededCiphertextVector64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn encrypt_lwe_seeded_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweSeededCiphertextVector64, LweSeededCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_seeded_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweSeededCiphertextVector64, LweSeededCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweSeededCiphertextVector64 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweSeededCiphertextVector64
unsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweSeededCiphertextVector64
Unsafely encrypts a seeded LWE ciphertext vector. Read more
sourceimpl LweSeededKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine
impl LweSeededKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine
sourcefn create_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey64, LweSeededKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey64, LweSeededKeyswitchKeyCreationError<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.));
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(seeded_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(seeded_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(seeded_keyswitch_key)?;
sourceunsafe fn create_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey64
unsafe fn create_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey64
Unsafely creates a seeded LWE keyswitch key. Read more
sourceimpl LweToGlweSecretKeyTransformationEngine<LweSecretKey64, GlweSecretKey64> for DefaultEngine
impl LweToGlweSecretKeyTransformationEngine<LweSecretKey64, GlweSecretKey64> for DefaultEngine
sourcefn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, LweToGlweSecretKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, LweToGlweSecretKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(8);
let polynomial_size = PolynomialSize(4);
// 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 lwe_secret_key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
let glwe_secret_key =
engine.transform_lwe_secret_key_to_glwe_secret_key(lwe_secret_key, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), GlweDimension(2));
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
engine.destroy(glwe_secret_key)?;
sourceunsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
unsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
Unsafely transforms an LWE secret key into a GLWE secret key Read more
sourceimpl PackingKeyswitchKeyCreationEngine<LweSecretKey64, GlweSecretKey64, PackingKeyswitchKey64> for DefaultEngine
impl PackingKeyswitchKeyCreationEngine<LweSecretKey64, GlweSecretKey64, PackingKeyswitchKey64> for DefaultEngine
Description:
Implementation of PackingKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn create_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<PackingKeyswitchKey64, PackingKeyswitchKeyCreationError<Self::EngineError>>
fn create_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<PackingKeyswitchKey64, PackingKeyswitchKeyCreationError<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.));
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let packing_keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(packing_keyswitch_key)?;
sourceunsafe fn create_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> PackingKeyswitchKey64
unsafe fn create_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> PackingKeyswitchKey64
Unsafely creates a packing keyswitch key. Read more
sourceimpl PartialEq<LweSecretKey64> for LweSecretKey64
impl PartialEq<LweSecretKey64> for LweSecretKey64
sourcefn eq(&self, other: &LweSecretKey64) -> bool
fn eq(&self, other: &LweSecretKey64) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &LweSecretKey64) -> bool
fn ne(&self, other: &LweSecretKey64) -> bool
This method tests for !=
.
impl Eq for LweSecretKey64
impl StructuralEq for LweSecretKey64
impl StructuralPartialEq for LweSecretKey64
Auto Trait Implementations
impl RefUnwindSafe for LweSecretKey64
impl Send for LweSecretKey64
impl Sync for LweSecretKey64
impl Unpin for LweSecretKey64
impl UnwindSafe for LweSecretKey64
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more