pub struct DefaultSerializationEngine;Trait Implementations§
Source§impl AbstractEngine for DefaultSerializationEngine
impl AbstractEngine for DefaultSerializationEngine
Source§type EngineError = DefaultSerializationError
type EngineError = DefaultSerializationError
Source§type Parameters = ()
type Parameters = ()
Source§fn new(_parameter: Self::Parameters) -> Result<Self, Self::EngineError>where
Self: Sized,
fn new(_parameter: Self::Parameters) -> Result<Self, Self::EngineError>where
Self: Sized,
Source§impl EntityDeserializationEngine<&[u8], Cleartext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a cleartext entity.
impl EntityDeserializationEngine<&[u8], Cleartext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a cleartext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<Cleartext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<Cleartext32, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext, recovered);Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Cleartext32
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Cleartext32
Source§impl EntityDeserializationEngine<&[u8], Cleartext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a cleartext entity.
impl EntityDeserializationEngine<&[u8], Cleartext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a cleartext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<Cleartext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<Cleartext64, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext, recovered);Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Cleartext64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Cleartext64
Source§impl EntityDeserializationEngine<&[u8], CleartextF64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a floating point cleartext entity.
impl EntityDeserializationEngine<&[u8], CleartextF64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a floating point cleartext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<CleartextF64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<CleartextF64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext, recovered);Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> CleartextF64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> CleartextF64
Source§impl EntityDeserializationEngine<&[u8], CleartextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a cleartext vector entity.
impl EntityDeserializationEngine<&[u8], CleartextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a cleartext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<CleartextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<CleartextVector32, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext_vector, recovered);Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> CleartextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> CleartextVector32
Source§impl EntityDeserializationEngine<&[u8], CleartextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a cleartext vector entity.
impl EntityDeserializationEngine<&[u8], CleartextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a cleartext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<CleartextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<CleartextVector64, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext_vector, recovered);Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> CleartextVector64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> CleartextVector64
Source§impl EntityDeserializationEngine<&[u8], CleartextVectorF64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a floating point cleartext vector entity.
impl EntityDeserializationEngine<&[u8], CleartextVectorF64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a floating point cleartext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<CleartextVectorF64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<CleartextVectorF64, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext_vector, recovered);Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> CleartextVectorF64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> CleartextVectorF64
Source§impl EntityDeserializationEngine<&[u8], FloatEncoder> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a float encoder entity.
impl EntityDeserializationEngine<&[u8], FloatEncoder> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a float encoder entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<FloatEncoder, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<FloatEncoder, EntityDeserializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{PlaintextCount, *};
// Unix seeder must be given a secret input.
// Here we just 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&encoder)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(encoder, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> FloatEncoder
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> FloatEncoder
Source§impl EntityDeserializationEngine<&[u8], FloatEncoderVector> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a float encoder vector entity.
impl EntityDeserializationEngine<&[u8], FloatEncoderVector> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a float encoder vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<FloatEncoderVector, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<FloatEncoderVector, EntityDeserializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::PlaintextCount;
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
])?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&encoder_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(encoder_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> FloatEncoderVector
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> FloatEncoderVector
Source§impl EntityDeserializationEngine<&[u8], GgswCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GGSW ciphertext entity.
impl EntityDeserializationEngine<&[u8], GgswCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GGSW ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GgswCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GgswCiphertext32, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GgswCiphertext32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GgswCiphertext32
Source§impl EntityDeserializationEngine<&[u8], GgswCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GGSW ciphertext entity.
impl EntityDeserializationEngine<&[u8], GgswCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GGSW ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GgswCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GgswCiphertext64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GgswCiphertext64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GgswCiphertext64
Source§impl EntityDeserializationEngine<&[u8], GgswSeededCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded GGSW ciphertext entity.
impl EntityDeserializationEngine<&[u8], GgswSeededCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded GGSW ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GgswSeededCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GgswSeededCiphertext32, EntityDeserializationError<Self::EngineError>>
TODO
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GgswSeededCiphertext32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GgswSeededCiphertext32
Source§impl EntityDeserializationEngine<&[u8], GgswSeededCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded GGSW ciphertext entity.
impl EntityDeserializationEngine<&[u8], GgswSeededCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded GGSW ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GgswSeededCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GgswSeededCiphertext64, EntityDeserializationError<Self::EngineError>>
TODO
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GgswSeededCiphertext64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GgswSeededCiphertext64
Source§impl EntityDeserializationEngine<&[u8], GlweCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE ciphertext entity.
impl EntityDeserializationEngine<&[u8], GlweCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweCiphertext32, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweCiphertext32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweCiphertext32
Source§impl EntityDeserializationEngine<&[u8], GlweCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE ciphertext entity.
impl EntityDeserializationEngine<&[u8], GlweCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweCiphertext64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweCiphertext64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweCiphertext64
Source§impl EntityDeserializationEngine<&[u8], GlweCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], GlweCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweCiphertextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweCiphertextVector32, EntityDeserializationError<Self::EngineError>>
§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(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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweCiphertextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweCiphertextVector32
Source§impl EntityDeserializationEngine<&[u8], GlweCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], GlweCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweCiphertextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweCiphertextVector64, EntityDeserializationError<Self::EngineError>>
§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(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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweCiphertextVector64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweCiphertextVector64
Source§impl EntityDeserializationEngine<&[u8], GlweSecretKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE secret key entity.
impl EntityDeserializationEngine<&[u8], GlweSecretKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE secret key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweSecretKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweSecretKey32, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&glwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(glwe_secret_key, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> GlweSecretKey32
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> GlweSecretKey32
Source§impl EntityDeserializationEngine<&[u8], GlweSecretKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE secret key entity.
impl EntityDeserializationEngine<&[u8], GlweSecretKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE secret key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweSecretKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweSecretKey64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&glwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(glwe_secret_key, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> GlweSecretKey64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> GlweSecretKey64
Source§impl EntityDeserializationEngine<&[u8], GlweSeededCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE seeded ciphertext entity.
impl EntityDeserializationEngine<&[u8], GlweSeededCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE seeded ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweSeededCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweSeededCiphertext32, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweSeededCiphertext32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweSeededCiphertext32
Source§impl EntityDeserializationEngine<&[u8], GlweSeededCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE seeded ciphertext entity.
impl EntityDeserializationEngine<&[u8], GlweSeededCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE seeded ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweSeededCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweSeededCiphertext64, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweSeededCiphertext64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweSeededCiphertext64
Source§impl EntityDeserializationEngine<&[u8], GlweSeededCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE seeded ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], GlweSeededCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a GLWE seeded ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweSeededCiphertextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweSeededCiphertextVector32, EntityDeserializationError<Self::EngineError>>
§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(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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweSeededCiphertextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweSeededCiphertextVector32
Source§impl EntityDeserializationEngine<&[u8], GlweSeededCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE seeded ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], GlweSeededCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a GLWE seeded ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<GlweSeededCiphertextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<GlweSeededCiphertextVector64, EntityDeserializationError<Self::EngineError>>
§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(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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> GlweSeededCiphertextVector64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> GlweSeededCiphertextVector64
Source§impl EntityDeserializationEngine<&[u8], LweBootstrapKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE bootstrap key entity.
impl EntityDeserializationEngine<&[u8], LweBootstrapKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE bootstrap key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweBootstrapKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweBootstrapKey32, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweBootstrapKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweBootstrapKey32
Source§impl EntityDeserializationEngine<&[u8], LweBootstrapKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE bootstrap key entity.
impl EntityDeserializationEngine<&[u8], LweBootstrapKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE bootstrap key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweBootstrapKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweBootstrapKey64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweBootstrapKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweBootstrapKey64
Source§impl EntityDeserializationEngine<&[u8], LweCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE ciphertext entity.
impl EntityDeserializationEngine<&[u8], LweCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCiphertext32, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweCiphertext32
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweCiphertext32
Source§impl EntityDeserializationEngine<&[u8], LweCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE ciphertext entity.
impl EntityDeserializationEngine<&[u8], LweCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCiphertext64, EntityDeserializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweCiphertext64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweCiphertext64
Source§impl EntityDeserializationEngine<&[u8], LweCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], LweCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCiphertextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCiphertextVector32, EntityDeserializationError<Self::EngineError>>
§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 ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweCiphertextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweCiphertextVector32
Source§impl EntityDeserializationEngine<&[u8], LweCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], LweCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCiphertextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCiphertextVector64, EntityDeserializationError<Self::EngineError>>
§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 ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweCiphertextVector64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweCiphertextVector64
Source§impl EntityDeserializationEngine<&[u8], LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes an LWE circuit bootstrap private functional
packing keyswitch vector.
impl EntityDeserializationEngine<&[u8], LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes an LWE circuit bootstrap private functional
packing keyswitch vector.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, EntityDeserializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, FunctionalPackingKeyswitchKeyCount,
GlweDimension, LweDimension, Variance, *,
};
// 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,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized =
serialization_engine.serialize(&cbs_private_functional_packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cbs_private_functional_packing_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32
Source§impl EntityDeserializationEngine<&[u8], LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes an LWE circuit bootstrap private functional
packing keyswitch vector.
impl EntityDeserializationEngine<&[u8], LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes an LWE circuit bootstrap private functional
packing keyswitch vector.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, EntityDeserializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, FunctionalPackingKeyswitchKeyCount,
GlweDimension, LweDimension, Variance, *,
};
// 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,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized =
serialization_engine.serialize(&cbs_private_functional_packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cbs_private_functional_packing_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64
Source§impl EntityDeserializationEngine<&[u8], LweKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LweKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweKeyswitchKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweKeyswitchKey32
Source§impl EntityDeserializationEngine<&[u8], LweKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LweKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweKeyswitchKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweKeyswitchKey64
Source§impl EntityDeserializationEngine<&[u8], LwePackingKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It serializes a packing keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LwePackingKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It serializes a packing keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LwePackingKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LwePackingKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 packing_keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(packing_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LwePackingKeyswitchKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LwePackingKeyswitchKey32
Source§impl EntityDeserializationEngine<&[u8], LwePackingKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a packing keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LwePackingKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a packing keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LwePackingKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LwePackingKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 packing_keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(packing_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LwePackingKeyswitchKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LwePackingKeyswitchKey64
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.
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>>
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
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LwePublicKey32
Source§impl EntityDeserializationEngine<&[u8], LwePublicKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes an LWE public key.
impl EntityDeserializationEngine<&[u8], LwePublicKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes an LWE public key.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LwePublicKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LwePublicKey64, 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: 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,
)?;
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]) -> LwePublicKey64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LwePublicKey64
Source§impl EntityDeserializationEngine<&[u8], LweSecretKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE secret key entity.
impl EntityDeserializationEngine<&[u8], LweSecretKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a LWE secret key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSecretKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSecretKey32, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&lwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(lwe_secret_key, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweSecretKey32
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweSecretKey32
Source§impl EntityDeserializationEngine<&[u8], LweSecretKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE secret key entity.
impl EntityDeserializationEngine<&[u8], LweSecretKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a LWE secret key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSecretKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSecretKey64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&lwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(lwe_secret_key, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweSecretKey64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> LweSecretKey64
Source§impl EntityDeserializationEngine<&[u8], LweSeededBootstrapKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE bootstrap key entity.
impl EntityDeserializationEngine<&[u8], LweSeededBootstrapKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE bootstrap key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededBootstrapKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededBootstrapKey32, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededBootstrapKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededBootstrapKey32
Source§impl EntityDeserializationEngine<&[u8], LweSeededBootstrapKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE bootstrap key entity.
impl EntityDeserializationEngine<&[u8], LweSeededBootstrapKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE bootstrap key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededBootstrapKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededBootstrapKey64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededBootstrapKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededBootstrapKey64
Source§impl EntityDeserializationEngine<&[u8], LweSeededCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE ciphertext entity.
impl EntityDeserializationEngine<&[u8], LweSeededCiphertext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededCiphertext32, EntityDeserializationError<Self::EngineError>>
§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: LweSeededCiphertext32 =
engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededCiphertext32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededCiphertext32
Source§impl EntityDeserializationEngine<&[u8], LweSeededCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE ciphertext entity.
impl EntityDeserializationEngine<&[u8], LweSeededCiphertext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE ciphertext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededCiphertext64, EntityDeserializationError<Self::EngineError>>
§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: LweSeededCiphertext64 =
engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededCiphertext64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededCiphertext64
Source§impl EntityDeserializationEngine<&[u8], LweSeededCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], LweSeededCiphertextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededCiphertextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededCiphertextVector32, EntityDeserializationError<Self::EngineError>>
§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 ciphertext_vector: LweSeededCiphertextVector32 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededCiphertextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededCiphertextVector32
Source§impl EntityDeserializationEngine<&[u8], LweSeededCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE ciphertext vector entity.
impl EntityDeserializationEngine<&[u8], LweSeededCiphertextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE ciphertext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededCiphertextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededCiphertextVector64, EntityDeserializationError<Self::EngineError>>
§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 ciphertext_vector: LweSeededCiphertextVector64 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededCiphertextVector64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededCiphertextVector64
Source§impl EntityDeserializationEngine<&[u8], LweSeededKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE ciphertext keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LweSeededKeyswitchKey32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a seeded LWE ciphertext keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededKeyswitchKey32, EntityDeserializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededKeyswitchKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededKeyswitchKey32
Source§impl EntityDeserializationEngine<&[u8], LweSeededKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE ciphertext keyswitch key entity.
impl EntityDeserializationEngine<&[u8], LweSeededKeyswitchKey64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a seeded LWE ciphertext keyswitch key entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<LweSeededKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<LweSeededKeyswitchKey64, EntityDeserializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_keyswitch_key, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> LweSeededKeyswitchKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> LweSeededKeyswitchKey64
Source§impl EntityDeserializationEngine<&[u8], Plaintext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a plaintext entity.
impl EntityDeserializationEngine<&[u8], Plaintext32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a plaintext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<Plaintext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<Plaintext32, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext, recovered);
Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Plaintext32
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Plaintext32
Source§impl EntityDeserializationEngine<&[u8], Plaintext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a plaintext entity.
impl EntityDeserializationEngine<&[u8], Plaintext64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a plaintext entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<Plaintext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<Plaintext64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext, recovered);Source§unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Plaintext64
unsafe fn deserialize_unchecked(&mut self, serialized: &[u8]) -> Plaintext64
Source§impl EntityDeserializationEngine<&[u8], PlaintextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a plaintext vector entity.
impl EntityDeserializationEngine<&[u8], PlaintextVector32> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 32 bits integers. It deserializes a plaintext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<PlaintextVector32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<PlaintextVector32, EntityDeserializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> PlaintextVector32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> PlaintextVector32
Source§impl EntityDeserializationEngine<&[u8], PlaintextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a plaintext vector entity.
impl EntityDeserializationEngine<&[u8], PlaintextVector64> for DefaultSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for DefaultSerializationEngine that
operates on 64 bits integers. It deserializes a plaintext vector entity.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<PlaintextVector64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<PlaintextVector64, EntityDeserializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext_vector, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> PlaintextVector64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> PlaintextVector64
Source§impl EntitySerializationEngine<Cleartext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a cleartext entity.
impl EntitySerializationEngine<Cleartext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a cleartext entity.
Source§fn serialize(
&mut self,
entity: &Cleartext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &Cleartext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &Cleartext32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &Cleartext32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<Cleartext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a cleartext entity.
impl EntitySerializationEngine<Cleartext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a cleartext entity.
Source§fn serialize(
&mut self,
entity: &Cleartext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &Cleartext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &Cleartext64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &Cleartext64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<CleartextF64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a floating point cleartext.
impl EntitySerializationEngine<CleartextF64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a floating point cleartext.
Source§fn serialize(
&mut self,
entity: &CleartextF64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &CleartextF64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &CleartextF64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &CleartextF64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<CleartextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a cleartext vector entity.
impl EntitySerializationEngine<CleartextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a cleartext vector entity.
Source§fn serialize(
&mut self,
entity: &CleartextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &CleartextVector32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext_vector, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &CleartextVector32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &CleartextVector32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<CleartextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a cleartext vector entity.
impl EntitySerializationEngine<CleartextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a cleartext vector entity.
Source§fn serialize(
&mut self,
entity: &CleartextVector64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &CleartextVector64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext_vector, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &CleartextVector64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &CleartextVector64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<CleartextVectorF64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a floating point cleartext vector entity.
impl EntitySerializationEngine<CleartextVectorF64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a floating point cleartext vector entity.
Source§fn serialize(
&mut self,
entity: &CleartextVectorF64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &CleartextVectorF64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&cleartext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cleartext_vector, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &CleartextVectorF64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &CleartextVectorF64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<FloatEncoder, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a float encoder entity.
impl EntitySerializationEngine<FloatEncoder, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a float encoder entity.
Source§fn serialize(
&mut self,
entity: &FloatEncoder,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &FloatEncoder, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{PlaintextCount, *};
// Unix seeder must be given a secret input.
// Here we just 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&encoder)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(encoder, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &FloatEncoder) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &FloatEncoder) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<FloatEncoderVector, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a float encoder vector entity.
impl EntitySerializationEngine<FloatEncoderVector, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a float encoder vector entity.
Source§fn serialize(
&mut self,
entity: &FloatEncoderVector,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &FloatEncoderVector, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::PlaintextCount;
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
])?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&encoder_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(encoder_vector, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &FloatEncoderVector) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &FloatEncoderVector) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GgswCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GGSW ciphertext entity.
impl EntitySerializationEngine<GgswCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GGSW ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GgswCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GgswCiphertext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &GgswCiphertext32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &GgswCiphertext32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GgswCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GGSW ciphertext entity.
impl EntitySerializationEngine<GgswCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GGSW ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GgswCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GgswCiphertext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &GgswCiphertext64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &GgswCiphertext64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GgswSeededCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded GGSW ciphertext entity.
impl EntitySerializationEngine<GgswSeededCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded GGSW ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GgswSeededCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GgswSeededCiphertext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
TODO
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GgswSeededCiphertext32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GgswSeededCiphertext32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GgswSeededCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded GGSW ciphertext entity.
impl EntitySerializationEngine<GgswSeededCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded GGSW ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GgswSeededCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GgswSeededCiphertext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
TODO
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GgswSeededCiphertext64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GgswSeededCiphertext64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext entity.
impl EntitySerializationEngine<GlweCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &GlweCiphertext32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &GlweCiphertext32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext entity.
impl EntitySerializationEngine<GlweCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &GlweCiphertext64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &GlweCiphertext64) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext mut view entity.
impl<'b> EntitySerializationEngine<GlweCiphertextMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext mut view entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextMutView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextMutView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut raw_buffer = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
let view: GlweCiphertextMutView32 =
engine.create_glwe_ciphertext_from(raw_buffer.as_mut_slice(), polynomial_size)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertext32 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextMutView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextMutView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext mut view entity.
impl<'b> EntitySerializationEngine<GlweCiphertextMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext mut view entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextMutView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextMutView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut raw_buffer = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
let view: GlweCiphertextMutView64 =
engine.create_glwe_ciphertext_from(raw_buffer.as_mut_slice(), polynomial_size)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertext64 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextMutView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextMutView64<'b>, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext vector entity.
impl EntitySerializationEngine<GlweCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextVector32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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(4);
let glwe_count = GlweCiphertextCount(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input =
vec![3_u32 << 20; glwe_dimension.to_glwe_size().0 * polynomial_size.0 * glwe_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: 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextVector32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextVector32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext vector entity.
impl EntitySerializationEngine<GlweCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextVector64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextVector64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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(4);
let glwe_count = GlweCiphertextCount(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input =
vec![3_u64 << 50; glwe_dimension.to_glwe_size().0 * polynomial_size.0 * glwe_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: 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextVector64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextVector64, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextVectorMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext vector view entity. Mutable version.
impl<'b> EntitySerializationEngine<GlweCiphertextVectorMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext vector view entity. Mutable version.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextVectorMutView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextVectorMutView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
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);
let glwe_count = GlweCiphertextCount(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input =
vec![3_u32 << 20; glwe_dimension.to_glwe_size().0 * polynomial_size.0 * glwe_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: 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 mut raw_buffer = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
let view: GlweCiphertextVectorMutView32 = engine.create_glwe_ciphertext_vector_from(
raw_buffer.as_mut_slice(),
glwe_dimension,
polynomial_size,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertextVector32 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextVectorMutView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextVectorMutView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextVectorMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext vector view entity. Mutable version.
impl<'b> EntitySerializationEngine<GlweCiphertextVectorMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext vector view entity. Mutable version.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextVectorMutView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextVectorMutView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
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);
let glwe_count = GlweCiphertextCount(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input =
vec![3_u64 << 50; glwe_dimension.to_glwe_size().0 * polynomial_size.0 * glwe_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: 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 mut raw_buffer = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
let view: GlweCiphertextVectorMutView64 = engine.create_glwe_ciphertext_vector_from(
raw_buffer.as_mut_slice(),
glwe_dimension,
polynomial_size,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertextVector64 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextVectorMutView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextVectorMutView64<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextVectorView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext vector view entity.
impl<'b> EntitySerializationEngine<GlweCiphertextVectorView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext vector view entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextVectorView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextVectorView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
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);
let glwe_count = GlweCiphertextCount(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input =
vec![3_u32 << 20; glwe_dimension.to_glwe_size().0 * polynomial_size.0 * glwe_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: 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 raw_buffer = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
let view: GlweCiphertextVectorView32 = engine.create_glwe_ciphertext_vector_from(
raw_buffer.as_slice(),
glwe_dimension,
polynomial_size,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertextVector32 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextVectorView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextVectorView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextVectorView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext vector view entity.
impl<'b> EntitySerializationEngine<GlweCiphertextVectorView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext vector view entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextVectorView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextVectorView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
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);
let glwe_count = GlweCiphertextCount(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input =
vec![3_u64 << 50; glwe_dimension.to_glwe_size().0 * polynomial_size.0 * glwe_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: 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 raw_buffer = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
let view: GlweCiphertextVectorView64 = engine.create_glwe_ciphertext_vector_from(
raw_buffer.as_slice(),
glwe_dimension,
polynomial_size,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertextVector64 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextVectorView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextVectorView64<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext view entity.
impl<'b> EntitySerializationEngine<GlweCiphertextView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE ciphertext view entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let raw_buffer = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
let view: GlweCiphertextView32 =
engine.create_glwe_ciphertext_from(raw_buffer.as_slice(), polynomial_size)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertext32 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<GlweCiphertextView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext view entity.
impl<'b> EntitySerializationEngine<GlweCiphertextView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE ciphertext view entity.
Source§fn serialize(
&mut self,
entity: &GlweCiphertextView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweCiphertextView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let raw_buffer = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
let view: GlweCiphertextView64 =
engine.create_glwe_ciphertext_from(raw_buffer.as_slice(), polynomial_size)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: GlweCiphertext64 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_glwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweCiphertextView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweCiphertextView64<'b>, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweSecretKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE secret key entity.
impl EntitySerializationEngine<GlweSecretKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a GLWE secret key entity.
Source§fn serialize(
&mut self,
entity: &GlweSecretKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweSecretKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&glwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(glwe_secret_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &GlweSecretKey32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &GlweSecretKey32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweSecretKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE secret key entity.
impl EntitySerializationEngine<GlweSecretKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a GLWE secret key entity.
Source§fn serialize(
&mut self,
entity: &GlweSecretKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweSecretKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&glwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(glwe_secret_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &GlweSecretKey64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &GlweSecretKey64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweSeededCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded GLWE ciphertext entity.
impl EntitySerializationEngine<GlweSeededCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded GLWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GlweSeededCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweSeededCiphertext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweSeededCiphertext32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweSeededCiphertext32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweSeededCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded GLWE ciphertext entity.
impl EntitySerializationEngine<GlweSeededCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded GLWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &GlweSeededCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweSeededCiphertext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweSeededCiphertext64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweSeededCiphertext64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweSeededCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded GLWE ciphertext vector entity.
impl EntitySerializationEngine<GlweSeededCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded GLWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &GlweSeededCiphertextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweSeededCiphertextVector32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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(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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweSeededCiphertextVector32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweSeededCiphertextVector32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<GlweSeededCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded GLWE ciphertext vector entity.
impl EntitySerializationEngine<GlweSeededCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded GLWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &GlweSeededCiphertextVector64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &GlweSeededCiphertextVector64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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(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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &GlweSeededCiphertextVector64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &GlweSeededCiphertextVector64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweBootstrapKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE bootstrap key entity.
impl EntitySerializationEngine<LweBootstrapKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE bootstrap key entity.
Source§fn serialize(
&mut self,
entity: &LweBootstrapKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweBootstrapKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweBootstrapKey32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweBootstrapKey32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweBootstrapKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE bootstrap key entity.
impl EntitySerializationEngine<LweBootstrapKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE bootstrap key entity.
Source§fn serialize(
&mut self,
entity: &LweBootstrapKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweBootstrapKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweBootstrapKey64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweBootstrapKey64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext entity.
impl EntitySerializationEngine<LweCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweCiphertext32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweCiphertext32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext entity.
impl EntitySerializationEngine<LweCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweCiphertext64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweCiphertext64) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext mut view entity.
impl<'b> EntitySerializationEngine<LweCiphertextMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext mut view entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextMutView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextMutView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut raw_buffer = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
let view: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(raw_buffer.as_mut_slice())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertext32 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextMutView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextMutView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext mut view entity.
impl<'b> EntitySerializationEngine<LweCiphertextMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext mut view entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextMutView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextMutView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut raw_buffer = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
let view: LweCiphertextMutView64 = engine.create_lwe_ciphertext_from(raw_buffer.as_mut_slice())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertext64 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextMutView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextMutView64<'b>, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector entity.
impl EntitySerializationEngine<LweCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVector32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVector32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVector32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector entity.
impl EntitySerializationEngine<LweCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVector64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVector64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVector64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVector64, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextVectorMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector view entity. Mutable variant.
impl<'b> EntitySerializationEngine<LweCiphertextVectorMutView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector view entity. Mutable variant.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVectorMutView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVectorMutView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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);
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(-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: 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)?;
let mut raw_buffer = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
let view: LweCiphertextVectorMutView32 = engine.create_lwe_ciphertext_vector_from(
raw_buffer.as_mut_slice(),
lwe_dimension.to_lwe_size(),
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertextVector32 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVectorMutView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVectorMutView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextVectorMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Mutable variant.
impl<'b> EntitySerializationEngine<LweCiphertextVectorMutView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Mutable variant.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVectorMutView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVectorMutView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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);
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 ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut raw_buffer = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
let view: LweCiphertextVectorMutView64 = engine.create_lwe_ciphertext_vector_from(
raw_buffer.as_mut_slice(),
lwe_dimension.to_lwe_size(),
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertextVector64 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVectorMutView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVectorMutView64<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextVectorView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector view entity. Immutable variant.
impl<'b> EntitySerializationEngine<LweCiphertextVectorView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext vector view entity. Immutable variant.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVectorView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVectorView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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);
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(-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: 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)?;
let raw_buffer = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
let view: LweCiphertextVectorView32 = engine
.create_lwe_ciphertext_vector_from(raw_buffer.as_slice(), lwe_dimension.to_lwe_size())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertextVector32 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVectorView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVectorView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextVectorView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Immutable variant.
impl<'b> EntitySerializationEngine<LweCiphertextVectorView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Immutable variant.
Source§fn serialize(
&mut self,
entity: &LweCiphertextVectorView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextVectorView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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);
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 ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let raw_buffer = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
let view: LweCiphertextVectorView64 = engine
.create_lwe_ciphertext_vector_from(raw_buffer.as_slice(), lwe_dimension.to_lwe_size())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertextVector64 =
serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextVectorView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVectorView64<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext view entity.
impl<'b> EntitySerializationEngine<LweCiphertextView32<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE ciphertext view entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextView32<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextView32<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 raw_buffer = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
let view: LweCiphertextView32 = engine.create_lwe_ciphertext_from(raw_buffer.as_slice())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertext32 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextView32<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextView32<'b>, ) -> Vec<u8> ⓘ
Source§impl<'b> EntitySerializationEngine<LweCiphertextView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext view entity.
impl<'b> EntitySerializationEngine<LweCiphertextView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext view entity.
Source§fn serialize(
&mut self,
entity: &LweCiphertextView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCiphertextView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let raw_buffer = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
let view: LweCiphertextView64 = engine.create_lwe_ciphertext_from(raw_buffer.as_slice())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertext64 = serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCiphertextView64<'b>,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextView64<'b>, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes an LWE circuit bootstrap private functional packing keyswitch
vector.
impl EntitySerializationEngine<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes an LWE circuit bootstrap private functional packing keyswitch
vector.
Source§fn serialize(
&mut self,
entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, FunctionalPackingKeyswitchKeyCount,
GlweDimension, LweDimension, Variance, *,
};
// 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,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized =
serialization_engine.serialize(&cbs_private_functional_packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cbs_private_functional_packing_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes an LWE circuit bootstrap private functional packing keyswitch
vector.
impl EntitySerializationEngine<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes an LWE circuit bootstrap private functional packing keyswitch
vector.
Source§fn serialize(
&mut self,
entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, FunctionalPackingKeyswitchKeyCount,
GlweDimension, LweDimension, Variance, *,
};
// 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,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized =
serialization_engine.serialize(&cbs_private_functional_packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(cbs_private_functional_packing_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE keyswitch key entity.
impl EntitySerializationEngine<LweKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LweKeyswitchKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweKeyswitchKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweKeyswitchKey32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweKeyswitchKey32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE keyswitch key entity.
impl EntitySerializationEngine<LweKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LweKeyswitchKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweKeyswitchKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweKeyswitchKey64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweKeyswitchKey64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LwePackingKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a packing keyswitch key entity.
impl EntitySerializationEngine<LwePackingKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a packing keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LwePackingKeyswitchKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LwePackingKeyswitchKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 packing_keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(packing_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LwePackingKeyswitchKey32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LwePackingKeyswitchKey32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LwePackingKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a packing keyswitch key entity.
impl EntitySerializationEngine<LwePackingKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a packing keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LwePackingKeyswitchKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LwePackingKeyswitchKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 packing_keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&packing_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(packing_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LwePackingKeyswitchKey64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LwePackingKeyswitchKey64, ) -> Vec<u8> ⓘ
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.
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>>
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> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LwePublicKey32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LwePublicKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes an LWE public key.
impl EntitySerializationEngine<LwePublicKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes an LWE public key.
Source§fn serialize(
&mut self,
entity: &LwePublicKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LwePublicKey64, ) -> 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: 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,
)?;
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: &LwePublicKey64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LwePublicKey64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSecretKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE secret key entity.
impl EntitySerializationEngine<LweSecretKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a LWE secret key entity.
Source§fn serialize(
&mut self,
entity: &LweSecretKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSecretKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&lwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(lwe_secret_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweSecretKey32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweSecretKey32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSecretKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE secret key entity.
impl EntitySerializationEngine<LweSecretKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE secret key entity.
Source§fn serialize(
&mut self,
entity: &LweSecretKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSecretKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&lwe_secret_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(lwe_secret_key, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &LweSecretKey64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &LweSecretKey64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededBootstrapKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE bootstrap key entity.
impl EntitySerializationEngine<LweSeededBootstrapKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE bootstrap key entity.
Source§fn serialize(
&mut self,
entity: &LweSeededBootstrapKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededBootstrapKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededBootstrapKey32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededBootstrapKey32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededBootstrapKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE bootstrap key entity.
impl EntitySerializationEngine<LweSeededBootstrapKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE bootstrap key entity.
Source§fn serialize(
&mut self,
entity: &LweSeededBootstrapKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededBootstrapKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(bsk, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededBootstrapKey64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededBootstrapKey64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE ciphertext entity.
impl EntitySerializationEngine<LweSeededCiphertext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &LweSeededCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededCiphertext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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: LweSeededCiphertext32 =
engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededCiphertext32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededCiphertext32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE ciphertext entity.
impl EntitySerializationEngine<LweSeededCiphertext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE ciphertext entity.
Source§fn serialize(
&mut self,
entity: &LweSeededCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededCiphertext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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: LweSeededCiphertext64 =
engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededCiphertext64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededCiphertext64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE ciphertext vector entity.
impl EntitySerializationEngine<LweSeededCiphertextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &LweSeededCiphertextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededCiphertextVector32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 ciphertext_vector: LweSeededCiphertextVector32 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededCiphertextVector32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededCiphertextVector32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE ciphertext vector entity.
impl EntitySerializationEngine<LweSeededCiphertextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE ciphertext vector entity.
Source§fn serialize(
&mut self,
entity: &LweSeededCiphertextVector64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededCiphertextVector64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 ciphertext_vector: LweSeededCiphertextVector64 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&ciphertext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(ciphertext_vector, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededCiphertextVector64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededCiphertextVector64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE keyswitch key entity.
impl EntitySerializationEngine<LweSeededKeyswitchKey32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a seeded LWE keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LweSeededKeyswitchKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededKeyswitchKey32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededKeyswitchKey32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededKeyswitchKey32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<LweSeededKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE keyswitch key entity.
impl EntitySerializationEngine<LweSeededKeyswitchKey64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a seeded LWE keyswitch key entity.
Source§fn serialize(
&mut self,
entity: &LweSeededKeyswitchKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &LweSeededKeyswitchKey64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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.));
// Unix seeder must be given a secret input.
// Here we just 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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&seeded_keyswitch_key)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(seeded_keyswitch_key, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &LweSeededKeyswitchKey64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &LweSeededKeyswitchKey64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<Plaintext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a plaintext entity.
impl EntitySerializationEngine<Plaintext32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a plaintext entity.
Source§fn serialize(
&mut self,
entity: &Plaintext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &Plaintext32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &Plaintext32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &Plaintext32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<Plaintext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a plaintext entity.
impl EntitySerializationEngine<Plaintext64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a plaintext entity.
Source§fn serialize(
&mut self,
entity: &Plaintext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &Plaintext64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext, recovered);Source§unsafe fn serialize_unchecked(&mut self, entity: &Plaintext64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &Plaintext64) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<PlaintextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a plaintext vector entity.
impl EntitySerializationEngine<PlaintextVector32, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 32 bits integers. It serializes a plaintext vector entity.
Source§fn serialize(
&mut self,
entity: &PlaintextVector32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &PlaintextVector32, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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 mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext_vector, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &PlaintextVector32) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &PlaintextVector32) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<PlaintextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a plaintext vector entity.
impl EntitySerializationEngine<PlaintextVector64, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a plaintext vector entity.
Source§fn serialize(
&mut self,
entity: &PlaintextVector64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &PlaintextVector64, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§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)?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&plaintext_vector)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(plaintext_vector, recovered);
Source§unsafe fn serialize_unchecked(&mut self, entity: &PlaintextVector64) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked(&mut self, entity: &PlaintextVector64) -> Vec<u8> ⓘ
Auto Trait Implementations§
impl Freeze for DefaultSerializationEngine
impl RefUnwindSafe for DefaultSerializationEngine
impl Send for DefaultSerializationEngine
impl Sync for DefaultSerializationEngine
impl Unpin for DefaultSerializationEngine
impl UnwindSafe for DefaultSerializationEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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