pub struct FftSerializationEngine;backend_fft and backend_fft_serialization only.Expand description
The serialization engine exposed by the fft backend.
Trait Implementations§
Source§impl AbstractEngine for FftSerializationEngine
impl AbstractEngine for FftSerializationEngine
Source§type EngineError = FftSerializationError
type EngineError = FftSerializationError
Source§type Parameters = ()
type Parameters = ()
Source§fn new(_parameters: Self::Parameters) -> Result<Self, Self::EngineError>
fn new(_parameters: Self::Parameters) -> Result<Self, Self::EngineError>
Source§impl EntityDeserializationEngine<&[u8], FftFourierGgswCiphertext32> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 32 bits integers. It deserializes a GGSW ciphertext in the Fourier domain.
impl EntityDeserializationEngine<&[u8], FftFourierGgswCiphertext32> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 32 bits integers. It deserializes a GGSW ciphertext in the Fourier domain.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<FftFourierGgswCiphertext32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<FftFourierGgswCiphertext32, 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 glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(256);
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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let key: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
// We encrypt a GGSW ciphertext in the standard domain
let ciphertext =
default_engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
// Then we convert it to the Fourier domain.
let fourier_ciphertext: FftFourierGgswCiphertext32 =
fft_engine.convert_ggsw_ciphertext(&ciphertext)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_ciphertext, recovered);Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> FftFourierGgswCiphertext32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> FftFourierGgswCiphertext32
Source§impl EntityDeserializationEngine<&[u8], FftFourierGgswCiphertext64> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 64 bits integers. It deserializes a GGSW ciphertext in the Fourier domain.
impl EntityDeserializationEngine<&[u8], FftFourierGgswCiphertext64> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 64 bits integers. It deserializes a GGSW ciphertext in the Fourier domain.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<FftFourierGgswCiphertext64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<FftFourierGgswCiphertext64, 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 glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(256);
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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let key: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
// We encrypt a GGSW ciphertext in the standard domain
let ciphertext =
default_engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
// Then we convert it to the Fourier domain.
let fourier_ciphertext: FftFourierGgswCiphertext64 =
fft_engine.convert_ggsw_ciphertext(&ciphertext)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_ciphertext, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> FftFourierGgswCiphertext64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> FftFourierGgswCiphertext64
Source§impl EntityDeserializationEngine<&[u8], FftFourierLweBootstrapKey32> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 32 bits integers. It deserializes an LWE bootstrap key in the Fourier domain.
impl EntityDeserializationEngine<&[u8], FftFourierLweBootstrapKey32> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 32 bits integers. It deserializes an LWE bootstrap key in the Fourier domain.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<FftFourierLweBootstrapKey32, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<FftFourierLweBootstrapKey32, 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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FftFourierLweBootstrapKey32 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_bsk, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> FftFourierLweBootstrapKey32
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> FftFourierLweBootstrapKey32
Source§impl EntityDeserializationEngine<&[u8], FftFourierLweBootstrapKey64> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 64 bits integers. It deserializes an LWE bootstrap key in the Fourier domain.
impl EntityDeserializationEngine<&[u8], FftFourierLweBootstrapKey64> for FftSerializationEngine
§Description:
Implementation of EntityDeserializationEngine for FftSerializationEngine that operates
on 64 bits integers. It deserializes an LWE bootstrap key in the Fourier domain.
Source§fn deserialize(
&mut self,
serialized: &[u8],
) -> Result<FftFourierLweBootstrapKey64, EntityDeserializationError<Self::EngineError>>
fn deserialize( &mut self, serialized: &[u8], ) -> Result<FftFourierLweBootstrapKey64, 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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FftFourierLweBootstrapKey64 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_bsk, recovered);
Source§unsafe fn deserialize_unchecked(
&mut self,
serialized: &[u8],
) -> FftFourierLweBootstrapKey64
unsafe fn deserialize_unchecked( &mut self, serialized: &[u8], ) -> FftFourierLweBootstrapKey64
Source§impl EntitySerializationEngine<FftFourierGgswCiphertext32, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
32 bits integers. It serializes a GGSW ciphertext in the Fourier domain.
impl EntitySerializationEngine<FftFourierGgswCiphertext32, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
32 bits integers. It serializes a GGSW ciphertext in the Fourier domain.
Source§fn serialize(
&mut self,
entity: &FftFourierGgswCiphertext32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &FftFourierGgswCiphertext32, ) -> 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 glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(256);
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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let key: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
// We encrypt a GGSW ciphertext in the standard domain
let ciphertext =
default_engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
// Then we convert it to the Fourier domain.
let fourier_ciphertext: FftFourierGgswCiphertext32 =
fft_engine.convert_ggsw_ciphertext(&ciphertext)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_ciphertext, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &FftFourierGgswCiphertext32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &FftFourierGgswCiphertext32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<FftFourierGgswCiphertext64, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
64 bits integers. It serializes a GGSW ciphertext in the Fourier domain.
impl EntitySerializationEngine<FftFourierGgswCiphertext64, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
64 bits integers. It serializes a GGSW ciphertext in the Fourier domain.
Source§fn serialize(
&mut self,
entity: &FftFourierGgswCiphertext64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &FftFourierGgswCiphertext64, ) -> 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 glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(256);
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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let key: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = default_engine.create_plaintext_from(&input)?;
// We encrypt a GGSW ciphertext in the standard domain
let ciphertext =
default_engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
// Then we convert it to the Fourier domain.
let fourier_ciphertext: FftFourierGgswCiphertext64 =
fft_engine.convert_ggsw_ciphertext(&ciphertext)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_ciphertext)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_ciphertext, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &FftFourierGgswCiphertext64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &FftFourierGgswCiphertext64, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<FftFourierLweBootstrapKey32, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
32 bits integers. It serializes an LWE bootstrap key in the Fourier domain.
impl EntitySerializationEngine<FftFourierLweBootstrapKey32, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
32 bits integers. It serializes an LWE bootstrap key in the Fourier domain.
Source§fn serialize(
&mut self,
entity: &FftFourierLweBootstrapKey32,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &FftFourierLweBootstrapKey32, ) -> 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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FftFourierLweBootstrapKey32 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_bsk, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &FftFourierLweBootstrapKey32,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &FftFourierLweBootstrapKey32, ) -> Vec<u8> ⓘ
Source§impl EntitySerializationEngine<FftFourierLweBootstrapKey64, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
64 bits integers. It serializes an LWE bootstrap key in the Fourier domain.
impl EntitySerializationEngine<FftFourierLweBootstrapKey64, Vec<u8>> for FftSerializationEngine
§Description:
Implementation of EntitySerializationEngine for FftSerializationEngine that operates on
64 bits integers. It serializes an LWE bootstrap key in the Fourier domain.
Source§fn serialize(
&mut self,
entity: &FftFourierLweBootstrapKey64,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
fn serialize( &mut self, entity: &FftFourierLweBootstrapKey64, ) -> 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 default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let fourier_bsk: FftFourierLweBootstrapKey64 = fft_engine.convert_lwe_bootstrap_key(&bsk)?;
let mut serialization_engine = FftSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&fourier_bsk)?;
let recovered = serialization_engine.deserialize(serialized.as_slice())?;
assert_eq!(fourier_bsk, recovered);
Source§unsafe fn serialize_unchecked(
&mut self,
entity: &FftFourierLweBootstrapKey64,
) -> Vec<u8> ⓘ
unsafe fn serialize_unchecked( &mut self, entity: &FftFourierLweBootstrapKey64, ) -> Vec<u8> ⓘ
Auto Trait Implementations§
impl Freeze for FftSerializationEngine
impl RefUnwindSafe for FftSerializationEngine
impl Send for FftSerializationEngine
impl Sync for FftSerializationEngine
impl Unpin for FftSerializationEngine
impl UnsafeUnpin for FftSerializationEngine
impl UnwindSafe for FftSerializationEngine
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