pub struct CoreEngine { /* private fields */ }
Expand description

The main engine exposed by the core backend.

Trait Implementations

The error associated to the engine.

A constructor for the engine.

Description:

Implementation of CleartextCreationEngine for CoreEngine that operates on 32 bits integers.

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.

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.

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)?;

Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextDiscardingRetrievalEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextRetrievalEngine for CoreEngine that operates on 32 bits integers.

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.

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.

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.

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.

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)?;

Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of CleartextVectorDiscardingRetrievalEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of CleartextVectorRetrievalEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of CleartextVectorRetrievalEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely retrieves arbitrary values from a cleartext vector. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

Description:

Implementation of GlweCiphertextDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more

Description:

Implementation of GlweCiphertextDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more

Description:

Implementation of GlweCiphertextDiscardingDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts a GLWE ciphertext . Read more

Description:

Implementation of GlweCiphertextDiscardingDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts a GLWE ciphertext . Read more

Description:

Implementation of GlweCiphertextDiscardingEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext . Read more

Description:

Implementation of GlweCiphertextDiscardingEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext . Read more

Description:

Implementation of GlweCiphertextEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more

Description:

Implementation of GlweCiphertextEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more

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)?;

Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more

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)?;

Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more

Description:

Implementation of GlweCiphertextVectorDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts a GLWE ciphertext vector. Read more

Description:

Implementation of GlweCiphertextVectorDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts a GLWE ciphertext vector. Read more

Description:

Implementation of GlweCiphertextVectorDiscardingDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

Implementation of GlweCiphertextVectorDiscardingDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

Implementation of GlweCiphertextVectorDiscardingEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

Implementation of GlweCiphertextVectorDiscardingEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

Implementation of GlweCiphertextVectorEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext vector. Read more

Description:

Implementation of GlweCiphertextVectorEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts a GLWE ciphertext vector. Read more

Description:

Implementation of GlweCiphertextVectorZeroEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts zero in a GLWE ciphertext vector. Read more

Description:

Implementation of GlweCiphertextVectorZeroEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts zero in a GLWE ciphertext vector. Read more

Description:

Implementation of GlweCiphertextZeroEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts a zero in a GLWE ciphertext. Read more

Description:

Implementation of GlweCiphertextZeroEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts a zero in a GLWE ciphertext. Read more

Description:

Implementation of GlweSecretKeyCreationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely creates a new GLWE secret key. Read more

Description:

Implementation of GlweSecretKeyCreationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely creates a new GLWE secret key. Read more

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));

Unsafely transmutes a GLWE secret key into a lwe secret key Read more

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));

Unsafely transmutes a GLWE secret key into a lwe secret key Read more

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.

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)?;

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.

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)?;

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.

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)?;

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.

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)?;

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.

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);

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.

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)?;

Unsafely creates an LWE bootstrap key. Read more

Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextCleartextFusingMultiplicationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextCleartextFusingMultiplicationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingAdditionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely adds two LWE ciphertexts. Read more

Description:

Implementation of LweCiphertextDiscardingAdditionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely adds two LWE ciphertexts. Read more

Description:

Implementation of LweCiphertextDiscardingBootstrapEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely bootstrap an LWE ciphertext . Read more

Description:

Implementation of LweCiphertextDiscardingBootstrapEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely bootstrap an LWE ciphertext . Read more

Description:

Implementation of LweCiphertextDiscardingDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingExtractionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingExtractionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely keyswitch an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely keyswitch an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingNegationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely negates an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingNegationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely negates an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextFusingAdditionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely add an LWE ciphertext to an other. Read more

Description:

Implementation of LweCiphertextFusingAdditionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely add an LWE ciphertext to an other. Read more

Description:

Implementation of LweCiphertextFusingNegationEngine for CoreEngine that operates on 32 bits integers.

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.

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.

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)?;

Unsafely adds a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely adds a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextFusingAdditionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely add a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextFusingAdditionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely add a plaintext to an LWE ciphertext. Read more

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)?;

Unsafely creates the trivial LWE encryption of the plaintext. Read more

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)?;

Unsafely creates the trivial LWE encryption of the plaintext. Read more

Description:

Implementation of LweCiphertextVectorDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely performs the affine transform of an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely performs the affine transform of an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingDecryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingDecryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely decrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encryprs an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encryprs an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts an LWE ciphertext vector. Read more

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)?;

Unsafely creates the trivial LWE encryption of the plaintext vector. Read more

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)?;

Unsafely creates the trivial LWE encryption of the plaintext vector. Read more

Description:

Implementation of LweCiphertextVectorZeroEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely encrypts zeros in an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorZeroEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely encrypts zeros in an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextZeroEncryptionEngine for CoreEngine that operates on 32 bits integers.

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)?;

Safely encrypts zero into an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextZeroEncryptionEngine for CoreEngine that operates on 64 bits integers.

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)?;

Safely encrypts zero into an LWE ciphertext. Read more

Description:

Implementation of LweKeyswitchKeyCreationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely creates an LWE keyswitch key. Read more

Description:

Implementation of LweKeyswitchKeyCreationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely creates an LWE keyswitch key. Read more

Description:

Implementation of LweSecretKeyCreationEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely creates an LWE secret key. Read more

Description:

Implementation of LweSecretKeyCreationEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely creates an LWE secret key. Read more

Description:

Implementation of PlaintextCreationEngine for CoreEngine that operates on 32 bits integers.

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.

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.

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)?;

Unsafely retrieves an arbitrary value from a plaintext inplace. Read more

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)?;

Unsafely retrieves an arbitrary value from a plaintext inplace. Read more

Description:

Implementation of PlaintextRetrievalEngine for CoreEngine that operates on 64 bits integers.

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.

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.

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.

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.

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)?;

Unsafely retrieves arbitrary values from a plaintext vector. Read more

Description:

Implementation of PlaintextVectorDiscardingRetrievalEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely retrieves arbitrary values from a plaintext vector. Read more

Description:

Implementation of PlaintextVectorRetrievalEngine for CoreEngine that operates on 32 bits integers.

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)?;

Unsafely retrieves arbitrary values from a plaintext vector. Read more

Description:

Implementation of PlaintextVectorRetrievalEngine for CoreEngine that operates on 64 bits integers.

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)?;

Unsafely retrieves arbitrary values from a plaintext vector. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.