Struct concrete_core::backends::default::entities::LwePublicKey32
source · [−]pub struct LwePublicKey32(_);
Expand description
A structure representing an LWE secret key with 32 bits of precision.
Trait Implementations
sourceimpl AbstractEntity for LwePublicKey32
impl AbstractEntity for LwePublicKey32
type Kind = LwePublicKeyKind
type Kind = LwePublicKeyKind
The kind of the entity.
sourceimpl Clone for LwePublicKey32
impl Clone for LwePublicKey32
sourcefn clone(&self) -> LwePublicKey32
fn clone(&self) -> LwePublicKey32
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for LwePublicKey32
impl Debug for LwePublicKey32
sourceimpl EntityDeserializationEngine<&[u8], LwePublicKey32> for DefaultSerializationEngine
impl EntityDeserializationEngine<&[u8], LwePublicKey32> for DefaultSerializationEngine
Description:
Implementation of EntityDeserializationEngine
for DefaultSerializationEngine
that
operates on 32 bits integers. It deserializes an LWE public key.
sourcefn deserialize(
&mut self,
serialized: &[u8]
) -> Result<LwePublicKey32, EntityDeserializationError<Self::EngineError>>
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);
sourceunsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LwePublicKey32
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LwePublicKey32
Unsafely deserializes an entity. Read more
sourceimpl EntitySerializationEngine<LwePublicKey32, Vec<u8, Global>> for DefaultSerializationEngine
impl EntitySerializationEngine<LwePublicKey32, Vec<u8, Global>> for DefaultSerializationEngine
Description:
Implementation of EntitySerializationEngine
for DefaultSerializationEngine
that operates
on 32 bits integers. It serializes an LWE public key.
sourcefn serialize(
&mut self,
entity: &LwePublicKey32
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
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);
sourceunsafe fn serialize_unchecked(&mut self, entity: &LwePublicKey32) -> Vec<u8>
unsafe fn serialize_unchecked(&mut self, entity: &LwePublicKey32) -> Vec<u8>
Unsafely serializes an entity. Read more
sourceimpl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn discard_encrypt_lwe_ciphertext_with_public_key(
&mut self,
key: &LwePublicKey32,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextDiscardingPublicKeyEncryptionError<Self::EngineError>>
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);
sourceunsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked(
&mut self,
key: &LwePublicKey32,
output: &mut LweCiphertext32,
input: &Plaintext32
)
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
sourceimpl LwePublicKeyEntity for LwePublicKey32
impl LwePublicKeyEntity for LwePublicKey32
sourcefn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
Returns the LWE dimension of the key.
sourcefn lwe_zero_encryption_count(&self) -> LwePublicKeyZeroEncryptionCount
fn lwe_zero_encryption_count(&self) -> LwePublicKeyZeroEncryptionCount
Returns the number of LWE encryption of 0 in the key.
sourceimpl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultEngine
impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultEngine
Description:
Implementation of LwePublicKeyGenerationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn 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>>
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
);
sourceunsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey32
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
sourceimpl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultParallelEngine
impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultParallelEngine
Description:
Implementation of LwePublicKeyGenerationEngine
for DefaultParallelEngine
that operates
on 32 bits integers.
sourcefn 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>>
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
);
sourceunsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey32
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
sourceimpl PartialEq<LwePublicKey32> for LwePublicKey32
impl PartialEq<LwePublicKey32> for LwePublicKey32
sourcefn eq(&self, other: &LwePublicKey32) -> bool
fn eq(&self, other: &LwePublicKey32) -> bool
impl Eq for LwePublicKey32
impl StructuralEq for LwePublicKey32
impl StructuralPartialEq for LwePublicKey32
Auto Trait Implementations
impl RefUnwindSafe for LwePublicKey32
impl Send for LwePublicKey32
impl Sync for LwePublicKey32
impl Unpin for LwePublicKey32
impl UnwindSafe for LwePublicKey32
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more