pub struct LwePublicKey32(_);
Expand description

A structure representing an LWE secret key with 32 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

Description:

Implementation of EntityDeserializationEngine for DefaultSerializationEngine that operates on 32 bits integers. It deserializes an LWE public key.

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

let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&public_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(public_key, recovered);
Unsafely deserializes an entity. Read more

Description:

Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates on 32 bits integers. It serializes an LWE public key.

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

let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&public_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(public_key, recovered);
Unsafely serializes an entity. 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
Returns the LWE dimension of the key.
Returns the number of LWE encryption of 0 in the key.

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 DefaultParallelEngine 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 mut par_engine = DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;

let public_key: LwePublicKey32 = par_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
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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 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.