LwePublicKey32

Struct LwePublicKey32 

Source
pub struct LwePublicKey32(/* private fields */);
Expand description

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

Trait Implementations§

Source§

impl AbstractEntity for LwePublicKey32

Source§

type Kind = LwePublicKeyKind

The kind of the entity.
Source§

impl Clone for LwePublicKey32

Source§

fn clone(&self) -> LwePublicKey32

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LwePublicKey32

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl EntityDeserializationEngine<&[u8], LwePublicKey32> for DefaultSerializationEngine

§Description:

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

Source§

fn deserialize( &mut self, serialized: &[u8], ) -> Result<LwePublicKey32, EntityDeserializationError<Self::EngineError>>

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

unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LwePublicKey32

Unsafely deserializes an entity. Read more
Source§

impl EntitySerializationEngine<LwePublicKey32, Vec<u8>> for DefaultSerializationEngine

§Description:

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

Source§

fn serialize( &mut self, entity: &LwePublicKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>

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

unsafe fn serialize_unchecked(&mut self, entity: &LwePublicKey32) -> Vec<u8>

Unsafely serializes an entity. Read more
Source§

impl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

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

Source§

fn discard_encrypt_lwe_ciphertext_with_public_key( &mut self, key: &LwePublicKey32, output: &mut LweCiphertext32, input: &Plaintext32, ) -> Result<(), LweCiphertextDiscardingPublicKeyEncryptionError<Self::EngineError>>

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

unsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked( &mut self, key: &LwePublicKey32, output: &mut LweCiphertext32, input: &Plaintext32, )

Unsafely encrypts an LWE ciphertext using a public key. Read more
Source§

impl LwePublicKeyEntity for LwePublicKey32

Source§

fn lwe_dimension(&self) -> LweDimension

Returns the LWE dimension of the key.
Source§

fn lwe_zero_encryption_count(&self) -> LwePublicKeyZeroEncryptionCount

Returns the number of LWE encryption of 0 in the key.
Source§

impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultEngine

§Description:

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

Source§

fn generate_new_lwe_public_key( &mut self, lwe_secret_key: &LweSecretKey32, noise: Variance, lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount, ) -> Result<LwePublicKey32, LwePublicKeyGenerationError<Self::EngineError>>

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

unsafe fn generate_new_lwe_public_key_unchecked( &mut self, lwe_secret_key: &LweSecretKey32, noise: Variance, lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount, ) -> LwePublicKey32

Unsafely generates a new LWE public key. Read more
Source§

impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultParallelEngine

§Description:

Implementation of LwePublicKeyGenerationEngine for DefaultParallelEngine that operates on 32 bits integers.

Source§

fn generate_new_lwe_public_key( &mut self, lwe_secret_key: &LweSecretKey32, noise: Variance, lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount, ) -> Result<LwePublicKey32, LwePublicKeyGenerationError<Self::EngineError>>

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

unsafe fn generate_new_lwe_public_key_unchecked( &mut self, lwe_secret_key: &LweSecretKey32, noise: Variance, lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount, ) -> LwePublicKey32

Unsafely generates a new LWE public key. Read more
Source§

impl PartialEq for LwePublicKey32

Source§

fn eq(&self, other: &LwePublicKey32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LwePublicKey32

Source§

impl StructuralPartialEq for LwePublicKey32

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.