pub struct DefaultEngine { /* private fields */ }

Trait Implementations

The error associated to the engine.
The constructor parameters type.
A constructor for the engine.

Description:

Implementation of CleartextCreationEngine for DefaultEngine that operates on 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;

let input: f64 = 3.;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&input)?;
Unsafely creates a cleartext from an arbitrary value. Read more

Description:

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

Example:
use concrete_core::prelude::*;

let input: u32 = 3;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext32 = engine.create_cleartext_from(&input)?;
Unsafely creates a cleartext from an arbitrary value. Read more

Description:

Implementation of CleartextCreationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::*;

let input: u64 = 3;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&input)?;
Unsafely creates a cleartext from an arbitrary value. Read more

Description:

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

Example:
use concrete_core::prelude::*;

let input: u32 = 3;
let mut output: u32 = 0;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext32 = engine.create_cleartext_from(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;

assert_eq!(output, 3_u32);
Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

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

Example:
use concrete_core::prelude::*;

let input: u64 = 3;
let mut output: u64 = 0;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;

assert_eq!(output, 3_u64);
Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextDiscardingRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;

let input: f64 = 3.;
let mut output: f64 = 0.;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;

assert_eq!(output, 3.0);
Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 32 bits integers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder = engine.create_encoder_from(&FloatEncoderMinMaxConfig {
    min: 0.,
    max: 10.,
    nb_bit_precision: 8,
    nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext32 = engine.encode_cleartext(&encoder, &cleartext)?;
Unsafely encodes a cleartext into a plaintext. Read more

Description:

Implementation of CleartextEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 32 bits integers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder = engine.create_encoder_from(&FloatEncoderMinMaxConfig {
    min: 0.,
    max: 10.,
    nb_bit_precision: 8,
    nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext64 = engine.encode_cleartext(&encoder, &cleartext)?;
Unsafely encodes a cleartext into a plaintext. Read more

Description:

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

Example:
use concrete_core::prelude::*;

let input: u32 = 3;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext32 = engine.create_cleartext_from(&input)?;
let output: u32 = engine.retrieve_cleartext(&cleartext)?;

assert_eq!(output, 3_u32);
Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::*;

let input: u64 = 3;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&input)?;
let output: u64 = engine.retrieve_cleartext(&cleartext)?;

assert_eq!(output, 3_u64);
Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;

let input: f64 = 3.0;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&input)?;
let output: f64 = engine.retrieve_cleartext(&cleartext)?;

assert_eq!(output, 3.0);
Unsafely retrieves an arbitrary value from a cleartext. Read more

Description:

Implementation of CleartextVectorCreationEngine for DefaultEngine that operates on 64 bits floating point numbers.

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3.0_f64; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector_from(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more

Description:

Implementation of CleartextVectorCreationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3_u32; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector_from(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more

Description:

Implementation of CleartextVectorCreationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3_u64; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector_from(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more

Description:

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

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3_u32; 100];
let mut retrieved = vec![0_u32; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector_from(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;

assert_eq!(retrieved[0], 3_u32);
Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3_u64; 100];
let mut retrieved = vec![0_u64; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector_from(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;

assert_eq!(retrieved[0], 3_u64);
Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of CleartextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3.0_f64; 100];
let mut retrieved = vec![0.0_f64; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector_from(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;

assert_eq!(retrieved[0], 3.0_f64);
Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of CleartextVectorEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 32 bits integers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder_vector = engine.create_encoder_vector_from(&vec![
    FloatEncoderMinMaxConfig {
        min: 0.,
        max: 10.,
        nb_bit_precision: 8,
        nb_bit_padding: 1,
    };
    100
])?;
let cleartext_vector: CleartextVectorF64 =
    engine.create_cleartext_vector_from(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector32 =
    engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
assert_eq!(
    cleartext_vector.cleartext_count().0,
    plaintext_vector.plaintext_count().0
);
Unsafely encodes a cleartext vector into a plaintext vector. Read more

Description:

Implementation of CleartextVectorEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 64 bits integers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder_vector = engine.create_encoder_vector_from(&vec![
    FloatEncoderMinMaxConfig {
        min: 0.,
        max: 10.,
        nb_bit_precision: 8,
        nb_bit_padding: 1,
    };
    100
])?;
let cleartext_vector: CleartextVectorF64 =
    engine.create_cleartext_vector_from(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector64 =
    engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
assert_eq!(
    cleartext_vector.cleartext_count().0,
    plaintext_vector.plaintext_count().0
);
Unsafely encodes a cleartext vector into a plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3_u32; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector_from(&input)?;
let retrieved: Vec<u32> = engine.retrieve_cleartext_vector(&cleartext_vector)?;

assert_eq!(retrieved[0], 3_u32);
Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3_u64; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector_from(&input)?;
let retrieved: Vec<u64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;

assert_eq!(retrieved[0], 3_u64);
Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of CleartextVectorRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Example:
use concrete_core::prelude::{CleartextCount, *};

let input = vec![3.0_f64; 100];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector_from(&input)?;
let retrieved: Vec<f64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;

assert_eq!(retrieved[0], 3.0_f64);
Unsafely retrieves arbitrary values from a cleartext vector. Read more

Description:

Implementation of EncoderCreationEngine for DefaultEngine that creates an encoder to encode 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder = engine.create_encoder_from(&FloatEncoderCenterRadiusConfig {
    center: 10.,
    radius: 5.,
    nb_bit_precision: 8,
    nb_bit_padding: 1,
})?;
Unsafely creates an encoder from a config. Read more

Description:

Implementation of EncoderCreationEngine for DefaultEngine that creates an encoder to encode 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder = engine.create_encoder_from(&FloatEncoderMinMaxConfig {
    min: 0.,
    max: 10.,
    nb_bit_precision: 8,
    nb_bit_padding: 1,
})?;
Unsafely creates an encoder from a config. Read more

Description:

Implementation of EncoderVectorCreationEngine for DefaultEngine that creates an encoder vector to encode vectors of 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder_vector = engine.create_encoder_vector_from(&vec![
    FloatEncoderCenterRadiusConfig {
        center: 10.,
        radius: 5.,
        nb_bit_precision: 8,
        nb_bit_padding: 1,
    };
    1
])?;
Unsafely creates an encoder vector from a config. Read more

Description:

Implementation of EncoderVectorCreationEngine for DefaultEngine that creates an encoder vector to encode vectors of 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder_vector = engine.create_encoder_vector_from(
    vec![
        FloatEncoderMinMaxConfig {
            min: 0.,
            max: 10.,
            nb_bit_precision: 8,
            nb_bit_padding: 1,
        };
        1
    ]
    .as_slice(),
)?;
Unsafely creates an encoder vector from a config. Read more

Description:

Implementation of GgswCiphertextScalarDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};

// 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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext =
    engine.encrypt_scalar_ggsw_ciphertext(&key_1, &plaintext, noise, level, base_log)?;
// 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;

engine.discard_encrypt_scalar_ggsw_ciphertext(&key_2, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely encrypts a GGSW ciphertext. Read more

Description:

Implementation of GgswCiphertextScalarDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};

// 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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext =
    engine.encrypt_scalar_ggsw_ciphertext(&key_1, &plaintext, noise, level, base_log)?;
// 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;

engine.discard_encrypt_scalar_ggsw_ciphertext(&key_2, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely encrypts a GGSW ciphertext. Read more

Description:

Implementation of GgswCiphertextScalarEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};

// 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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext =
    engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely encrypts a plaintext vector into a GGSW ciphertext. Read more

Description:

Implementation of GgswCiphertextScalarEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};

// 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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext =
    engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely encrypts a plaintext vector into a GGSW ciphertext. Read more

Description:

Implementation of GgswCiphertextScalarTrivialEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:

use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};

// 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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
let input = 3_u32 << 20;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
let ciphertext: GgswCiphertext32 = engine.trivially_encrypt_scalar_ggsw_ciphertext(
    polynomial_size,
    glwe_dimension.to_glwe_size(),
    level,
    base_log,
    &plaintext,
)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
assert_eq!(ciphertext.decomposition_base_log(), base_log);
assert_eq!(ciphertext.decomposition_level_count(), level);
Unsafely creates the trivial GGSW encryption of the plaintext. Read more

Description:

Implementation of GgswCiphertextScalarTrivialEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:

use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};

// 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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
let input = 3_u64 << 20;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext64 = engine.create_plaintext_from(&input)?;
let ciphertext: GgswCiphertext64 = engine.trivially_encrypt_scalar_ggsw_ciphertext(
    polynomial_size,
    glwe_dimension.to_glwe_size(),
    level,
    base_log,
    &plaintext,
)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely creates the trivial GGSW encryption of the plaintext. Read more

Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a GlweCiphertext32 consuming it in the process

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: GlweCiphertext32 =
    engine.create_glwe_ciphertext_from(owned_container, polynomial_size)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a GlweCiphertext64 consuming it in the process

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: GlweCiphertext64 =
    engine.create_glwe_ciphertext_from(owned_container, polynomial_size)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextMutView32 consuming it in the process

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextMutView32 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextMutView64 consuming it in the process

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextMutView64 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextView32 consuming it in the process

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextView32 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextView64 consuming it in the process

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextView64 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextCreationEngine for DefaultEngine which returns an immutable GlweCiphertextView32 that does not own its memory.

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextView32 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more

Description:

Implementation of GlweCiphertextCreationEngine for DefaultEngine which returns an immutable GlweCiphertextView64 that does not own its memory.

Example:
use concrete_core::prelude::{PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = 600_usize;
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; (glwe_size + 1) * polynomial_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextView64 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more

Description:

Implementation of GlweCiphertextCreationEngine for DefaultEngine which returns a mutable GlweCiphertextMutView32 that does not own its memory.

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextMutView32 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more

Description:

Implementation of GlweCiphertextCreationEngine for DefaultEngine which returns a mutable GlweCiphertextMutView64 that does not own its memory.

Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextMutView64 =
    engine.create_glwe_ciphertext_from(slice, polynomial_size)?;
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Example:
use concrete_core::prelude::{GlweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: GlweCiphertext32 =
    engine.create_glwe_ciphertext_from(owned_container, polynomial_size)?;
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Example:
use concrete_core::prelude::{GlweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);

// You have to make sure you size the container properly
let owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: GlweCiphertext64 =
    engine.create_glwe_ciphertext_from(owned_container, polynomial_size)?;
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;

let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;

let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
Unsafely decrypts a GLWE ciphertext . Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
Unsafely decrypts a GLWE ciphertext . Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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.generate_new_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);
Unsafely encrypts a GLWE ciphertext . Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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.generate_new_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);
Unsafely encrypts a GLWE ciphertext . Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;

let ct_container = vec![0_u32; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertext32 =
    engine.create_glwe_ciphertext_from(ct_container, polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;

let mut ct_container = vec![0_u32; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertextMutView32 =
    engine.create_glwe_ciphertext_from(&mut ct_container[..], polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;

let ct_container = vec![0_u64; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertext64 =
    engine.create_glwe_ciphertext_from(ct_container, polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;

let mut ct_container = vec![0_u64; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertextMutView64 =
    engine.create_glwe_ciphertext_from(&mut ct_container[..], polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: GlweCiphertext32 = engine
    .trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
let output: PlaintextVector32 = engine.trivially_decrypt_glwe_ciphertext(&ciphertext)?;

assert_eq!(output.plaintext_count(), PlaintextCount(polynomial_size.0));
Unsafely trivially decrypts a GLWE ciphertext into a plaintext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: GlweCiphertext64 = engine
    .trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
let output: PlaintextVector64 = engine.trivially_decrypt_glwe_ciphertext(&ciphertext)?;

assert_eq!(output.plaintext_count(), PlaintextCount(polynomial_size.0));
Unsafely trivially decrypts a GLWE ciphertext into a plaintext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
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);
Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: 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);
Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more

Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVector32 consuming it in the process

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: GlweCiphertextVector32 = engine.create_glwe_ciphertext_vector_from(
    owned_container,
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVector64 consuming it in the process

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: GlweCiphertextVector64 = engine.create_glwe_ciphertext_vector_from(
    owned_container,
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVectorMutView32 consuming it in the process

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: GlweCiphertextVectorMutView32 = engine
    .create_glwe_ciphertext_vector_from(
        slice,
        glwe_size.to_glwe_dimension(),
        polynomial_size,
    )?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVectorMutView64 consuming it in the process

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: GlweCiphertextVectorMutView64 = engine
    .create_glwe_ciphertext_vector_from(
        slice,
        glwe_size.to_glwe_dimension(),
        polynomial_size,
    )?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVectorView32 consuming it in the process

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];
let original_vec_ptr = owned_container.as_ptr();

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: GlweCiphertextVector32 = engine.create_glwe_ciphertext_vector_from(
    slice.to_vec(),
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVectorView64 consuming it in the process

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];
let original_vec_ptr = owned_container.as_ptr();

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: GlweCiphertextVector64 = engine.create_glwe_ciphertext_vector_from(
    slice.to_vec(),
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of GlweCiphertextVectorCreationEngine for DefaultEngine which returns an immutable GlweCiphertextVectorView32 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextVectorView32 = engine.create_glwe_ciphertext_vector_from(
    slice,
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more

Description:

Implementation of GlweCiphertextVectorCreationEngine for DefaultEngine which returns an immutable GlweCiphertextVectorView64 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextVectorView64 = engine.create_glwe_ciphertext_vector_from(
    slice,
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more

Description:

Implementation of GlweCiphertextVectorCreationEngine for DefaultEngine which returns a mutable GlweCiphertextVectorMutView32 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextVectorMutView32 = engine
    .create_glwe_ciphertext_vector_from(
        slice,
        glwe_size.to_glwe_dimension(),
        polynomial_size,
    )?;
Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more

Description:

Implementation of GlweCiphertextVectorCreationEngine for DefaultEngine which returns a mutable GlweCiphertextVectorMutView64 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextVectorMutView64 = engine
    .create_glwe_ciphertext_vector_from(
        slice,
        glwe_size.to_glwe_dimension(),
        polynomial_size,
    )?;
Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextVector32 = engine.create_glwe_ciphertext_vector_from(
    slice.to_vec(),
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);

// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: GlweCiphertextVector64 = engine.create_glwe_ciphertext_vector_from(
    slice.to_vec(),
    glwe_size.to_glwe_dimension(),
    polynomial_size,
)?;
Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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!(
Unsafely decrypts a GLWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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!(
Unsafely decrypts a GLWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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!(
Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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!(
Unsafely encrypts a GLWE ciphertext vector . Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
Unsafely encrypts a GLWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
Unsafely encrypts a GLWE ciphertext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector32 = engine
    .trivially_encrypt_glwe_ciphertext_vector(
        glwe_dimension.to_glwe_size(),
        ciphertext_count,
        &plaintext_vector,
    )?;
let output: PlaintextVector32 =
    engine.trivially_decrypt_glwe_ciphertext_vector(&ciphertext_vector)?;

assert_eq!(output.plaintext_count(), PlaintextCount(8));
Unsafely trivially decrypts a GLWE ciphertext vector into a plaintext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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 << 50; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector64 = engine
    .trivially_encrypt_glwe_ciphertext_vector(
        glwe_dimension.to_glwe_size(),
        ciphertext_count,
        &plaintext_vector,
    )?;
let output: PlaintextVector64 =
    engine.trivially_decrypt_glwe_ciphertext_vector(&ciphertext_vector)?;

assert_eq!(output.plaintext_count(), PlaintextCount(8));
Unsafely trivially decrypts a GLWE ciphertext vector into a plaintext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector32 = engine
    .trivially_encrypt_glwe_ciphertext_vector(
        glwe_dimension.to_glwe_size(),
        ciphertext_count,
        &plaintext_vector,
    )?;

assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext vector. Read more
Example:

use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

// 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 << 50; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector64 = engine
    .trivially_encrypt_glwe_ciphertext_vector(
        glwe_dimension.to_glwe_size(),
        ciphertext_count,
        &plaintext_vector,
    )?;

assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweCiphertextCount, GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_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);
Unsafely encrypts zero in a GLWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweCiphertextCount, GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_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);
Unsafely encrypts zero in a GLWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_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);
Unsafely encrypts a zero in a GLWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_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);
Unsafely encrypts a zero in a GLWE ciphertext. Read more

Description:

Implementation of GlweSecretKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_secret_key: GlweSecretKey32 =
    engine.generate_new_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);
Unsafely generates a new GLWE secret key. Read more

Description:

Implementation of GlweSecretKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_secret_key: GlweSecretKey64 =
    engine.generate_new_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);
Unsafely generates a new GLWE secret key. Read more

Description:

Implementation of GlweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext =
    engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(seeded_ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(seeded_ciphertext.polynomial_size(), polynomial_size);
Unsafely encrypts a seeded GLWE ciphertext. Read more

Description:

Implementation of GlweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext =
    engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(seeded_ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(seeded_ciphertext.polynomial_size(), polynomial_size);
Unsafely encrypts a seeded GLWE ciphertext. Read more

Description:

Implementation of GlweSeededCiphertextToGlweCiphertextTransformationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext =
    engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;

let ciphertext =
    engine.transform_glwe_seeded_ciphertext_to_glwe_ciphertext(seeded_ciphertext)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely transforms a GLWE seeded ciphertext into a GLWE ciphertext Read more

Description:

Implementation of GlweSeededCiphertextToGlweCiphertextTransformationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext =
    engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;

let ciphertext =
    engine.transform_glwe_seeded_ciphertext_to_glwe_ciphertext(seeded_ciphertext)?;

assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
Unsafely transforms a GLWE seeded ciphertext into a GLWE ciphertext Read more

Description:

Implementation of GlweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext_vector =
    engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(seeded_ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(seeded_ciphertext_vector.glwe_dimension(), glwe_dimension);
Unsafely encrypts a GLWE seeded ciphertext vector. Read more

Description:

Implementation of GlweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext_vector =
    engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(seeded_ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(seeded_ciphertext_vector.glwe_dimension(), glwe_dimension);
Unsafely encrypts a GLWE seeded ciphertext vector. Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext_vector =
    engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;

let ciphertext_vector = engine.transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(seeded_ciphertext_vector)?;

assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
Unsafely transforms a GLWE seeded ciphertext vector into a GLWE ciphertext vector Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let seeded_ciphertext_vector =
    engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;

let ciphertext_vector = engine.transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(seeded_ciphertext_vector)?;

assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
Unsafely transforms a GLWE seeded ciphertext vector into a GLWE ciphertext vector Read more
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let glwe_secret_key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);

let lwe_secret_key = engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
Unsafely transforms a GLWE secret key into an LWE secret key Read more
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let glwe_secret_key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);

let lwe_secret_key = engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
Unsafely transforms a GLWE secret key into an LWE secret key Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();

let lwe_bootstrap_key: LweBootstrapKey32 = engine.create_lwe_bootstrap_key_from(
    owned_container,
    glwe_size,
    polynomial_size,
    base_log,
    level,
)?;
let retrieved_container = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();

let lwe_bootstrap_key: LweBootstrapKey64 = engine.create_lwe_bootstrap_key_from(
    owned_container,
    glwe_size,
    polynomial_size,
    base_log,
    level,
)?;
let retrieved_container = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let mut owned_container =
    vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let mut slice = owned_container.as_mut_slice();
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

let lwe_bootstrap_key: LweBootstrapKeyMutView32 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;

assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let mut owned_container =
    vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let mut slice = owned_container.as_mut_slice();
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

let lwe_bootstrap_key: LweBootstrapKeyMutView64 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;

assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let slice = owned_container.as_slice();

let lwe_bootstrap_key: LweBootstrapKeyView32 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;

assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let slice = owned_container.as_slice();

let lwe_bootstrap_key: LweBootstrapKeyView64 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;

assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let slice = owned_container.as_slice();

let lwe_bootstrap_key: LweBootstrapKeyView32 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
Unsafely creates an LWE bootstrap key from an existing container. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let slice = owned_container.as_slice();

let lwe_bootstrap_key: LweBootstrapKeyView64 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
Unsafely creates an LWE bootstrap key from an existing container. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let mut owned_container =
    vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let mut slice = owned_container.as_mut_slice();

let lwe_bootstrap_key: LweBootstrapKeyMutView32 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
Unsafely creates an LWE bootstrap key from an existing container. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let mut owned_container =
    vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let mut slice = owned_container.as_mut_slice();

let lwe_bootstrap_key: LweBootstrapKeyMutView64 =
    engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
Unsafely creates an LWE bootstrap key from an existing container. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let lwe_bootstrap_key: LweBootstrapKey32 = engine.create_lwe_bootstrap_key_from(
    owned_container,
    glwe_size,
    polynomial_size,
    base_log,
    level,
)?;
Unsafely creates an LWE bootstrap key from an existing container. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let owned_container =
    vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];

let lwe_bootstrap_key: LweBootstrapKey64 = engine.create_lwe_bootstrap_key_from(
    owned_container,
    glwe_size,
    polynomial_size,
    base_log,
    level,
)?;
Unsafely creates an LWE bootstrap key from an existing container. Read more
Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 =
    default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
    default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;

let mut owned_container = vec![
    0_u32;
    lwe_dim.0
        * dec_lc.0
        * glwe_dim.to_glwe_size().0
        * glwe_dim.to_glwe_size().0
        * poly_size.0
];

let mut out_bsk_mut_view: LweBootstrapKeyMutView32 = default_engine
    .create_lwe_bootstrap_key_from(
        owned_container.as_mut_slice(),
        glwe_dim.to_glwe_size(),
        poly_size,
        dec_bl,
        dec_lc,
    )?;

default_engine.discard_convert_lwe_bootstrap_key(&mut out_bsk_mut_view, &bsk)?;
assert_eq!(out_bsk_mut_view.glwe_dimension(), glwe_dim);
assert_eq!(out_bsk_mut_view.polynomial_size(), poly_size);
assert_eq!(out_bsk_mut_view.input_lwe_dimension(), lwe_dim);
assert_eq!(out_bsk_mut_view.decomposition_base_log(), dec_bl);
assert_eq!(out_bsk_mut_view.decomposition_level_count(), dec_lc);

// Check content is the same

let original_bsk_container = default_engine.consume_retrieve_lwe_bootstrap_key(bsk)?;
let mut_view_bsk_container =
    default_engine.consume_retrieve_lwe_bootstrap_key(out_bsk_mut_view)?;

assert_eq!(original_bsk_container, mut_view_bsk_container);
Unsafely converts a LWE bootstrap key . Read more
Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
    default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
    default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;

let mut owned_container = vec![
    0_u64;
    lwe_dim.0
        * dec_lc.0
        * glwe_dim.to_glwe_size().0
        * glwe_dim.to_glwe_size().0
        * poly_size.0
];

let mut out_bsk_mut_view: LweBootstrapKeyMutView64 = default_engine
    .create_lwe_bootstrap_key_from(
        owned_container.as_mut_slice(),
        glwe_dim.to_glwe_size(),
        poly_size,
        dec_bl,
        dec_lc,
    )?;

default_engine.discard_convert_lwe_bootstrap_key(&mut out_bsk_mut_view, &bsk)?;
assert_eq!(out_bsk_mut_view.glwe_dimension(), glwe_dim);
assert_eq!(out_bsk_mut_view.polynomial_size(), poly_size);
assert_eq!(out_bsk_mut_view.input_lwe_dimension(), lwe_dim);
assert_eq!(out_bsk_mut_view.decomposition_base_log(), dec_bl);
assert_eq!(out_bsk_mut_view.decomposition_level_count(), dec_lc);

// Check content is the same

let original_bsk_container = default_engine.consume_retrieve_lwe_bootstrap_key(bsk)?;
let mut_view_bsk_container =
    default_engine.consume_retrieve_lwe_bootstrap_key(out_bsk_mut_view)?;

assert_eq!(original_bsk_container, mut_view_bsk_container);
Unsafely converts a LWE bootstrap key . Read more

Description:

Implementation of LweBootstrapKeyGenerationEngine for DefaultEngine that operates on 32 bits integers. It outputs a bootstrap key in the standard domain.

Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;

let bsk: LweBootstrapKey32 =
    engine.generate_new_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);
Unsafely generates a new LWE bootstrap key. Read more

Description:

Implementation of LweBootstrapKeyGenerationEngine for DefaultEngine that operates on 64 bits integers. It outputs a bootstrap key in the standard domain.

Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;

let bsk: LweBootstrapKey64 =
    engine.generate_new_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);
Unsafely generates a new LWE bootstrap key. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext32 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 =
    engine.trivially_encrypt_lwe_ciphertext(lwe_dimension.to_lwe_size(), &plaintext)?;

engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 =
    engine.trivially_encrypt_lwe_ciphertext(lwe_dimension.to_lwe_size(), &plaintext)?;

engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine that operates on views containing 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext32 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;

engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine that operates on views containing 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;

engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext32 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely multiply an LWE ciphertext with a cleartext. Read more

Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a LweCiphertext32 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: LweCiphertext32 = engine.create_lwe_ciphertext_from(owned_container)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more

Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a LweCiphertext64 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: LweCiphertext64 = engine.create_lwe_ciphertext_from(owned_container)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more

Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying container of a LweCiphertextMutView32 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextMutView32 = engine.create_lwe_ciphertext_from(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more

Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying container of a LweCiphertextMutView64 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextMutView64 = engine.create_lwe_ciphertext_from(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more

Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying container of a LweCiphertextView32 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext_from(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more

Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying container of a LweCiphertextView64 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextView64 = engine.create_lwe_ciphertext_from(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more

Description:

Implementation of LweCiphertextCreationEngine for DefaultEngine which returns an immutable LweCiphertextView32 that does not own its memory.

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext_from(slice)?;
Unsafely creates an LWE ciphertext from an arbitrary container. Read more

Description:

Implementation of LweCiphertextCreationEngine for DefaultEngine which returns an immutable LweCiphertextView64 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let mut owned_container = vec![0_u64; 128];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextView64 = engine.create_lwe_ciphertext_from(slice)?;
Unsafely creates an LWE ciphertext from an arbitrary container. Read more

Description:

Implementation of LweCiphertextCreationEngine for DefaultEngine which returns a mutable LweCiphertextMutView32 that does not own its memory.

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextMutView32 = engine.create_lwe_ciphertext_from(slice)?;
Unsafely creates an LWE ciphertext from an arbitrary container. Read more

Description:

Implementation of LweCiphertextCreationEngine for DefaultEngine which returns a mutable LweCiphertextMutView64 that does not own its memory.

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_view: LweCiphertextMutView64 = engine.create_lwe_ciphertext_from(slice)?;
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let owned_container = vec![0_u32; lwe_size.0];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: LweCiphertext32 = engine.create_lwe_ciphertext_from(owned_container)?;
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let owned_container = vec![0_u64; lwe_size.0];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext: LweCiphertext64 = engine.create_lwe_ciphertext_from(owned_container)?;
Unsafely creates an LWE ciphertext from an arbitrary container. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;

let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
Unsafely decrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on an LweCiphertextView32 containing 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut raw_ciphertext = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut raw_ciphertext[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_view, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
let ciphertext_view: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext[..])?;

let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
Unsafely decrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;

let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
Unsafely decrypts an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on an LweCiphertextView64 containing 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u64 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut raw_ciphertext = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut raw_ciphertext[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_view, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
let ciphertext_view: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext[..])?;

let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
Unsafely decrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
Unsafely adds two LWE ciphertexts. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 7_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
Unsafely adds two LWE ciphertexts. Read more

Description:

Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates on views containing 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&input_2)?;

let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext_1, noise)?;
let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_2, &plaintext_2, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_2[..])?;

let mut ciphertext_3_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_3: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_3_container[..])?;

engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
Unsafely adds two LWE ciphertexts. Read more

Description:

Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates on on views containing 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 7_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&input_2)?;

let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext_1, noise)?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_2, &plaintext_2, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_2[..])?;

let mut ciphertext_3_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_3: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_3_container[..])?;

engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
Unsafely adds two LWE ciphertexts. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext_from(&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);
Unsafely decrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext_from(&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);
Unsafely decrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut output_cipertext_container = vec![0_32; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut output_cipertext_container[..])?;

engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut output_cipertext_container = vec![0_64; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut output_cipertext_container[..])?;

engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{
    GlweDimension, LweDimension, MonomialIndex, PolynomialSize, Variance, *,
};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{
    GlweDimension, LweDimension, MonomialIndex, PolynomialSize, Variance, *,
};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely keyswitch an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates on views containing 32 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut raw_ciphertext_1_container = vec![0_u32; input_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut raw_ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&input_key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut raw_ciphertext_2_container = vec![0_u32; output_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut raw_ciphertext_2_container[..])?;

engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
Unsafely keyswitch an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely keyswitch an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates on views containing 64 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut raw_ciphertext_1_container = vec![0_u64; input_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut raw_ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&input_key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut raw_ciphertext_2_container = vec![0_u64; output_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut raw_ciphertext_2_container[..])?;

engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
Unsafely keyswitch an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;

engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely computes the opposite of an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;

engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely computes the opposite of an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on views containing 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;

engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely computes the opposite of an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on views containing 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;

engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely computes the opposite of an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(7);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey32 = engine.generate_new_lwe_public_key(
    &secret_key,
    noise,
    lwe_public_key_zero_encryption_count,
)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext_container = vec![0u32; lwe_dimension.to_lwe_size().0];

let mut ciphertext = engine.create_lwe_ciphertext_from(ciphertext_container)?;

engine.discard_encrypt_lwe_ciphertext_with_public_key(
    &public_key,
    &mut ciphertext,
    &plaintext,
)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts an LWE ciphertext using a public key. Read more

Description:

Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(7);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey64 = engine.generate_new_lwe_public_key(
    &secret_key,
    noise,
    lwe_public_key_zero_encryption_count,
)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext_container = vec![0u64; lwe_dimension.to_lwe_size().0];

let mut ciphertext = engine.create_lwe_ciphertext_from(ciphertext_container)?;

engine.discard_encrypt_lwe_ciphertext_with_public_key(
    &public_key,
    &mut ciphertext,
    &plaintext,
)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts an LWE ciphertext using a public key. Read more

Description:

Implementation of LweCiphertextDiscardingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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_sub_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
Unsafely substracts two LWE ciphertexts. Read more

Description:

Implementation of LweCiphertextDiscardingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 7_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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_sub_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
Unsafely substracts two LWE ciphertexts. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
Unsafely add an LWE ciphertext to an other. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 5_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
Unsafely add an LWE ciphertext to an other. Read more

Description:

Implementation of LweCiphertextFusingOppositeEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;

engine.fuse_opp_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely computes the opposite of an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextFusingOppositeEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;

engine.fuse_opp_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely computes the opposite of an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextFusingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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_sub_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely subtracts an LWE ciphertext to another. Read more

Description:

Implementation of LweCiphertextFusingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 5_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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_sub_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely subtracts an LWE ciphertext to another. Read more

Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely adds a plaintext to an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
Unsafely adds a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on views containing 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2 = engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;

engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely adds a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on views containing 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
    engine.create_lwe_ciphertext_from(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;

// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 =
    engine.create_lwe_ciphertext_from(&raw_ciphertext_1[..])?;

let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2 = engine.create_lwe_ciphertext_from(&mut ciphertext_2_container[..])?;

engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely adds a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextDiscardingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;

engine.discard_sub_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely subtracts a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextDiscardingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;

engine.discard_sub_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
Unsafely subtracts a plaintext to an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
Unsafely add a plaintext to an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 40 bits)
let input_1 = 3_u64 << 40;
let input_2 = 5_u64 << 40;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
Unsafely add a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextFusingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;

engine.fuse_sub_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely subtracts a plaintext to an LWE ciphertext. Read more

Description:

Implementation of LweCiphertextPlaintextFusingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 40 bits)
let input_1 = 3_u64 << 40;
let input_2 = 5_u64 << 40;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;

engine.fuse_sub_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely subtracts a plaintext to an LWE ciphertext. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = 3_u32 << 20;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext32 =
    engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;
let output: Plaintext32 = engine.trivially_decrypt_lwe_ciphertext(&ciphertext)?;
let res = engine.retrieve_plaintext(&output)?;
assert_eq!(res, input);
Unsafely trivially decrypts an LWE ciphertext into a plaintext. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = 3_u64 << 20;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext64 = engine.create_plaintext_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext64 =
    engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;

let output: Plaintext64 = engine.trivially_decrypt_lwe_ciphertext(&ciphertext)?;
let res = engine.retrieve_plaintext(&output)?;
assert_eq!(res, input);
Unsafely trivially decrypts an LWE ciphertext into a plaintext. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = 3_u32 << 20;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext32 =
    engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;

assert_eq!(ciphertext.lwe_dimension().to_lwe_size(), lwe_size);
Unsafely creates the trivial LWE encryption of the plaintext. Read more
Example:

use concrete_core::prelude::{CiphertextCount, LweSize, Variance, *};

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext64 = engine.create_plaintext_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext64 =
    engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;

assert_eq!(ciphertext.lwe_dimension().to_lwe_size(), lwe_size);
Unsafely creates the trivial LWE encryption of the plaintext. Read more

Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVector32 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
use concrete_core::commons::crypto::lwe::LweCiphertext;
let lwe_size = LweSize(128);
let lwe_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: LweCiphertextVector32 =
    engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVector64 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
use concrete_core::commons::crypto::lwe::LweCiphertext;
let lwe_size = LweSize(128);
let lwe_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.0];
let original_vec_ptr = owned_container.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: LweCiphertextVector64 =
    engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVectorMutView32 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_ciphertext_count.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorMutView32 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVectorMutView64 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_ciphertext_count.0];

let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorMutView64 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVectorView32 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_ciphertext_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorView32 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVectorView64 consuming it in the process

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_ciphertext_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorView64 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more

Description:

Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns an immutable LweCiphertextVectorView32 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorView32 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more

Description:

Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns an immutable LweCiphertextVectorView64 that does not own its memory.

Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.0];

let slice = &owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorView64 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more

Description:

Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a mutable LweCiphertextVectorMutView32 that does not own its memory.

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorMutView32 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more

Description:

Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a mutable LweCiphertextVectorMutView64 that does not own its memory.

Example:
use concrete_core::prelude::{LweSize, *};

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.0];

let slice = &mut owned_container[..];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorMutView64 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.0];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: LweCiphertextVector32 =
    engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Example:
use concrete_core::prelude::*;

// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.0];

// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector: LweCiphertextVector64 =
    engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more

Description:

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

Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 18];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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)
);
Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(18);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; lwe_count.0];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let mut raw_ciphertext_vector = vec![0_u32; key.lwe_dimension().to_lwe_size().0 * lwe_count.0];
let mut ciphertext_vector_view: LweCiphertextVectorMutView32 = engine
    .create_lwe_ciphertext_vector_from(
        &mut raw_ciphertext_vector[..],
        lwe_dimension.to_lwe_size(),
    )?;
engine.discard_encrypt_lwe_ciphertext_vector(
    &key,
    &mut ciphertext_vector_view,
    &plaintext_vector,
    noise,
)?;

// Convert MutView to View
let raw_ciphertext_vector =
    engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
let ciphertext_vector_view: LweCiphertextVectorView32 = engine
    .create_lwe_ciphertext_vector_from(
        &raw_ciphertext_vector[..],
        lwe_dimension.to_lwe_size(),
    )?;

let decrypted_plaintext_vector =
    engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector_view)?;

assert_eq!(
    decrypted_plaintext_vector.plaintext_count(),
    PlaintextCount(lwe_count.0)
);
Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 18];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector: LweCiphertextVector64 =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

let decrypted_plaintext_vector =
    engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;

assert_eq!(
    decrypted_plaintext_vector.plaintext_count(),
    PlaintextCount(18)
);
Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(18);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;

let mut raw_ciphertext_vector = vec![0_u64; key.lwe_dimension().to_lwe_size().0 * lwe_count.0];
let mut ciphertext_vector_view: LweCiphertextVectorMutView64 = engine
    .create_lwe_ciphertext_vector_from(
        &mut raw_ciphertext_vector[..],
        lwe_dimension.to_lwe_size(),
    )?;
engine.discard_encrypt_lwe_ciphertext_vector(
    &key,
    &mut ciphertext_vector_view,
    &plaintext_vector,
    noise,
)?;

// Convert MutView to View
let raw_ciphertext_vector =
    engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
let ciphertext_vector_view: LweCiphertextVectorView64 = engine
    .create_lwe_ciphertext_vector_from(
        &raw_ciphertext_vector[..],
        lwe_dimension.to_lwe_size(),
    )?;

let decrypted_plaintext_vector =
    engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector_view)?;

assert_eq!(
    decrypted_plaintext_vector.plaintext_count(),
    PlaintextCount(lwe_count.0)
);
Unsafely decrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.discard_add_lwe_ciphertext_vector(
    &mut output_ciphertext_vector,
    &ciphertext_vector,
    &ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely adds two LWE ciphertext vectors. Read more

Description:

Implementation of LweCiphertextVectorDiscardingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.discard_add_lwe_ciphertext_vector(
    &mut output_ciphertext_vector,
    &ciphertext_vector,
    &ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely adds two LWE ciphertext vectors. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_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.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector32 = engine.create_cleartext_vector_from(&input_vector)?;
let bias: Plaintext32 = engine.create_plaintext_from(&bias_input)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;

engine.discard_affine_transform_lwe_ciphertext_vector(
    &mut output_ciphertext,
    &ciphertext_vector,
    &weights,
    &bias,
)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
Unsafely performs the affine transform of an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let weights_input = vec![2_u64; 8];
let bias_input = 8_u64 << 50;
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector64 = engine.create_cleartext_vector_from(&input_vector)?;
let bias: Plaintext64 = engine.create_plaintext_from(&bias_input)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;

engine.discard_affine_transform_lwe_ciphertext_vector(
    &mut output_ciphertext,
    &ciphertext_vector,
    &weights,
    &bias,
)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
Unsafely performs the affine transform of an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 18];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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));
Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 18];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector: LweCiphertextVector64 =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.discard_decrypt_lwe_ciphertext_vector(
    &key,
    &mut plaintext_vector,
    &ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));
Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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!(
Unsafely encryprs an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; lwe_count.0];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;

let mut output_ciphertext_vector_container = vec![0_32; lwe_dimension.to_lwe_size().0 *
    lwe_count.0];
let mut ciphertext_vector: LweCiphertextVectorMutView32 =
    engine.create_lwe_ciphertext_vector_from(&mut output_ciphertext_vector_container[..],
    lwe_dimension.to_lwe_size())?;

engine.discard_encrypt_lwe_ciphertext_vector(&key, &mut ciphertext_vector,
    &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Unsafely encryprs an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
    engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;

engine.discard_encrypt_lwe_ciphertext_vector(
    &key,
    &mut ciphertext_vector,
    &plaintext_vector,
    noise,
);
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Unsafely encryprs an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;

let mut output_ciphertext_vector_container = vec![0_64; lwe_dimension.to_lwe_size().0 *
    lwe_count.0];
let mut ciphertext_vector: LweCiphertextVectorMutView64 =
    engine.create_lwe_ciphertext_vector_from(&mut output_ciphertext_vector_container[..],
    lwe_dimension.to_lwe_size())?;

engine.discard_encrypt_lwe_ciphertext_vector(&key, &mut ciphertext_vector,
    &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Unsafely encryprs an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorDiscardingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.discard_sub_lwe_ciphertext_vector(
    &mut output_ciphertext_vector,
    &ciphertext_vector,
    &ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely subtracts two LWE ciphertext vectors. Read more

Description:

Implementation of LweCiphertextVectorDiscardingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.discard_sub_lwe_ciphertext_vector(
    &mut output_ciphertext_vector,
    &ciphertext_vector,
    &ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely subtracts two LWE ciphertext vectors. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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!(
Unsafely encrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;

let mut ciphertext_vector: LweCiphertextVector64 =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Unsafely encrypts an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorFusingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.fuse_add_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely add two LWE ciphertext vectors. Read more

Description:

Implementation of LweCiphertextVectorFusingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.fuse_add_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely add two LWE ciphertext vectors. Read more

Description:

Implementation of LweCiphertextVectorFusingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.fuse_sub_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely subtracts two LWE ciphertext vectors. Read more

Description:

Implementation of LweCiphertextVectorFusingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;

engine.fuse_sub_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely subtracts two LWE ciphertext vectors. Read more

Description:

Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20, 256];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;

engine.discard_packing_keyswitch_lwe_ciphertext_vector(
    &mut ciphertext_output,
    &ciphertext_vector,
    &packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
Unsafely packing keyswitches an LWE ciphertext vector. Read more

Description:

Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input_vector = vec![3_u64 << 50, 256];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;

engine.discard_packing_keyswitch_lwe_ciphertext_vector(
    &mut ciphertext_output,
    &ciphertext_vector,
    &packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
Unsafely packing keyswitches an LWE ciphertext vector. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20, 256];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
    engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let val = vec![1_u32; output_key.polynomial_size().0];
let polynomial: CleartextVector32 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
    .generate_new_lwe_private_functional_packing_keyswitch_key(
        &input_key,
        &output_key,
        decomposition_level_count,
        decomposition_base_log,
        StandardDev(noise.get_standard_dev()),
        &|x| x,
        &polynomial,
    )?;
let plaintext_vector = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;

engine.discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
    &mut ciphertext_output,
    &ciphertext_vector,
    &private_functional_packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
Unsafely keyswitches an LWE ciphertext vector using a private functional packing keyswitch key. Read more
Example:
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input_vector = vec![3_u64 << 50, 256];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
    engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let val = vec![1_u64; output_key.polynomial_size().0];
let polynomial: CleartextVector64 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
    .generate_new_lwe_private_functional_packing_keyswitch_key(
        &input_key,
        &output_key,
        decomposition_level_count,
        decomposition_base_log,
        StandardDev(noise.get_standard_dev()),
        &|x| x,
        &polynomial,
    )?;
let plaintext_vector = engine.create_plaintext_vector_from(&input_vector)?;
let ciphertext_vector =
    engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;

engine.discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
    &mut ciphertext_output,
    &ciphertext_vector,
    &private_functional_packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
Unsafely keyswitches an LWE ciphertext vector using a private functional packing keyswitch key. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u32 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector32 =
    engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
let output: PlaintextVector32 =
    engine.trivially_decrypt_lwe_ciphertext_vector(&ciphertext_vector)?;

assert_eq!(output.plaintext_count(), PlaintextCount(3));
Unsafely trivially decrypts an LWE ciphertext vector into a plaintext vector. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u64 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector64 =
    engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;

let output: PlaintextVector64 =
    engine.trivially_decrypt_lwe_ciphertext_vector(&ciphertext_vector)?;

assert_eq!(output.plaintext_count(), PlaintextCount(3));
Unsafely trivially decrypts an LWE ciphertext vector into a plaintext vector. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u32 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
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
);
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
Example:

use concrete_core::prelude::{LweSize, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u64 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector64 =
    engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;

assert_eq!(ciphertext_vector.lwe_dimension().to_lwe_size(), lwe_size);
assert_eq!(
    ciphertext_vector.lwe_ciphertext_count().0,
    plaintext_vector.plaintext_count().0
);
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let ciphertext_vector =
    engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
Unsafely encrypts zeros in an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let ciphertext_vector =
    engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
Unsafely encrypts zeros in an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Safely encrypts zero into an LWE ciphertext. Read more

Description:

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

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Safely encrypts zero into an LWE ciphertext. Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension,FunctionalPackingKeyswitchKeyCount
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;

let cbs_private_functional_packing_keyswitch_key:
    LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32 =
    engine
    .generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
        &input_key,
        &output_key,
        decomposition_base_log,
        decomposition_level_count,
        noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(cbs_private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.key_count().0,
output_glwe_dimension.to_glwe_size().0);
Unsafely generate a new LWE CBSFPKSK. Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension,FunctionalPackingKeyswitchKeyCount
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;

let cbs_private_functional_packing_keyswitch_key:
    LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64 =
    engine
    .generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
        &input_key,
        &output_key,
        decomposition_base_log,
        decomposition_level_count,
        noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(cbs_private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.key_count().0,
output_glwe_dimension.to_glwe_size().0);
Unsafely generate a new LWE CBSFPKSK. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u32;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];
let original_vec_ptr = owned_container.as_ptr();

let keyswitch_key: LweKeyswitchKey32 = engine.create_lwe_keyswitch_key_from(
    owned_container,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;
let retrieved_container = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;

assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u64;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];
let original_vec_ptr = owned_container.as_ptr();

let keyswitch_key: LweKeyswitchKey64 = engine.create_lwe_keyswitch_key_from(
    owned_container,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;
let retrieved_container = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;

assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container = vec![
    0u32;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];
let slice = owned_container.as_mut_slice();
let underlying_ptr = slice.as_ptr();

let keyswitch_key: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
    slice,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;

assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container = vec![
    0u64;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];
let slice = owned_container.as_mut_slice();
let underlying_ptr = slice.as_ptr();

let keyswitch_key: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
    slice,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;

assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u32;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];
let slice = owned_container.as_slice();

let keyswitch_key: LweKeyswitchKeyView32 = engine.create_lwe_keyswitch_key_from(
    slice,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;

assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u64;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];
let slice = owned_container.as_slice();

let keyswitch_key: LweKeyswitchKeyView64 = engine.create_lwe_keyswitch_key_from(
    slice,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;

assert_eq!(slice, retrieved_slice);
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u32;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];

let keyswitch_key: LweKeyswitchKeyView32 = engine.create_lwe_keyswitch_key_from(
    owned_container.as_slice(),
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
    keyswitch_key.decomposition_level_count(),
    decomposition_level_count
);
assert_eq!(
    keyswitch_key.decomposition_base_log(),
    decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely creates an LWE keyswitch key from an existing container. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u64;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];

let keyswitch_key: LweKeyswitchKeyView64 = engine.create_lwe_keyswitch_key_from(
    owned_container.as_slice(),
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
    keyswitch_key.decomposition_level_count(),
    decomposition_level_count
);
assert_eq!(
    keyswitch_key.decomposition_base_log(),
    decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely creates an LWE keyswitch key from an existing container. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container = vec![
    0u32;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];

let keyswitch_key: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
    owned_container.as_mut_slice(),
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
    keyswitch_key.decomposition_level_count(),
    decomposition_level_count
);
assert_eq!(
    keyswitch_key.decomposition_base_log(),
    decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely creates an LWE keyswitch key from an existing container. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container = vec![
    0u64;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];

let keyswitch_key: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
    owned_container.as_mut_slice(),
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
    keyswitch_key.decomposition_level_count(),
    decomposition_level_count
);
assert_eq!(
    keyswitch_key.decomposition_base_log(),
    decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely creates an LWE keyswitch key from an existing container. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u32;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];

let keyswitch_key: LweKeyswitchKey32 = engine.create_lwe_keyswitch_key_from(
    owned_container,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
    keyswitch_key.decomposition_level_count(),
    decomposition_level_count
);
assert_eq!(
    keyswitch_key.decomposition_base_log(),
    decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely creates an LWE keyswitch key from an existing container. Read more
Example:
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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container = vec![
    0u64;
    input_lwe_dimension.0
        * output_lwe_dimension.to_lwe_size().0
        * decomposition_level_count.0
];

let keyswitch_key: LweKeyswitchKey64 = engine.create_lwe_keyswitch_key_from(
    owned_container,
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
    keyswitch_key.decomposition_level_count(),
    decomposition_level_count
);
assert_eq!(
    keyswitch_key.decomposition_base_log(),
    decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely creates an LWE keyswitch key from an existing container. Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;

let mut owned_container = vec![
    0_u32;
    decomposition_level_count.0 * output_lwe_dimension.to_lwe_size().0 * input_lwe_dimension.0
];

let mut out_ksk_mut_view: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
    owned_container.as_mut_slice(),
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
assert_eq!(
assert_eq!(out_ksk_mut_view.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(out_ksk_mut_view.output_lwe_dimension(), output_lwe_dimension);
Unsafely converts a LWE keyswitch key . Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    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(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;

let mut owned_container = vec![
    0_u64;
    decomposition_level_count.0 * output_lwe_dimension.to_lwe_size().0 * input_lwe_dimension.0
];

let mut out_ksk_mut_view: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
    owned_container.as_mut_slice(),
    output_lwe_dimension,
    decomposition_base_log,
    decomposition_level_count,
)?;

assert_eq!(
assert_eq!(
assert_eq!(out_ksk_mut_view.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(out_ksk_mut_view.output_lwe_dimension(), output_lwe_dimension);
Unsafely converts a LWE keyswitch key . Read more

Description:

Implementation of LweKeyswitchKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let keyswitch_key = engine.generate_new_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);
Unsafely generates a new LWE keyswitch key. Read more

Description:

Implementation of LweKeyswitchKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let keyswitch_key = engine.generate_new_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);
Unsafely generates a new LWE keyswitch key. Read more

Description:

Implementation of LwePackingKeyswitchKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    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_glwe_dimension = GlweDimension(3);
let output_polynomial_size = PolynomialSize(512);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(
    output_glwe_dimension,
    output_polynomial_size
)?;

let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_glwe_dimension(), output_glwe_dimension);
assert_eq!(packing_keyswitch_key.output_polynomial_size(), output_polynomial_size);
Unsafely generates a new packing keyswitch key. Read more

Description:

Implementation of LwePackingKeyswitchKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    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_glwe_dimension = GlweDimension(3);
let output_polynomial_size = PolynomialSize(512);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(
    output_glwe_dimension,
    output_polynomial_size
)?;

let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_glwe_dimension(), output_glwe_dimension);
assert_eq!(packing_keyswitch_key.output_polynomial_size(), output_polynomial_size);
Unsafely generates a new packing keyswitch key. Read more

Description:

Implementation of LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine for DefaultEngine that operates on 32 bits integers. Note that the function applied during keyswitching is of the form m -> m * pol for a polynomial pol. The input polynomial should be a cleartext vector containing the coefficients of pol starting with the constant term.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;

let val = vec![1_u32; output_key.polynomial_size().0];
let polynomial: CleartextVector32 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    StandardDev(noise.get_standard_dev()),
    &|x|x,
    &polynomial,
)?;
assert_eq!(
assert_eq!(
assert_eq!(private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
Unsafely generates a new private functional packing keyswitch key. Read more

Description:

Implementation of LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine for DefaultEngine that operates on 64 bits integers. Note that the function applied during keyswitching is of the form m -> m * pol for a polynomial pol. The input polynomial should be a cleartext vector containing the coefficients of pol starting with the constant term.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension
};
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_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;

let val = vec![1_u64; output_key.polynomial_size().0];
let polynomial: CleartextVector64 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    StandardDev(noise.get_standard_dev()),
    &|x|x,
    &polynomial,
)?;
assert_eq!(
assert_eq!(
assert_eq!(private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
Unsafely generates a new private functional packing keyswitch key. Read more

Description:

Implementation of LwePublicKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, LwePublicKeyZeroEncryptionCount, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let noise = Variance(2_f64.powf(-50.));
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(42);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let public_key: LwePublicKey32 = engine.generate_new_lwe_public_key(
    &lwe_secret_key,
    noise,
    lwe_public_key_zero_encryption_count,
)?;

assert_eq!(public_key.lwe_dimension(), lwe_dimension);
assert_eq!(
    public_key.lwe_zero_encryption_count(),
    lwe_public_key_zero_encryption_count
);
Unsafely generates a new LWE public key. Read more

Description:

Implementation of LwePublicKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, LwePublicKeyZeroEncryptionCount, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let noise = Variance(2_f64.powf(-50.));
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(42);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let public_key: LwePublicKey64 = engine.generate_new_lwe_public_key(
    &lwe_secret_key,
    noise,
    lwe_public_key_zero_encryption_count,
)?;

assert_eq!(public_key.lwe_dimension(), lwe_dimension);
assert_eq!(
    public_key.lwe_zero_encryption_count(),
    lwe_public_key_zero_encryption_count
);
Unsafely generates a new LWE public key. Read more

Description:

Implementation of LweSecretKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
Unsafely generates a new LWE secret key. Read more

Description:

Implementation of LweSecretKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
Unsafely generates a new LWE secret key. Read more

Description:

Implementation of LweSeededBootstrapKeyGenerationEngine for DefaultEngine that operates on 32 bits integers. It outputs a seeded bootstrap key in the standard domain.

Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;

let bsk: LweSeededBootstrapKey32 =
    engine.generate_new_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
Unsafely generates a new seeded LWE bootstrap key. Read more

Description:

Implementation of LweSeededBootstrapKeyGenerationEngine for DefaultEngine that operates on 64 bits integers. It outputs a seeded bootstrap key in the standard domain.

Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;

let bsk: LweSeededBootstrapKey64 =
    engine.generate_new_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
Unsafely generates a new seeded LWE bootstrap key. Read more

Description:

Implementation of LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine for DefaultEngine that operates on 32 bits integers. It outputs a bootstrap key in the standard domain.

Example
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;

let seeded_bsk: LweSeededBootstrapKey32 =
    engine.generate_new_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;

let bsk = engine.transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(seeded_bsk)?;

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);
Unsafely transforms an LWE seeded bootstrap key into an LWE bootstrap key Read more

Description:

Implementation of LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine for DefaultEngine that operates on 64 bits integers. It outputs a bootstrap key in the standard domain.

use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
    Variance, *,
};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;

let seeded_bsk: LweSeededBootstrapKey64 =
    engine.generate_new_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;

let bsk = engine.transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(seeded_bsk)?;

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);
Unsafely transforms an LWE seeded bootstrap key into an LWE bootstrap key Read more

Description:

Implementation of LweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts a seeded LWE ciphertext. Read more

Description:

Implementation of LweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely encrypts a seeded LWE ciphertext. Read more

Description:

Implementation of LweSeededCiphertextToLweCiphertextTransformationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let seeded_ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let ciphertext = engine.transform_lwe_seeded_ciphertext_to_lwe_ciphertext(seeded_ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely transforms an LWE seeded ciphertext into an LWE ciphertext Read more

Description:

Implementation of LweSeededCiphertextToLweCiphertextTransformationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;

let seeded_ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let ciphertext = engine.transform_lwe_seeded_ciphertext_to_lwe_ciphertext(seeded_ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
Unsafely transforms an LWE seeded ciphertext into an LWE ciphertext Read more

Description:

Implementation of LweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;

let mut ciphertext_vector: LweSeededCiphertextVector32 =
    engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Unsafely encrypts a seeded LWE ciphertext vector. Read more

Description:

Implementation of LweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;

let mut ciphertext_vector: LweSeededCiphertextVector64 =
    engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
Unsafely encrypts a seeded LWE ciphertext vector. Read more
Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;

let mut seeded_ciphertext_vector: LweSeededCiphertextVector32 =
    engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;

let ciphertext_vector = engine
    .transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
        seeded_ciphertext_vector,
    )?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely transforms an LWE seeded ciphertext vector into an LWE ciphertext vector Read more
Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;

let mut seeded_ciphertext_vector: LweSeededCiphertextVector64 =
    engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;

let ciphertext_vector = engine
    .transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
        seeded_ciphertext_vector,
    )?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
Unsafely transforms an LWE seeded ciphertext vector into an LWE ciphertext vector Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(seeded_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(seeded_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely generates a new seeded LWE keyswitch key. Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(seeded_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(seeded_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely generates a new seeded LWE keyswitch key. Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;

let keyswitch_key = engine.transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(seeded_keyswitch_key)?;

assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
    DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;

let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;

let keyswitch_key = engine.transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(seeded_keyswitch_key)?;

assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(8);
let polynomial_size = PolynomialSize(4);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);

let glwe_secret_key =
    engine.transform_lwe_secret_key_to_glwe_secret_key(lwe_secret_key, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), GlweDimension(2));
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
Unsafely transforms an LWE secret key into a GLWE secret key Read more
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(8);
let polynomial_size = PolynomialSize(4);

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

let lwe_secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);

let glwe_secret_key =
    engine.transform_lwe_secret_key_to_glwe_secret_key(lwe_secret_key, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), GlweDimension(2));
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
Unsafely transforms an LWE secret key into a GLWE secret key Read more

Description:

Implementation of PlaintextCreationEngine for DefaultEngine 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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
Unsafely creates a plaintext from an arbitrary value. Read more

Description:

Implementation of PlaintextCreationEngine for DefaultEngine 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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext64 = engine.create_plaintext_from(&input)?;
Unsafely creates a plaintext from an arbitrary value. Read more

Description:

Implementation of PlaintextDecodingEngine for DefaultEngine that decodes 32 bits integers to 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder = engine.create_encoder_from(&FloatEncoderMinMaxConfig {
    min: 0.,
    max: 10.,
    nb_bit_precision: 8,
    nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext32 = engine.encode_cleartext(&encoder, &cleartext)?;
let recovered_cleartext: CleartextF64 = engine.decode_plaintext(&encoder, &plaintext)?;
Unsafely decodes a plaintext. Read more

Description:

Implementation of PlaintextDecodingEngine for DefaultEngine that decodes 64 bits integers to 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder = engine.create_encoder_from(&FloatEncoderMinMaxConfig {
    min: 0.,
    max: 10.,
    nb_bit_precision: 8,
    nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext64 = engine.encode_cleartext(&encoder, &cleartext)?;
let recovered_cleartext: CleartextF64 = engine.decode_plaintext(&encoder, &plaintext)?;
Unsafely decodes a plaintext. Read more

Description:

Implementation of PlaintextDiscardingRetrievalEngine for DefaultEngine 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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;

assert_eq!(output, 3_u32 << 20);
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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext64 = engine.create_plaintext_from(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;

assert_eq!(output, 3_u64 << 20);
Unsafely retrieves an arbitrary value from a plaintext inplace. Read more

Description:

Implementation of PlaintextRetrievalEngine for DefaultEngine 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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
let output: u32 = engine.retrieve_plaintext(&plaintext)?;

assert_eq!(output, 3_u32 << 20);
Unsafely retrieves an arbitrary value from a plaintext. Read more

Description:

Implementation of PlaintextRetrievalEngine for DefaultEngine 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;

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext64 = engine.create_plaintext_from(&input)?;
let output: u64 = engine.retrieve_plaintext(&plaintext)?;

assert_eq!(output, 3_u64 << 20);
Unsafely retrieves an arbitrary value from a plaintext. Read more

Description:

Implementation of PlaintextVectorCreationEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{PlaintextCount, *};

// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
Unsafely creates a plaintext vector from a slice of arbitrary values. Read more

Description:

Implementation of PlaintextVectorCreationEngine for DefaultEngine that operates on 64 bits integers.

Example:
use concrete_core::prelude::{PlaintextCount, *};

// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
Unsafely creates a plaintext vector from a slice of arbitrary values. Read more

Description:

Implementation of PlaintextVectorDecodingEngine for DefaultEngine that decodes 32 bits integers to 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder_vector = engine.create_encoder_vector_from(&vec![
    FloatEncoderMinMaxConfig {
        min: 0.,
        max: 10.,
        nb_bit_precision: 8,
        nb_bit_padding: 1,
    };
    100
])?;
let cleartext_vector: CleartextVectorF64 =
    engine.create_cleartext_vector_from(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector32 =
    engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
let recovered_cleartext_vector: CleartextVectorF64 =
    engine.decode_plaintext_vector(&encoder_vector, &plaintext_vector)?;
assert_eq!(
    recovered_cleartext_vector.cleartext_count().0,
    plaintext_vector.plaintext_count().0
);
Unsafely decodes a plaintext vector. Read more

Description:

Implementation of PlaintextVectorDecodingEngine for DefaultEngine that decodes 64 bits integers to 64 bits floating point numbers.

Example:
use concrete_core::prelude::*;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let encoder_vector = engine.create_encoder_vector_from(&vec![
    FloatEncoderMinMaxConfig {
        min: 0.,
        max: 10.,
        nb_bit_precision: 8,
        nb_bit_padding: 1,
    };
    100
])?;
let cleartext_vector: CleartextVectorF64 =
    engine.create_cleartext_vector_from(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector32 =
    engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
let recovered_cleartext_vector: CleartextVectorF64 =
    engine.decode_plaintext_vector(&encoder_vector, &plaintext_vector)?;
assert_eq!(
    recovered_cleartext_vector.cleartext_count().0,
    plaintext_vector.plaintext_count().0
);
Unsafely decodes a plaintext vector. Read more

Description:

Implementation of PlaintextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Example:
use concrete_core::prelude::{PlaintextCount, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
Unsafely retrieves arbitrary values from a plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{PlaintextCount, *};

// 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];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
Unsafely retrieves arbitrary values from a plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{PlaintextCount, *};

// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let output: Vec<u32> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
Unsafely retrieves arbitrary values from a plaintext vector. Read more

Description:

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

Example:
use concrete_core::prelude::{PlaintextCount, *};

// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u64 << 20; 3];

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let output: Vec<u64> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
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.