pub struct LweSecretKey64(_);
Expand description

A structure representing an LWE secret key with 64 bits of precision.

Trait Implementations

The kind of the entity.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Destroys an entity.

Unsafely destroys an entity. Read more

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

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

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

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

let lwe_secret_key = engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));

engine.destroy(lwe_secret_key)?;

Unsafely transforms a GLWE secret key into an LWE secret key Read more

Description:

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

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

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

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

let bsk: LweBootstrapKey64 =
    engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);

engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;

Unsafely creates an LWE bootstrap key. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext)?;

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_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

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

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

let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_view)?;
engine.destroy(decrypted_plaintext)?;

Unsafely decrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

engine.discard_decrypt_lwe_ciphertext(&key, &mut plaintext, &ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;

Unsafely decrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

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

engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(output_ciphertext)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;

Unsafely encrypts an LWE ciphertext. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;

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

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

let decrypted_plaintext_vector =
    engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;

assert_eq!(
    decrypted_plaintext_vector.plaintext_count(),
    PlaintextCount(18)
);

engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;

Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;

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

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

engine.discard_decrypt_lwe_ciphertext_vector(
    &key,
    &mut plaintext_vector,
    &ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));

engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;

Unsafely decrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

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

// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
    engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;

engine.discard_encrypt_lwe_ciphertext_vector(
    &key,
    &mut ciphertext_vector,
    &plaintext_vector,
    noise,
);
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(

engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;

Unsafely encryprs an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

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

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

let mut ciphertext_vector: LweCiphertextVector64 =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(

engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;

Unsafely encrypts an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));

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

let ciphertext_vector =
    engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);

engine.destroy(key)?;
engine.destroy(ciphertext_vector)?;

Unsafely encrypts zeros in an LWE ciphertext vector. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let noise = Variance(2_f64.powf(-25.));

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

let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);

engine.destroy(key)?;
engine.destroy(ciphertext)?;

Safely encrypts zero into an LWE ciphertext. Read more

Description:

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

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

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

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

let keyswitch_key = engine.create_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);

engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;

Unsafely creates an LWE keyswitch key. Read more

Description:

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

Example:
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);

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

Unsafely creates an LWE secret key. Read more

The distribution of this key.

Returns the LWE dimension of the key.

Description:

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

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

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

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

let bsk: LweSeededBootstrapKey64 =
    engine.create_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);

engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;

Unsafely creates a seeded LWE bootstrap key. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;

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

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

let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);

engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;

Unsafely encrypts a seeded LWE ciphertext. Read more

Description:

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

Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;

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

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

let mut ciphertext_vector: LweSeededCiphertextVector64 =
    engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(

engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;

Unsafely encrypts a seeded LWE ciphertext vector. Read more

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

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

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

let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(seeded_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(seeded_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);

engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(seeded_keyswitch_key)?;

Unsafely creates a seeded LWE keyswitch key. Read more

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

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

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

let lwe_secret_key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);

let glwe_secret_key =
    engine.transform_lwe_secret_key_to_glwe_secret_key(lwe_secret_key, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), GlweDimension(2));
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);

engine.destroy(glwe_secret_key)?;

Unsafely transforms an LWE secret key into a GLWE secret key Read more

Description:

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

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

// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));

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

let packing_keyswitch_key = engine.create_lwe_keyswitch_key(
    &input_key,
    &output_key,
    decomposition_level_count,
    decomposition_base_log,
    noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);

engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(packing_keyswitch_key)?;

Unsafely creates a packing keyswitch key. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

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.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

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.