Struct concrete_core::backends::core::engines::CoreEngine
source · [−]pub struct CoreEngine { /* private fields */ }
Expand description
The main engine exposed by the core backend.
Trait Implementations
type EngineError = CoreError
type EngineError = CoreError
The error associated to the engine.
A constructor for the engine.
Description:
Implementation of CleartextCreationEngine
for CoreEngine
that operates on 32 bits
integers.
fn create_cleartext(
&mut self,
input: &u32
) -> Result<Cleartext32, CleartextCreationError<Self::EngineError>>
fn create_cleartext(
&mut self,
input: &u32
) -> Result<Cleartext32, CleartextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u32 = 3;
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext32 = engine.create_cleartext(&input)?;
engine.destroy(cleartext)?;
Unsafely creates a cleartext from an arbitrary value. Read more
Description:
Implementation of CleartextCreationEngine
for CoreEngine
that operates on 64 bits
integers.
fn create_cleartext(
&mut self,
input: &u64
) -> Result<Cleartext64, CleartextCreationError<Self::EngineError>>
fn create_cleartext(
&mut self,
input: &u64
) -> Result<Cleartext64, CleartextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u64 = 3;
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext64 = engine.create_cleartext(&input)?;
engine.destroy(cleartext)?;
Unsafely creates a cleartext from an arbitrary value. Read more
Description:
Implementation of CleartextDiscardingRetrievalEngine
for CoreEngine
that operates on 32
bits integers.
fn discard_retrieve_cleartext(
&mut self,
output: &mut u32,
input: &Cleartext32
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext(
&mut self,
output: &mut u32,
input: &Cleartext32
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u32 = 3;
let mut output: u32 = 0;
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext32 = engine.create_cleartext(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3_u32);
engine.destroy(cleartext)?;
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u32,
input: &Cleartext32
)
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u32,
input: &Cleartext32
)
Unsafely retrieves an arbitrary value from a cleartext. Read more
Description:
Implementation of CleartextDiscardingRetrievalEngine
for CoreEngine
that operates on 32
bits integers.
fn discard_retrieve_cleartext(
&mut self,
output: &mut u64,
input: &Cleartext64
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext(
&mut self,
output: &mut u64,
input: &Cleartext64
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u64 = 3;
let mut output: u64 = 0;
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext64 = engine.create_cleartext(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3_u64);
engine.destroy(cleartext)?;
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u64,
input: &Cleartext64
)
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u64,
input: &Cleartext64
)
Unsafely retrieves an arbitrary value from a cleartext. Read more
Description:
Implementation of CleartextRetrievalEngine
for CoreEngine
that operates on 32 bits
integers.
fn retrieve_cleartext(
&mut self,
cleartext: &Cleartext32
) -> Result<u32, CleartextRetrievalError<Self::EngineError>>
fn retrieve_cleartext(
&mut self,
cleartext: &Cleartext32
) -> Result<u32, CleartextRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u32 = 3;
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext32 = engine.create_cleartext(&input)?;
let output: u32 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3_u32);
engine.destroy(cleartext)?;
Unsafely retrieves an arbitrary value from a cleartext. Read more
Description:
Implementation of CleartextRetrievalEngine
for CoreEngine
that operates on 64 bits
integers.
fn retrieve_cleartext(
&mut self,
cleartext: &Cleartext64
) -> Result<u64, CleartextRetrievalError<Self::EngineError>>
fn retrieve_cleartext(
&mut self,
cleartext: &Cleartext64
) -> Result<u64, CleartextRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u64 = 3;
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext64 = engine.create_cleartext(&input)?;
let output: u64 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3_u64);
engine.destroy(cleartext)?;
Unsafely retrieves an arbitrary value from a cleartext. Read more
Description:
Implementation of CleartextVectorCreationEngine
for CoreEngine
that operates on 32 bits
integers.
fn create_cleartext_vector(
&mut self,
input: &[u32]
) -> Result<CleartextVector32, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector(
&mut self,
input: &[u32]
) -> Result<CleartextVector32, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u32; 100];
let mut engine = CoreEngine::new()?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
engine.destroy(cleartext_vector)?;
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
Description:
Implementation of CleartextVectorCreationEngine
for CoreEngine
that operates on 64 bits
integers.
fn create_cleartext_vector(
&mut self,
input: &[u64]
) -> Result<CleartextVector64, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector(
&mut self,
input: &[u64]
) -> Result<CleartextVector64, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u64; 100];
let mut engine = CoreEngine::new()?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
engine.destroy(cleartext_vector)?;
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
Description:
Implementation of CleartextVectorDiscardingRetrievalEngine
for CoreEngine
that operates
on 32 bits integers.
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u32],
input: &CleartextVector32
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u32],
input: &CleartextVector32
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u32; 100];
let mut retrieved = vec![0_u32; 100];
let mut engine = CoreEngine::new()?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3_u32);
engine.destroy(cleartext_vector)?;
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &CleartextVector32
)
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &CleartextVector32
)
Unsafely retrieves arbitrary values from a cleartext vector. Read more
Description:
Implementation of CleartextVectorDiscardingRetrievalEngine
for CoreEngine
that operates
on 32 bits integers.
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u64],
input: &CleartextVector64
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u64],
input: &CleartextVector64
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u64; 100];
let mut retrieved = vec![0_u64; 100];
let mut engine = CoreEngine::new()?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3_u64);
engine.destroy(cleartext_vector)?;
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &CleartextVector64
)
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &CleartextVector64
)
Unsafely retrieves arbitrary values from a cleartext vector. Read more
Description:
Implementation of CleartextVectorRetrievalEngine
for CoreEngine
that operates on 64 bits
integers.
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector32
) -> Result<Vec<u32>, CleartextVectorRetrievalError<Self::EngineError>>
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector32
) -> Result<Vec<u32>, CleartextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u32; 100];
let mut engine = CoreEngine::new()?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector(&input)?;
let retrieved: Vec<u32> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3_u32);
engine.destroy(cleartext_vector)?;
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector32
) -> Vec<u32>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector32
) -> Vec<u32>
Unsafely retrieves arbitrary values from a cleartext vector. Read more
Description:
Implementation of CleartextVectorRetrievalEngine
for CoreEngine
that operates on 32 bits
integers.
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector64
) -> Result<Vec<u64>, CleartextVectorRetrievalError<Self::EngineError>>
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector64
) -> Result<Vec<u64>, CleartextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u64; 100];
let mut engine = CoreEngine::new()?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector(&input)?;
let retrieved: Vec<u64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3_u64);
engine.destroy(cleartext_vector)?;
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector64
) -> Vec<u64>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector64
) -> Vec<u64>
Unsafely retrieves arbitrary values from a cleartext vector. Read more
fn destroy(
&mut self,
entity: Cleartext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Cleartext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: Cleartext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Cleartext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: CleartextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: CleartextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: CleartextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: CleartextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: FourierLweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: FourierLweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: FourierLweBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: FourierLweBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: GlweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: GlweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: GlweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: GlweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: GlweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: GlweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. 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
fn destroy(
&mut self,
entity: LweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: LweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: Plaintext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Plaintext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: Plaintext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Plaintext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: PlaintextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: PlaintextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
fn destroy(
&mut self,
entity: PlaintextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: PlaintextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
Description:
Implementation of GlweCiphertextDecryptionEngine
for CoreEngine
that operates on 32 bits
integers.
fn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> Result<PlaintextVector32, GlweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> Result<PlaintextVector32, GlweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext_vector)?;
unsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> PlaintextVector32
unsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> PlaintextVector32
Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more
Description:
Implementation of GlweCiphertextDecryptionEngine
for CoreEngine
that operates on 64 bits
integers.
fn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> Result<PlaintextVector64, GlweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> Result<PlaintextVector64, GlweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
// 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 key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext_vector)?;
unsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> PlaintextVector64
unsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> PlaintextVector64
Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more
Description:
Implementation of GlweCiphertextDiscardingDecryptionEngine
for CoreEngine
that operates
on 32 bits integers.
fn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let mut input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext(&key, &mut plaintext_vector, &ciphertext)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(4));
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
unsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
)
unsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
)
Unsafely decrypts a GLWE ciphertext . Read more
Description:
Implementation of GlweCiphertextDiscardingDecryptionEngine
for CoreEngine
that operates
on 64 bits integers.
fn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, 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);
// Here a hard-set encoding is applied (shift by 50 bits)
let mut input = vec![3_u64 << 50; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext(&key, &mut plaintext_vector, &ciphertext)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(4));
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
unsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
)
unsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
)
Unsafely decrypts a GLWE ciphertext . Read more
Description:
Implementation of GlweCiphertextDiscardingEncryptionEngine
for CoreEngine
that operates
on 32 bits integers.
fn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 4];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key_1: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext = engine.encrypt_glwe_ciphertext(&key_1, &plaintext_vector, noise)?;
// We're going to re-encrypt the input with another secret key
// For this, it is required that the second secret key uses the same GLWE dimension
// and polynomial size as the first one.
let key_2: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
engine.discard_encrypt_glwe_ciphertext(&key_2, &mut ciphertext, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
unsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext . Read more
Description:
Implementation of GlweCiphertextDiscardingEncryptionEngine
for CoreEngine
that operates
on 64 bits integers.
fn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 4];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key_1: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext = engine.encrypt_glwe_ciphertext(&key_1, &plaintext_vector, noise)?;
// We're going to re-encrypt the input with another secret key
// For this, it is required that the second secret key uses the same GLWE dimension
// and polynomial size as the first one.
let key_2: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
engine.discard_encrypt_glwe_ciphertext(&key_2, &mut ciphertext, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
unsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext . Read more
Description:
Implementation of GlweCiphertextEncryptionEngine
for CoreEngine
that operates on 32 bits
integers.
fn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
unsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertext32
unsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertext32
Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
Description:
Implementation of GlweCiphertextEncryptionEngine
for CoreEngine
that operates on 64 bits
integers.
fn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// 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 key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
unsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertext64
unsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertext64
Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
fn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> Result<GlweCiphertext32, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> Result<GlweCiphertext32, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
let input = vec![3_u32 << 20; polynomial_size.0];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext: GlweCiphertext32 = engine
.trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
unsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> GlweCiphertext32
unsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> GlweCiphertext32
Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
fn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> Result<GlweCiphertext64, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> Result<GlweCiphertext64, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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);
let input = vec![3_u64 << 20; polynomial_size.0];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let ciphertext: GlweCiphertext64 = engine
.trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
unsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> GlweCiphertext64
unsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> GlweCiphertext64
Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
Description:
Implementation of GlweCiphertextVectorDecryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> Result<PlaintextVector32, GlweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> Result<PlaintextVector32, GlweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_glwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
engine.destroy(key)?;
unsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> PlaintextVector32
unsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> PlaintextVector32
Unsafely decrypts a GLWE ciphertext vector. Read more
Description:
Implementation of GlweCiphertextVectorDecryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> Result<PlaintextVector64, GlweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> Result<PlaintextVector64, GlweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, 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);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_glwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
engine.destroy(key)?;
unsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> PlaintextVector64
unsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> PlaintextVector64
Unsafely decrypts a GLWE ciphertext vector. Read more
Description:
Implementation of GlweCiphertextVectorDiscardingDecryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(8));
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
)
unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
)
Unsafely encrypts a GLWE ciphertext vector . Read more
Description:
Implementation of GlweCiphertextVectorDiscardingDecryptionEngine
for CoreEngine
that
operates on 64 bits integers.
fn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, 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);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(8));
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
)
unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
)
Unsafely encrypts a GLWE ciphertext vector . Read more
Description:
Implementation of GlweCiphertextVectorDiscardingEncryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key_1: GlweSecretKey32 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey32 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key_1, &plaintext_vector, noise)?;
engine.discard_encrypt_glwe_ciphertext_vector(
&key_2,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext vector . Read more
Description:
Implementation of GlweCiphertextVectorDiscardingEncryptionEngine
for CoreEngine
that
operates on 64 bits integers.
fn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key_1: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key_1, &plaintext_vector, noise)?;
engine.discard_encrypt_glwe_ciphertext_vector(
&key_2,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext vector . Read more
Description:
Implementation of GlweCiphertextVectorEncryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
unsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertextVector32
unsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertextVector32
Unsafely encrypts a GLWE ciphertext vector. Read more
Description:
Implementation of GlweCiphertextVectorEncryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, 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);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 8];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
unsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertextVector64
unsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertextVector64
Unsafely encrypts a GLWE ciphertext vector. Read more
Description:
Implementation of GlweCiphertextVectorZeroEncryptionEngine
for CoreEngine
that operates
on 32 bits integers.
fn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, 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(1024);
let ciphertext_count = GlweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext_vector =
engine.zero_encrypt_glwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(key)?;
unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector32
unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector32
Unsafely encrypts zero in a GLWE ciphertext vector. Read more
Description:
Implementation of GlweCiphertextVectorZeroEncryptionEngine
for CoreEngine
that operates
on 64 bits integers.
fn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, 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(1024);
let ciphertext_count = GlweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext_vector =
engine.zero_encrypt_glwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(key)?;
unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector64
unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector64
Unsafely encrypts zero in a GLWE ciphertext vector. Read more
Description:
Implementation of GlweCiphertextZeroEncryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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(1024);
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext = engine.zero_encrypt_glwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
unsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> GlweCiphertext32
unsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> GlweCiphertext32
Unsafely encrypts a zero in a GLWE ciphertext. Read more
Description:
Implementation of GlweCiphertextZeroEncryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, 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(1024);
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext = engine.zero_encrypt_glwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
unsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> GlweCiphertext64
unsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> GlweCiphertext64
Unsafely encrypts a zero in a GLWE ciphertext. Read more
Description:
Implementation of GlweSecretKeyCreationEngine
for CoreEngine
that operates on
32 bits integers.
fn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, GlweSecretKeyCreationError<Self::EngineError>>
fn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, GlweSecretKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweDimension, 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);
let mut engine = CoreEngine::new()?;
let glwe_secret_key: GlweSecretKey32 =
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);
engine.destroy(glwe_secret_key)?;
unsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
unsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
Unsafely creates a new GLWE secret key. Read more
Description:
Implementation of GlweSecretKeyCreationEngine
for CoreEngine
that operates on
64 bits integers.
fn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, GlweSecretKeyCreationError<Self::EngineError>>
fn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, GlweSecretKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweDimension, 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);
let mut engine = CoreEngine::new()?;
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);
engine.destroy(glwe_secret_key)?;
unsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
unsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
Unsafely creates a new GLWE secret key. Read more
fn transmute_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> Result<LweSecretKey32, GlweToLweSecretKeyTransmutationEngineError<Self::EngineError>>
fn transmute_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> Result<LweSecretKey32, GlweToLweSecretKeyTransmutationEngineError<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);
let mut engine = CoreEngine::new()?;
let glwe_secret_key: GlweSecretKey32 =
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.transmute_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
unsafe fn transmute_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> LweSecretKey32
unsafe fn transmute_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> LweSecretKey32
Unsafely transmutes a GLWE secret key into a lwe secret key Read more
fn transmute_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransmutationEngineError<Self::EngineError>>
fn transmute_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransmutationEngineError<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);
let mut engine = CoreEngine::new()?;
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.transmute_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
unsafe fn transmute_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> LweSecretKey64
unsafe fn transmute_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> LweSecretKey64
Unsafely transmutes a GLWE secret key into a lwe secret key Read more
impl<Key> LweBootstrapKeyConversionEngine<Key, Key> for CoreEngine where
Key: LweBootstrapKeyEntity + Clone,
impl<Key> LweBootstrapKeyConversionEngine<Key, Key> for CoreEngine where
Key: LweBootstrapKeyEntity + Clone,
fn convert_lwe_bootstrap_key(
&mut self,
input: &Key
) -> Result<Key, LweBootstrapKeyConversionError<Self::EngineError>>
fn convert_lwe_bootstrap_key(
&mut self,
input: &Key
) -> Result<Key, LweBootstrapKeyConversionError<Self::EngineError>>
Converts an LWE bootstrap key.
Unsafely converts an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyConversionEngine
for CoreEngine
that operates on
32 bits integers. It converts a bootstrap key from the standard to the Fourier domain.
fn convert_lwe_bootstrap_key(
&mut self,
input: &LweBootstrapKey32
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyConversionError<Self::EngineError>>
fn convert_lwe_bootstrap_key(
&mut self,
input: &LweBootstrapKey32
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyConversionError<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.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FourierLweBootstrapKey32 = engine.convert_lwe_bootstrap_key(&bsk)?;
assert_eq!(fourier_bsk.glwe_dimension(), glwe_dim);
assert_eq!(fourier_bsk.polynomial_size(), poly_size);
assert_eq!(fourier_bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(fourier_bsk.decomposition_base_log(), dec_bl);
assert_eq!(fourier_bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
engine.destroy(fourier_bsk)?;
unsafe fn convert_lwe_bootstrap_key_unchecked(
&mut self,
input: &LweBootstrapKey32
) -> FourierLweBootstrapKey32
unsafe fn convert_lwe_bootstrap_key_unchecked(
&mut self,
input: &LweBootstrapKey32
) -> FourierLweBootstrapKey32
Unsafely converts an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyConversionEngine
for CoreEngine
that operates on
64 bits integers. It converts a bootstrap key from the standard to the Fourier domain.
fn convert_lwe_bootstrap_key(
&mut self,
input: &LweBootstrapKey64
) -> Result<FourierLweBootstrapKey64, LweBootstrapKeyConversionError<Self::EngineError>>
fn convert_lwe_bootstrap_key(
&mut self,
input: &LweBootstrapKey64
) -> Result<FourierLweBootstrapKey64, LweBootstrapKeyConversionError<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.));
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: LweBootstrapKey64 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FourierLweBootstrapKey64 = engine.convert_lwe_bootstrap_key(&bsk)?;
assert_eq!(fourier_bsk.glwe_dimension(), glwe_dim);
assert_eq!(fourier_bsk.polynomial_size(), poly_size);
assert_eq!(fourier_bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(fourier_bsk.decomposition_base_log(), dec_bl);
assert_eq!(fourier_bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
engine.destroy(fourier_bsk)?;
unsafe fn convert_lwe_bootstrap_key_unchecked(
&mut self,
input: &LweBootstrapKey64
) -> FourierLweBootstrapKey64
unsafe fn convert_lwe_bootstrap_key_unchecked(
&mut self,
input: &LweBootstrapKey64
) -> FourierLweBootstrapKey64
Unsafely converts an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyCreationEngine
for CoreEngine
that operates on
32 bits integers. It outputs a bootstrap key in the Fourier domain.
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<FourierLweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<FourierLweBootstrapKey32, 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.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: FourierLweBootstrapKey32 =
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)?;
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> FourierLweBootstrapKey32
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> FourierLweBootstrapKey32
Unsafely creates an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyCreationEngine
for CoreEngine
that operates on
32 bits integers. It outputs a bootstrap key in the standard domain.
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, 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.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
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)?;
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
Unsafely creates an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyCreationEngine
for CoreEngine
that operates on
64 bits integers. It outputs a bootstrap key in the Fourier domain.
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<FourierLweBootstrapKey64, 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<FourierLweBootstrapKey64, 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.));
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)?;
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);
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
) -> FourierLweBootstrapKey64
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
) -> FourierLweBootstrapKey64
Unsafely creates an LWE bootstrap key. Read more
Description:
Implementation of LweBootstrapKeyCreationEngine
for CoreEngine
that operates on
64 bits integers. It outputs a bootstrap key in the standard domain.
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>>
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.));
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: 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)?;
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
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
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for CoreEngine
that operates on 32 bits integers.
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
) -> 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 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext32 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
)
Unsafely multiply an LWE ciphertext with a cleartext. 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 32 bits integers.
fn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
fn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
) -> 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 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let cleartext: Cleartext32 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input: &Cleartext32
)
unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
)
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
32 bits integers.
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Result<Plaintext32, 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_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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: &LweSecretKey32,
input: &LweCiphertext32
) -> Plaintext32
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Plaintext32
Unsafely decrypts an LWE ciphertext. 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
32 bits integers.
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
) -> 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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
)
Unsafely adds two LWE ciphertexts. 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
32 bits integers.
fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
) -> Result<(), LweCiphertextDiscardingBootstrapError<Self::EngineError>>
fn discard_bootstrap_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
) -> 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 20 bits)
let input = 3_u32 << 20;
// 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_u32 << 20; poly_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let lwe_sk: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: FourierLweBootstrapKey32 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let lwe_sk_output: LweSecretKey32 = 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.zero_encrypt_lwe_ciphertext(&lwe_sk_output, 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 LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
)
unsafe fn discard_bootstrap_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
acc: &GlweCiphertext32,
bsk: &FourierLweBootstrapKey32
)
Unsafely bootstrap an LWE ciphertext . 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 32 bits integers.
fn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
) -> 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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
)
unsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
)
Unsafely decrypts 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 32 bits integers.
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
)
Unsafely encrypts 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 32 bits integers.
fn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
fn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
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 20 bits)
let input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let glwe_key: GlweSecretKey32 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey32 = 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 LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
)
unsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
)
Unsafely extracts an LWE ciphertext from a GLWE 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
32 bits integers.
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
) -> 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 20 bits)
let input = 3_u32 << 20;
let mut engine = CoreEngine::new()?;
let input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = 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 LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
)
Unsafely keyswitch an LWE 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
32 bits integers.
fn discard_neg_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingNegationError<Self::EngineError>>
fn discard_neg_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> 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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input: &LweCiphertext32
)
unsafe fn discard_neg_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
Unsafely negates 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
32 bits integers.
fn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> Result<LweCiphertext32, LweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> Result<LweCiphertext32, 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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> LweCiphertext32
unsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> LweCiphertext32
Unsafely encrypts 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
Description:
Implementation of LweCiphertextFusingAdditionEngine
for CoreEngine
that operates on
32 bits integers.
fn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> 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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input: &LweCiphertext32
)
unsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
Unsafely add an LWE ciphertext to an other. Read more
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
32 bits integers.
fn fuse_neg_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext32
) -> Result<(), LweCiphertextFusingNegationError<Self::EngineError>>
fn fuse_neg_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext32
) -> 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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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 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 32 bits integers.
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
) -> 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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
)
Unsafely adds a plaintext to 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 32 bits integers.
fn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> 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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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 LweCiphertext32,
input: &Plaintext32
)
unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
)
Unsafely add 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: &Plaintext32
) -> Result<LweCiphertext32, LweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext32
) -> Result<LweCiphertext32, LweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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_u32 << 20;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext32 = engine.create_plaintext(&input)?;
let ciphertext: LweCiphertext32 =
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: &Plaintext32
) -> LweCiphertext32
unsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext32
) -> LweCiphertext32
Unsafely creates the trivial LWE encryption of the plaintext. 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 LweCiphertextVectorDecryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_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 20 bits)
let input = vec![3_u32 << 20; 18];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(18)
);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> PlaintextVector32
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> PlaintextVector32
Unsafely decrypts an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorDecryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn 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.));
let mut engine = CoreEngine::new()?;
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)?;
unsafe 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
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for CoreEngine
that operates on 32 bits integers.
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
Example:
use concrete_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_u32 << 20; 8];
let weights_input = vec![2_u32; 8];
let bias_input = 8_u32 << 20;
let noise = Variance::from_variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector32 = engine.create_cleartext_vector(&input_vector)?;
let bias: Plaintext32 = engine.create_plaintext(&bias_input)?;
let plaintext_vector: PlaintextVector32 = 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 LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
)
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
)
Unsafely performs the affine transform of an LWE ciphertext vector. 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 LweCiphertextVectorDiscardingDecryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_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 20 bits)
let input = vec![3_u32 << 20; 18];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_lwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
)
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
)
Unsafely decrypts an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine
for CoreEngine
that
operates on 64 bits integers.
fn 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.));
let mut engine = CoreEngine::new()?;
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)?;
unsafe 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
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_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 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;
engine.discard_encrypt_lwe_ciphertext_vector(
&key,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encryprs an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for CoreEngine
that
operates on 64 bits integers.
fn 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.));
let mut engine = CoreEngine::new()?;
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)?;
unsafe 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
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_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 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweCiphertextVector32
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweCiphertextVector32
Unsafely encrypts an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for CoreEngine
that operates on
64 bits integers.
fn 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.));
let mut engine = CoreEngine::new()?;
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)?;
unsafe 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
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 = vec![3_u32 << 20; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
assert_eq!(ciphertext_vector.lwe_dimension().to_lwe_size(), lwe_size);
assert_eq!(
ciphertext_vector.lwe_ciphertext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> LweCiphertextVector32
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> LweCiphertextVector32
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
fn 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_commons::dispersion::Variance;
use concrete_commons::parameters::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 = vec![3_u64 << 20; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
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
);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe 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
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_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.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = 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)?;
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
Unsafely encrypts zeros in an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for CoreEngine
that
operates on 64 bits integers.
fn 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.));
let mut engine = CoreEngine::new()?;
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)?;
unsafe 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
Description:
Implementation of LweCiphertextZeroEncryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> Result<LweCiphertext32, LweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> Result<LweCiphertext32, 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: LweSecretKey32 = 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: &LweSecretKey32,
noise: Variance
) -> LweCiphertext32
unsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> LweCiphertext32
Safely encrypts zero into an LWE ciphertext. 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
Description:
Implementation of LweKeyswitchKeyCreationEngine
for CoreEngine
that
operates on 32 bits integers.
fn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, 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.));
let mut engine = CoreEngine::new()?;
let input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = 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)?;
unsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
unsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
Unsafely creates an LWE keyswitch key. Read more
Description:
Implementation of LweKeyswitchKeyCreationEngine
for CoreEngine
that
operates on 64 bits integers.
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>>
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.));
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,
)?;
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)?;
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
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
Description:
Implementation of LweSecretKeyCreationEngine
for CoreEngine
that operates on
32 bits integers.
fn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey32, LweSecretKeyCreationError<Self::EngineError>>
fn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey32, 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);
let mut engine = CoreEngine::new()?;
let lwe_secret_key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
engine.destroy(lwe_secret_key)?;
unsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey32
unsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey32
Unsafely creates an LWE secret key. Read more
Description:
Implementation of LweSecretKeyCreationEngine
for CoreEngine
that operates on
64 bits integers.
fn 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);
let mut engine = CoreEngine::new()?;
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)?;
unsafe 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
Description:
Implementation of PlaintextCreationEngine
for CoreEngine
that operates on
32 bits integers.
fn create_plaintext(
&mut self,
input: &u32
) -> Result<Plaintext32, PlaintextCreationError<Self::EngineError>>
fn create_plaintext(
&mut self,
input: &u32
) -> Result<Plaintext32, PlaintextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext32 = engine.create_plaintext(&input)?;
engine.destroy(plaintext)?;
Unsafely creates a plaintext from an arbitrary value. Read more
Description:
Implementation of PlaintextCreationEngine
for CoreEngine
that operates on
64 bits integers.
fn create_plaintext(
&mut self,
input: &u64
) -> Result<Plaintext64, PlaintextCreationError<Self::EngineError>>
fn create_plaintext(
&mut self,
input: &u64
) -> Result<Plaintext64, PlaintextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext64 = engine.create_plaintext(&input)?;
engine.destroy(plaintext)?;
Unsafely creates a plaintext from an arbitrary value. Read more
Description:
Implementation of PlaintextDiscardingRetrievalEngine
for CoreEngine
that operates on 32
bits integers.
fn discard_retrieve_plaintext(
&mut self,
output: &mut u32,
input: &Plaintext32
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext(
&mut self,
output: &mut u32,
input: &Plaintext32
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let mut output = 0_u32;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext32 = engine.create_plaintext(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;
assert_eq!(output, 3_u32 << 20);
engine.destroy(plaintext)?;
unsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u32,
input: &Plaintext32
)
unsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u32,
input: &Plaintext32
)
Unsafely retrieves an arbitrary value from a plaintext inplace. Read more
fn discard_retrieve_plaintext(
&mut self,
output: &mut u64,
input: &Plaintext64
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext(
&mut self,
output: &mut u64,
input: &Plaintext64
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u64 << 20;
let mut output = 0_u64;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext64 = engine.create_plaintext(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;
assert_eq!(output, 3_u64 << 20);
engine.destroy(plaintext)?;
unsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u64,
input: &Plaintext64
)
unsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u64,
input: &Plaintext64
)
Unsafely retrieves an arbitrary value from a plaintext inplace. Read more
Description:
Implementation of PlaintextRetrievalEngine
for CoreEngine
that operates on 64 bits
integers.
fn retrieve_plaintext(
&mut self,
plaintext: &Plaintext32
) -> Result<u32, PlaintextRetrievalError<Self::EngineError>>
fn retrieve_plaintext(
&mut self,
plaintext: &Plaintext32
) -> Result<u32, PlaintextRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext32 = engine.create_plaintext(&input)?;
let output: u32 = engine.retrieve_plaintext(&plaintext)?;
assert_eq!(output, 3_u32 << 20);
engine.destroy(plaintext)?;
Unsafely retrieves an arbitrary value from a plaintext. Read more
Description:
Implementation of PlaintextRetrievalEngine
for CoreEngine
that operates on 64 bits
integers.
fn retrieve_plaintext(
&mut self,
plaintext: &Plaintext64
) -> Result<u64, PlaintextRetrievalError<Self::EngineError>>
fn retrieve_plaintext(
&mut self,
plaintext: &Plaintext64
) -> Result<u64, PlaintextRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u64 << 20;
let mut engine = CoreEngine::new()?;
let plaintext: Plaintext64 = engine.create_plaintext(&input)?;
let output: u64 = engine.retrieve_plaintext(&plaintext)?;
assert_eq!(output, 3_u64 << 20);
engine.destroy(plaintext)?;
Unsafely retrieves an arbitrary value from a plaintext. Read more
Description:
Implementation of PlaintextVectorCreationEngine
for CoreEngine
that operates on
32 bits integers.
fn create_plaintext_vector(
&mut self,
input: &[u32]
) -> Result<PlaintextVector32, PlaintextVectorCreationError<Self::EngineError>>
fn create_plaintext_vector(
&mut self,
input: &[u32]
) -> Result<PlaintextVector32, PlaintextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
engine.destroy(plaintext_vector)?;
Unsafely creates a plaintext vector from a slice of arbitrary values. Read more
Description:
Implementation of PlaintextVectorCreationEngine
for CoreEngine
that operates on
64 bits integers.
fn create_plaintext_vector(
&mut self,
input: &[u64]
) -> Result<PlaintextVector64, PlaintextVectorCreationError<Self::EngineError>>
fn create_plaintext_vector(
&mut self,
input: &[u64]
) -> Result<PlaintextVector64, PlaintextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
engine.destroy(plaintext_vector)?;
Unsafely creates a plaintext vector from a slice of arbitrary values. Read more
Description:
Implementation of PlaintextVectorDiscardingRetrievalEngine
for CoreEngine
that operates
on 32 bits integers.
fn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let mut output = vec![0_u32; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
engine.destroy(plaintext_vector)?;
unsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
)
unsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
)
Unsafely retrieves arbitrary values from a plaintext vector. Read more
Description:
Implementation of PlaintextVectorDiscardingRetrievalEngine
for CoreEngine
that operates
on 64 bits integers.
fn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u64 << 20; 3];
let mut output = vec![0_u64; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
engine.destroy(plaintext_vector)?;
unsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
)
unsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
)
Unsafely retrieves arbitrary values from a plaintext vector. Read more
Description:
Implementation of PlaintextVectorRetrievalEngine
for CoreEngine
that operates on 32 bits
integers.
fn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector32
) -> Result<Vec<u32>, PlaintextVectorRetrievalError<Self::EngineError>>
fn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector32
) -> Result<Vec<u32>, PlaintextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let output: Vec<u32> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
engine.destroy(plaintext_vector)?;
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector32
) -> Vec<u32>
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector32
) -> Vec<u32>
Unsafely retrieves arbitrary values from a plaintext vector. Read more
Description:
Implementation of PlaintextVectorRetrievalEngine
for CoreEngine
that operates on 64 bits
integers.
fn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector64
) -> Result<Vec<u64>, PlaintextVectorRetrievalError<Self::EngineError>>
fn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector64
) -> Result<Vec<u64>, PlaintextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u64 << 20; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let output: Vec<u64> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
engine.destroy(plaintext_vector)?;
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector64
) -> Vec<u64>
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector64
) -> Vec<u64>
Unsafely retrieves arbitrary values from a plaintext vector. Read more