Struct concrete_core::backends::default::engines::DefaultEngine
source · [−]pub struct DefaultEngine { /* private fields */ }
Trait Implementations
sourceimpl AbstractEngine for DefaultEngine
impl AbstractEngine for DefaultEngine
type EngineError = DefaultError
type EngineError = DefaultError
The error associated to the engine.
type Parameters = Box<dyn Seeder + 'static, Global>
type Parameters = Box<dyn Seeder + 'static, Global>
The constructor parameters type.
sourcefn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>
fn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>
A constructor for the engine.
sourceimpl CleartextCreationEngine<f64, CleartextF64> for DefaultEngine
impl CleartextCreationEngine<f64, CleartextF64> for DefaultEngine
Description:
Implementation of CleartextCreationEngine
for DefaultEngine
that operates on 64 bits
floating point numbers.
sourcefn create_cleartext(
&mut self,
value: &f64
) -> Result<CleartextF64, CleartextCreationError<Self::EngineError>>
fn create_cleartext(
&mut self,
value: &f64
) -> Result<CleartextF64, CleartextCreationError<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(&input)?;
engine.destroy(cleartext)?;
sourceunsafe fn create_cleartext_unchecked(&mut self, value: &f64) -> CleartextF64
unsafe fn create_cleartext_unchecked(&mut self, value: &f64) -> CleartextF64
Unsafely creates a cleartext from an arbitrary value. Read more
sourceimpl CleartextCreationEngine<u32, Cleartext32> for DefaultEngine
impl CleartextCreationEngine<u32, Cleartext32> for DefaultEngine
Description:
Implementation of CleartextCreationEngine
for DefaultEngine
that operates on 32 bits
integers.
sourcefn create_cleartext(
&mut self,
input: &u32
) -> Result<Cleartext32, CleartextCreationError<Self::EngineError>>
fn create_cleartext(
&mut self,
input: &u32
) -> Result<Cleartext32, CleartextCreationError<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(&input)?;
engine.destroy(cleartext)?;
sourceunsafe fn create_cleartext_unchecked(&mut self, input: &u32) -> Cleartext32
unsafe fn create_cleartext_unchecked(&mut self, input: &u32) -> Cleartext32
Unsafely creates a cleartext from an arbitrary value. Read more
sourceimpl CleartextCreationEngine<u64, Cleartext64> for DefaultEngine
impl CleartextCreationEngine<u64, Cleartext64> for DefaultEngine
Description:
Implementation of CleartextCreationEngine
for DefaultEngine
that operates on 64 bits
integers.
sourcefn create_cleartext(
&mut self,
input: &u64
) -> Result<Cleartext64, CleartextCreationError<Self::EngineError>>
fn create_cleartext(
&mut self,
input: &u64
) -> Result<Cleartext64, CleartextCreationError<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(&input)?;
engine.destroy(cleartext)?;
sourceunsafe fn create_cleartext_unchecked(&mut self, input: &u64) -> Cleartext64
unsafe fn create_cleartext_unchecked(&mut self, input: &u64) -> Cleartext64
Unsafely creates a cleartext from an arbitrary value. Read more
sourceimpl CleartextDiscardingRetrievalEngine<Cleartext32, u32> for DefaultEngine
impl CleartextDiscardingRetrievalEngine<Cleartext32, u32> for DefaultEngine
Description:
Implementation of CleartextDiscardingRetrievalEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn discard_retrieve_cleartext(
&mut self,
output: &mut u32,
input: &Cleartext32
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext(
&mut self,
output: &mut u32,
input: &Cleartext32
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u32 = 3;
let mut output: u32 = 0;
// 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(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3_u32);
engine.destroy(cleartext)?;
sourceunsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u32,
input: &Cleartext32
)
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u32,
input: &Cleartext32
)
Unsafely retrieves an arbitrary value from a cleartext. Read more
sourceimpl CleartextDiscardingRetrievalEngine<Cleartext64, u64> for DefaultEngine
impl CleartextDiscardingRetrievalEngine<Cleartext64, u64> for DefaultEngine
Description:
Implementation of CleartextDiscardingRetrievalEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn discard_retrieve_cleartext(
&mut self,
output: &mut u64,
input: &Cleartext64
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext(
&mut self,
output: &mut u64,
input: &Cleartext64
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: u64 = 3;
let mut output: u64 = 0;
// 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(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3_u64);
engine.destroy(cleartext)?;
sourceunsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u64,
input: &Cleartext64
)
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut u64,
input: &Cleartext64
)
Unsafely retrieves an arbitrary value from a cleartext. Read more
sourceimpl CleartextDiscardingRetrievalEngine<CleartextF64, f64> for DefaultEngine
impl CleartextDiscardingRetrievalEngine<CleartextF64, f64> for DefaultEngine
Description:
Implementation of CleartextDiscardingRetrievalEngine
for DefaultEngine
that operates on
64 bits floating point numbers.
sourcefn discard_retrieve_cleartext(
&mut self,
output: &mut f64,
input: &CleartextF64
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext(
&mut self,
output: &mut f64,
input: &CleartextF64
) -> Result<(), CleartextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: f64 = 3.;
let mut output: f64 = 0.;
// 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(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3.0);
engine.destroy(cleartext)?;
sourceunsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut f64,
input: &CleartextF64
)
unsafe fn discard_retrieve_cleartext_unchecked(
&mut self,
output: &mut f64,
input: &CleartextF64
)
Unsafely retrieves an arbitrary value from a cleartext. Read more
sourceimpl CleartextEncodingEngine<FloatEncoder, CleartextF64, Plaintext32> for DefaultEngine
impl CleartextEncodingEngine<FloatEncoder, CleartextF64, Plaintext32> for DefaultEngine
Description:
Implementation of CleartextEncodingEngine
for DefaultEngine
that encodes 64 bits
floating point numbers to 32 bits integers.
sourcefn encode_cleartext(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Result<Plaintext32, CleartextEncodingError<Self::EngineError>>
fn encode_cleartext(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Result<Plaintext32, CleartextEncodingError<Self::EngineError>>
Example:
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 = engine.create_encoder(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext(&5.)?;
let plaintext: Plaintext32 = engine.encode_cleartext(&encoder, &cleartext)?;
engine.destroy(encoder)?;
engine.destroy(cleartext)?;
engine.destroy(plaintext)?;
sourceunsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext32
unsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext32
Unsafely encodes a cleartext into a plaintext. Read more
sourceimpl CleartextEncodingEngine<FloatEncoder, CleartextF64, Plaintext64> for DefaultEngine
impl CleartextEncodingEngine<FloatEncoder, CleartextF64, Plaintext64> for DefaultEngine
Description:
Implementation of CleartextEncodingEngine
for DefaultEngine
that encodes 64 bits
floating point numbers to 32 bits integers.
sourcefn encode_cleartext(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Result<Plaintext64, CleartextEncodingError<Self::EngineError>>
fn encode_cleartext(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Result<Plaintext64, CleartextEncodingError<Self::EngineError>>
Example:
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 = engine.create_encoder(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext(&5.)?;
let plaintext: Plaintext64 = engine.encode_cleartext(&encoder, &cleartext)?;
engine.destroy(encoder)?;
engine.destroy(cleartext)?;
engine.destroy(plaintext)?;
sourceunsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext64
unsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext64
Unsafely encodes a cleartext into a plaintext. Read more
sourceimpl CleartextRetrievalEngine<Cleartext32, u32> for DefaultEngine
impl CleartextRetrievalEngine<Cleartext32, u32> for DefaultEngine
Description:
Implementation of CleartextRetrievalEngine
for DefaultEngine
that operates on 32 bits
integers.
sourcefn retrieve_cleartext(
&mut self,
cleartext: &Cleartext32
) -> Result<u32, CleartextRetrievalError<Self::EngineError>>
fn retrieve_cleartext(
&mut self,
cleartext: &Cleartext32
) -> Result<u32, CleartextRetrievalError<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(&input)?;
let output: u32 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3_u32);
engine.destroy(cleartext)?;
sourceunsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext32) -> u32
unsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext32) -> u32
Unsafely retrieves an arbitrary value from a cleartext. Read more
sourceimpl CleartextRetrievalEngine<Cleartext64, u64> for DefaultEngine
impl CleartextRetrievalEngine<Cleartext64, u64> for DefaultEngine
Description:
Implementation of CleartextRetrievalEngine
for DefaultEngine
that operates on 64 bits
integers.
sourcefn retrieve_cleartext(
&mut self,
cleartext: &Cleartext64
) -> Result<u64, CleartextRetrievalError<Self::EngineError>>
fn retrieve_cleartext(
&mut self,
cleartext: &Cleartext64
) -> Result<u64, CleartextRetrievalError<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(&input)?;
let output: u64 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3_u64);
engine.destroy(cleartext)?;
sourceunsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext64) -> u64
unsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext64) -> u64
Unsafely retrieves an arbitrary value from a cleartext. Read more
sourceimpl CleartextRetrievalEngine<CleartextF64, f64> for DefaultEngine
impl CleartextRetrievalEngine<CleartextF64, f64> for DefaultEngine
Description:
Implementation of CleartextRetrievalEngine
for DefaultEngine
that operates on 64 bits
floating point numbers.
sourcefn retrieve_cleartext(
&mut self,
cleartext: &CleartextF64
) -> Result<f64, CleartextRetrievalError<Self::EngineError>>
fn retrieve_cleartext(
&mut self,
cleartext: &CleartextF64
) -> Result<f64, CleartextRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
let input: f64 = 3.0;
// 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(&input)?;
let output: f64 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3.0);
engine.destroy(cleartext)?;
sourceunsafe fn retrieve_cleartext_unchecked(
&mut self,
cleartext: &CleartextF64
) -> f64
unsafe fn retrieve_cleartext_unchecked(
&mut self,
cleartext: &CleartextF64
) -> f64
Unsafely retrieves an arbitrary value from a cleartext. Read more
sourceimpl CleartextVectorCreationEngine<f64, CleartextVectorF64> for DefaultEngine
impl CleartextVectorCreationEngine<f64, CleartextVectorF64> for DefaultEngine
Description:
Implementation of CleartextVectorCreationEngine
for DefaultEngine
that operates on 64
bits floating point numbers.
sourcefn create_cleartext_vector(
&mut self,
values: &[f64]
) -> Result<CleartextVectorF64, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector(
&mut self,
values: &[f64]
) -> Result<CleartextVectorF64, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
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(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
engine.destroy(cleartext_vector)?;
sourceunsafe fn create_cleartext_vector_unchecked(
&mut self,
values: &[f64]
) -> CleartextVectorF64
unsafe fn create_cleartext_vector_unchecked(
&mut self,
values: &[f64]
) -> CleartextVectorF64
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
sourceimpl CleartextVectorCreationEngine<u32, CleartextVector32> for DefaultEngine
impl CleartextVectorCreationEngine<u32, CleartextVector32> for DefaultEngine
Description:
Implementation of CleartextVectorCreationEngine
for DefaultEngine
that operates on 32
bits integers.
sourcefn create_cleartext_vector(
&mut self,
input: &[u32]
) -> Result<CleartextVector32, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector(
&mut self,
input: &[u32]
) -> Result<CleartextVector32, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
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(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
engine.destroy(cleartext_vector)?;
sourceunsafe fn create_cleartext_vector_unchecked(
&mut self,
input: &[u32]
) -> CleartextVector32
unsafe fn create_cleartext_vector_unchecked(
&mut self,
input: &[u32]
) -> CleartextVector32
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
sourceimpl CleartextVectorCreationEngine<u64, CleartextVector64> for DefaultEngine
impl CleartextVectorCreationEngine<u64, CleartextVector64> for DefaultEngine
Description:
Implementation of CleartextVectorCreationEngine
for DefaultEngine
that operates on 64
bits integers.
sourcefn create_cleartext_vector(
&mut self,
input: &[u64]
) -> Result<CleartextVector64, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector(
&mut self,
input: &[u64]
) -> Result<CleartextVector64, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
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(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
engine.destroy(cleartext_vector)?;
sourceunsafe fn create_cleartext_vector_unchecked(
&mut self,
input: &[u64]
) -> CleartextVector64
unsafe fn create_cleartext_vector_unchecked(
&mut self,
input: &[u64]
) -> CleartextVector64
Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
sourceimpl CleartextVectorDiscardingRetrievalEngine<CleartextVector32, u32> for DefaultEngine
impl CleartextVectorDiscardingRetrievalEngine<CleartextVector32, u32> for DefaultEngine
Description:
Implementation of CleartextVectorDiscardingRetrievalEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u32],
input: &CleartextVector32
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u32],
input: &CleartextVector32
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u32; 100];
let mut retrieved = vec![0_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(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3_u32);
engine.destroy(cleartext_vector)?;
sourceunsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &CleartextVector32
)
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &CleartextVector32
)
Unsafely retrieves arbitrary values from a cleartext vector. Read more
sourceimpl CleartextVectorDiscardingRetrievalEngine<CleartextVector64, u64> for DefaultEngine
impl CleartextVectorDiscardingRetrievalEngine<CleartextVector64, u64> for DefaultEngine
Description:
Implementation of CleartextVectorDiscardingRetrievalEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u64],
input: &CleartextVector64
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [u64],
input: &CleartextVector64
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3_u64; 100];
let mut retrieved = vec![0_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(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3_u64);
engine.destroy(cleartext_vector)?;
sourceunsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &CleartextVector64
)
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &CleartextVector64
)
Unsafely retrieves arbitrary values from a cleartext vector. Read more
sourceimpl CleartextVectorDiscardingRetrievalEngine<CleartextVectorF64, f64> for DefaultEngine
impl CleartextVectorDiscardingRetrievalEngine<CleartextVectorF64, f64> for DefaultEngine
Description:
Implementation of CleartextVectorDiscardingRetrievalEngine
for DefaultEngine
that
operates on 64 bits floating point numbers.
sourcefn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [f64],
input: &CleartextVectorF64
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_cleartext_vector(
&mut self,
output: &mut [f64],
input: &CleartextVectorF64
) -> Result<(), CleartextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
let input = vec![3.0_f64; 100];
let mut retrieved = vec![0.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(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3.0_f64);
engine.destroy(cleartext_vector)?;
sourceunsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [f64],
input: &CleartextVectorF64
)
unsafe fn discard_retrieve_cleartext_vector_unchecked(
&mut self,
output: &mut [f64],
input: &CleartextVectorF64
)
Unsafely retrieves arbitrary values from a cleartext vector. Read more
sourceimpl CleartextVectorEncodingEngine<FloatEncoderVector, CleartextVectorF64, PlaintextVector32> for DefaultEngine
impl CleartextVectorEncodingEngine<FloatEncoderVector, CleartextVectorF64, PlaintextVector32> for DefaultEngine
Description:
Implementation of CleartextVectorEncodingEngine
for DefaultEngine
that encodes 64 bits
floating point numbers to 32 bits integers.
sourcefn encode_cleartext_vector(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> Result<PlaintextVector32, CleartextVectorEncodingError<Self::EngineError>>
fn encode_cleartext_vector(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> Result<PlaintextVector32, CleartextVectorEncodingError<Self::EngineError>>
Example:
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(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector32 =
engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
assert_eq!(
cleartext_vector.cleartext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(encoder_vector)?;
engine.destroy(cleartext_vector)?;
engine.destroy(plaintext_vector)?;
sourceunsafe fn encode_cleartext_vector_unchecked(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> PlaintextVector32
unsafe fn encode_cleartext_vector_unchecked(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> PlaintextVector32
Unsafely encodes a cleartext vector into a plaintext vector. Read more
sourceimpl CleartextVectorEncodingEngine<FloatEncoderVector, CleartextVectorF64, PlaintextVector64> for DefaultEngine
impl CleartextVectorEncodingEngine<FloatEncoderVector, CleartextVectorF64, PlaintextVector64> for DefaultEngine
Description:
Implementation of CleartextVectorEncodingEngine
for DefaultEngine
that encodes 64 bits
floating point numbers to 64 bits integers.
sourcefn encode_cleartext_vector(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> Result<PlaintextVector64, CleartextVectorEncodingError<Self::EngineError>>
fn encode_cleartext_vector(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> Result<PlaintextVector64, CleartextVectorEncodingError<Self::EngineError>>
Example:
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(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector64 =
engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
assert_eq!(
cleartext_vector.cleartext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(encoder_vector)?;
engine.destroy(cleartext_vector)?;
engine.destroy(plaintext_vector)?;
sourceunsafe fn encode_cleartext_vector_unchecked(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> PlaintextVector64
unsafe fn encode_cleartext_vector_unchecked(
&mut self,
encoder_vector: &FloatEncoderVector,
cleartext_vector: &CleartextVectorF64
) -> PlaintextVector64
Unsafely encodes a cleartext vector into a plaintext vector. Read more
sourceimpl CleartextVectorRetrievalEngine<CleartextVector32, u32> for DefaultEngine
impl CleartextVectorRetrievalEngine<CleartextVector32, u32> for DefaultEngine
Description:
Implementation of CleartextVectorRetrievalEngine
for DefaultEngine
that operates on 64
bits integers.
sourcefn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector32
) -> Result<Vec<u32>, CleartextVectorRetrievalError<Self::EngineError>>
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector32
) -> Result<Vec<u32>, CleartextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
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(&input)?;
let retrieved: Vec<u32> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3_u32);
engine.destroy(cleartext_vector)?;
sourceunsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector32
) -> Vec<u32>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector32
) -> Vec<u32>
Unsafely retrieves arbitrary values from a cleartext vector. Read more
sourceimpl CleartextVectorRetrievalEngine<CleartextVector64, u64> for DefaultEngine
impl CleartextVectorRetrievalEngine<CleartextVector64, u64> for DefaultEngine
Description:
Implementation of CleartextVectorRetrievalEngine
for DefaultEngine
that operates on 32
bits integers.
sourcefn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector64
) -> Result<Vec<u64>, CleartextVectorRetrievalError<Self::EngineError>>
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVector64
) -> Result<Vec<u64>, CleartextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
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(&input)?;
let retrieved: Vec<u64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3_u64);
engine.destroy(cleartext_vector)?;
sourceunsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector64
) -> Vec<u64>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector64
) -> Vec<u64>
Unsafely retrieves arbitrary values from a cleartext vector. Read more
sourceimpl CleartextVectorRetrievalEngine<CleartextVectorF64, f64> for DefaultEngine
impl CleartextVectorRetrievalEngine<CleartextVectorF64, f64> for DefaultEngine
Description:
Implementation of CleartextVectorRetrievalEngine
for DefaultEngine
that operates on 64
bits floating point numbers.
sourcefn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVectorF64
) -> Result<Vec<f64>, CleartextVectorRetrievalError<Self::EngineError>>
fn retrieve_cleartext_vector(
&mut self,
cleartext: &CleartextVectorF64
) -> Result<Vec<f64>, CleartextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::CleartextCount;
use concrete_core::prelude::*;
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(&input)?;
let retrieved: Vec<f64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3.0_f64);
engine.destroy(cleartext_vector)?;
sourceunsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVectorF64
) -> Vec<f64>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVectorF64
) -> Vec<f64>
Unsafely retrieves arbitrary values from a cleartext vector. Read more
sourceimpl DestructionEngine<Cleartext32> for DefaultEngine
impl DestructionEngine<Cleartext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: Cleartext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Cleartext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut Cleartext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut Cleartext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<Cleartext64> for DefaultEngine
impl DestructionEngine<Cleartext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: Cleartext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Cleartext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut Cleartext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut Cleartext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<CleartextF64> for DefaultEngine
impl DestructionEngine<CleartextF64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: CleartextF64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: CleartextF64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut CleartextF64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut CleartextF64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<CleartextVector32> for DefaultEngine
impl DestructionEngine<CleartextVector32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: CleartextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: CleartextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut CleartextVector32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut CleartextVector32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<CleartextVector64> for DefaultEngine
impl DestructionEngine<CleartextVector64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: CleartextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: CleartextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut CleartextVector64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut CleartextVector64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<CleartextVectorF64> for DefaultEngine
impl DestructionEngine<CleartextVectorF64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: CleartextVectorF64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: CleartextVectorF64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut CleartextVectorF64)
unsafe fn destroy_unchecked(&mut self, entity: &mut CleartextVectorF64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<FloatEncoder> for DefaultEngine
impl DestructionEngine<FloatEncoder> for DefaultEngine
sourcefn destroy(
&mut self,
entity: FloatEncoder
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: FloatEncoder
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut FloatEncoder)
unsafe fn destroy_unchecked(&mut self, _entity: &mut FloatEncoder)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<FloatEncoderVector> for DefaultEngine
impl DestructionEngine<FloatEncoderVector> for DefaultEngine
sourcefn destroy(
&mut self,
entity: FloatEncoderVector
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: FloatEncoderVector
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut FloatEncoderVector)
unsafe fn destroy_unchecked(&mut self, _entity: &mut FloatEncoderVector)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GgswCiphertext32> for DefaultEngine
impl DestructionEngine<GgswCiphertext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GgswCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GgswCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GgswCiphertext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GgswCiphertext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GgswCiphertext64> for DefaultEngine
impl DestructionEngine<GgswCiphertext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GgswCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GgswCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GgswCiphertext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GgswCiphertext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GgswSeededCiphertext32> for DefaultEngine
impl DestructionEngine<GgswSeededCiphertext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GgswSeededCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GgswSeededCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GgswSeededCiphertext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GgswSeededCiphertext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GgswSeededCiphertext64> for DefaultEngine
impl DestructionEngine<GgswSeededCiphertext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GgswSeededCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GgswSeededCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GgswSeededCiphertext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GgswSeededCiphertext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertext32> for DefaultEngine
impl DestructionEngine<GlweCiphertext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertext64> for DefaultEngine
impl DestructionEngine<GlweCiphertext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertextMutView32<'_>> for DefaultEngine
impl DestructionEngine<GlweCiphertextMutView32<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertextMutView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextMutView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextMutView32<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextMutView32<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertextMutView64<'_>> for DefaultEngine
impl DestructionEngine<GlweCiphertextMutView64<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertextMutView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextMutView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextMutView64<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextMutView64<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertextVector32> for DefaultEngine
impl DestructionEngine<GlweCiphertextVector32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextVector32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextVector32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertextVector64> for DefaultEngine
impl DestructionEngine<GlweCiphertextVector64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextVector64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextVector64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertextView32<'_>> for DefaultEngine
impl DestructionEngine<GlweCiphertextView32<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertextView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextView32<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextView32<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweCiphertextView64<'_>> for DefaultEngine
impl DestructionEngine<GlweCiphertextView64<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweCiphertextView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweCiphertextView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextView64<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweCiphertextView64<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweSecretKey32> for DefaultEngine
impl DestructionEngine<GlweSecretKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut GlweSecretKey32)
unsafe fn destroy_unchecked(&mut self, entity: &mut GlweSecretKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweSecretKey64> for DefaultEngine
impl DestructionEngine<GlweSecretKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut GlweSecretKey64)
unsafe fn destroy_unchecked(&mut self, entity: &mut GlweSecretKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweSeededCiphertext32> for DefaultEngine
impl DestructionEngine<GlweSeededCiphertext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweSeededCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSeededCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweSeededCiphertext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweSeededCiphertext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweSeededCiphertext64> for DefaultEngine
impl DestructionEngine<GlweSeededCiphertext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweSeededCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSeededCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut GlweSeededCiphertext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut GlweSeededCiphertext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweSeededCiphertextVector32> for DefaultEngine
impl DestructionEngine<GlweSeededCiphertextVector32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweSeededCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSeededCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(
&mut self,
_entity: &mut GlweSeededCiphertextVector32
)
unsafe fn destroy_unchecked(
&mut self,
_entity: &mut GlweSeededCiphertextVector32
)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<GlweSeededCiphertextVector64> for DefaultEngine
impl DestructionEngine<GlweSeededCiphertextVector64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: GlweSeededCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: GlweSeededCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(
&mut self,
_entity: &mut GlweSeededCiphertextVector64
)
unsafe fn destroy_unchecked(
&mut self,
_entity: &mut GlweSeededCiphertextVector64
)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweBootstrapKey32> for DefaultEngine
impl DestructionEngine<LweBootstrapKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweBootstrapKey32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweBootstrapKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweBootstrapKey64> for DefaultEngine
impl DestructionEngine<LweBootstrapKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweBootstrapKey64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweBootstrapKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertext32> for DefaultEngine
impl DestructionEngine<LweCiphertext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertext64> for DefaultEngine
impl DestructionEngine<LweCiphertext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertextMutView32<'_>> for DefaultEngine
impl DestructionEngine<LweCiphertextMutView32<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextMutView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextMutView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextMutView32<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextMutView32<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertextMutView64<'_>> for DefaultEngine
impl DestructionEngine<LweCiphertextMutView64<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextMutView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextMutView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextMutView64<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextMutView64<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertextVector32> for DefaultEngine
impl DestructionEngine<LweCiphertextVector32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextVector32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextVector32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertextVector64> for DefaultEngine
impl DestructionEngine<LweCiphertextVector64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextVector64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextVector64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertextView32<'_>> for DefaultEngine
impl DestructionEngine<LweCiphertextView32<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextView32<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextView32<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextView32<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweCiphertextView64<'_>> for DefaultEngine
impl DestructionEngine<LweCiphertextView64<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextView64<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextView64<'_>)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweKeyswitchKey32> for DefaultEngine
impl DestructionEngine<LweKeyswitchKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweKeyswitchKey32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweKeyswitchKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweKeyswitchKey64> for DefaultEngine
impl DestructionEngine<LweKeyswitchKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweKeyswitchKey64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweKeyswitchKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSecretKey32> for DefaultEngine
impl DestructionEngine<LweSecretKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSecretKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut LweSecretKey32)
unsafe fn destroy_unchecked(&mut self, entity: &mut LweSecretKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSecretKey64> for DefaultEngine
impl DestructionEngine<LweSecretKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSecretKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut LweSecretKey64)
unsafe fn destroy_unchecked(&mut self, entity: &mut LweSecretKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededBootstrapKey32> for DefaultEngine
impl DestructionEngine<LweSeededBootstrapKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededBootstrapKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut LweSeededBootstrapKey32)
unsafe fn destroy_unchecked(&mut self, entity: &mut LweSeededBootstrapKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededBootstrapKey64> for DefaultEngine
impl DestructionEngine<LweSeededBootstrapKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededBootstrapKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut LweSeededBootstrapKey64)
unsafe fn destroy_unchecked(&mut self, entity: &mut LweSeededBootstrapKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededCiphertext32> for DefaultEngine
impl DestructionEngine<LweSeededCiphertext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededCiphertext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededCiphertext64> for DefaultEngine
impl DestructionEngine<LweSeededCiphertext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededCiphertext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededCiphertextVector32> for DefaultEngine
impl DestructionEngine<LweSeededCiphertextVector32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertextVector32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertextVector32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededCiphertextVector64> for DefaultEngine
impl DestructionEngine<LweSeededCiphertextVector64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededCiphertextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertextVector64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededCiphertextVector64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededKeyswitchKey32> for DefaultEngine
impl DestructionEngine<LweSeededKeyswitchKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededKeyswitchKey32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededKeyswitchKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<LweSeededKeyswitchKey64> for DefaultEngine
impl DestructionEngine<LweSeededKeyswitchKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweSeededKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweSeededKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededKeyswitchKey64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweSeededKeyswitchKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<PackingKeyswitchKey32> for DefaultEngine
impl DestructionEngine<PackingKeyswitchKey32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: PackingKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: PackingKeyswitchKey32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut PackingKeyswitchKey32)
unsafe fn destroy_unchecked(&mut self, entity: &mut PackingKeyswitchKey32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<PackingKeyswitchKey64> for DefaultEngine
impl DestructionEngine<PackingKeyswitchKey64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: PackingKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: PackingKeyswitchKey64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, entity: &mut PackingKeyswitchKey64)
unsafe fn destroy_unchecked(&mut self, entity: &mut PackingKeyswitchKey64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<Plaintext32> for DefaultEngine
impl DestructionEngine<Plaintext32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: Plaintext32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Plaintext32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut Plaintext32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut Plaintext32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<Plaintext64> for DefaultEngine
impl DestructionEngine<Plaintext64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: Plaintext64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: Plaintext64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut Plaintext64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut Plaintext64)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<PlaintextVector32> for DefaultEngine
impl DestructionEngine<PlaintextVector32> for DefaultEngine
sourcefn destroy(
&mut self,
entity: PlaintextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: PlaintextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut PlaintextVector32)
unsafe fn destroy_unchecked(&mut self, _entity: &mut PlaintextVector32)
Unsafely destroys an entity. Read more
sourceimpl DestructionEngine<PlaintextVector64> for DefaultEngine
impl DestructionEngine<PlaintextVector64> for DefaultEngine
sourcefn destroy(
&mut self,
entity: PlaintextVector64
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: PlaintextVector64
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut PlaintextVector64)
unsafe fn destroy_unchecked(&mut self, _entity: &mut PlaintextVector64)
Unsafely destroys an entity. Read more
sourceimpl EncoderCreationEngine<FloatEncoderCenterRadiusConfig, FloatEncoder> for DefaultEngine
impl EncoderCreationEngine<FloatEncoderCenterRadiusConfig, FloatEncoder> for DefaultEngine
Description:
Implementation of EncoderCreationEngine
for DefaultEngine
that creates an encoder to
encode 64 bits floating point numbers.
sourcefn create_encoder(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> Result<FloatEncoder, EncoderCreationError<Self::EngineError>>
fn create_encoder(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> Result<FloatEncoder, EncoderCreationError<Self::EngineError>>
Example:
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 = engine.create_encoder(&FloatEncoderCenterRadiusConfig {
center: 10.,
radius: 5.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
engine.destroy(encoder)?;
sourceunsafe fn create_encoder_unchecked(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> FloatEncoder
unsafe fn create_encoder_unchecked(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> FloatEncoder
Unsafely creates an encoder from a config. Read more
sourceimpl EncoderCreationEngine<FloatEncoderMinMaxConfig, FloatEncoder> for DefaultEngine
impl EncoderCreationEngine<FloatEncoderMinMaxConfig, FloatEncoder> for DefaultEngine
Description:
Implementation of EncoderCreationEngine
for DefaultEngine
that creates an encoder to
encode 64 bits floating point numbers.
sourcefn create_encoder(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> Result<FloatEncoder, EncoderCreationError<Self::EngineError>>
fn create_encoder(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> Result<FloatEncoder, EncoderCreationError<Self::EngineError>>
Example:
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 = engine.create_encoder(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
engine.destroy(encoder)?;
sourceunsafe fn create_encoder_unchecked(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> FloatEncoder
unsafe fn create_encoder_unchecked(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> FloatEncoder
Unsafely creates an encoder from a config. Read more
sourceimpl EncoderVectorCreationEngine<FloatEncoderCenterRadiusConfig, FloatEncoderVector> for DefaultEngine
impl EncoderVectorCreationEngine<FloatEncoderCenterRadiusConfig, FloatEncoderVector> for DefaultEngine
Description:
Implementation of EncoderVectorCreationEngine
for DefaultEngine
that creates an encoder
vector to encode vectors of 64 bits floating point numbers.
sourcefn create_encoder_vector(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> Result<FloatEncoderVector, EncoderVectorCreationError<Self::EngineError>>
fn create_encoder_vector(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> Result<FloatEncoderVector, EncoderVectorCreationError<Self::EngineError>>
Example:
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(&vec![
FloatEncoderCenterRadiusConfig {
center: 10.,
radius: 5.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
1
])?;
engine.destroy(encoder_vector)?;
sourceunsafe fn create_encoder_vector_unchecked(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> FloatEncoderVector
unsafe fn create_encoder_vector_unchecked(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> FloatEncoderVector
Unsafely creates an encoder vector from a config. Read more
sourceimpl EncoderVectorCreationEngine<FloatEncoderMinMaxConfig, FloatEncoderVector> for DefaultEngine
impl EncoderVectorCreationEngine<FloatEncoderMinMaxConfig, FloatEncoderVector> for DefaultEngine
Description:
Implementation of EncoderVectorCreationEngine
for DefaultEngine
that creates an encoder
vector to encode vectors of 64 bits floating point numbers.
sourcefn create_encoder_vector(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> Result<FloatEncoderVector, EncoderVectorCreationError<Self::EngineError>>
fn create_encoder_vector(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> Result<FloatEncoderVector, EncoderVectorCreationError<Self::EngineError>>
Example:
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(
vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
1
]
.as_slice(),
)?;
engine.destroy(encoder_vector)?;
sourceunsafe fn create_encoder_vector_unchecked(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> FloatEncoderVector
unsafe fn create_encoder_vector_unchecked(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> FloatEncoderVector
Unsafely creates an encoder vector from a config. Read more
sourceimpl GgswCiphertextScalarDiscardingEncryptionEngine<GlweSecretKey32, Plaintext32, GgswCiphertext32> for DefaultEngine
impl GgswCiphertextScalarDiscardingEncryptionEngine<GlweSecretKey32, Plaintext32, GgswCiphertext32> for DefaultEngine
Description:
Implementation of GgswCiphertextScalarDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut GgswCiphertext32,
input: &Plaintext32,
noise: Variance
) -> Result<(), GgswCiphertextScalarDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut GgswCiphertext32,
input: &Plaintext32,
noise: Variance
) -> Result<(), GgswCiphertextScalarDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize,
};
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 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_1: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext =
engine.encrypt_scalar_ggsw_ciphertext(&key_1, &plaintext, noise, level, base_log)?;
// We're going to re-encrypt the input with another secret key
// For this, it is required that the second secret key uses the same GLWE dimension
// and polynomial size as the first one.
let key_2: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
engine.discard_encrypt_scalar_ggsw_ciphertext(&key_2, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(ciphertext)?;
engine.destroy(plaintext)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
sourceunsafe fn discard_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GgswCiphertext32,
input: &Plaintext32,
noise: Variance
)
unsafe fn discard_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GgswCiphertext32,
input: &Plaintext32,
noise: Variance
)
Unsafely encrypts a GGSW ciphertext. Read more
sourceimpl GgswCiphertextScalarDiscardingEncryptionEngine<GlweSecretKey64, Plaintext64, GgswCiphertext64> for DefaultEngine
impl GgswCiphertextScalarDiscardingEncryptionEngine<GlweSecretKey64, Plaintext64, GgswCiphertext64> for DefaultEngine
Description:
Implementation of GgswCiphertextScalarDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut GgswCiphertext64,
input: &Plaintext64,
noise: Variance
) -> Result<(), GgswCiphertextScalarDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut GgswCiphertext64,
input: &Plaintext64,
noise: Variance
) -> Result<(), GgswCiphertextScalarDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize,
};
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 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_1: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext =
engine.encrypt_scalar_ggsw_ciphertext(&key_1, &plaintext, noise, level, base_log)?;
// We're going to re-encrypt the input with another secret key
// For this, it is required that the second secret key uses the same GLWE dimension
// and polynomial size as the first one.
let key_2: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
engine.discard_encrypt_scalar_ggsw_ciphertext(&key_2, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(ciphertext)?;
engine.destroy(plaintext)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
sourceunsafe fn discard_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GgswCiphertext64,
input: &Plaintext64,
noise: Variance
)
unsafe fn discard_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GgswCiphertext64,
input: &Plaintext64,
noise: Variance
)
Unsafely encrypts a GGSW ciphertext. Read more
sourceimpl GgswCiphertextScalarEncryptionEngine<GlweSecretKey32, Plaintext32, GgswCiphertext32> for DefaultEngine
impl GgswCiphertextScalarEncryptionEngine<GlweSecretKey32, Plaintext32, GgswCiphertext32> for DefaultEngine
Description:
Implementation of GgswCiphertextScalarEncryptionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &Plaintext32,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> Result<GgswCiphertext32, GgswCiphertextScalarEncryptionError<Self::EngineError>>
fn encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &Plaintext32,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> Result<GgswCiphertext32, GgswCiphertextScalarEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize,
};
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 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext =
engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &Plaintext32,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> GgswCiphertext32
unsafe fn encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &Plaintext32,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> GgswCiphertext32
Unsafely encrypts a plaintext vector into a GGSW ciphertext. Read more
sourceimpl GgswCiphertextScalarEncryptionEngine<GlweSecretKey64, Plaintext64, GgswCiphertext64> for DefaultEngine
impl GgswCiphertextScalarEncryptionEngine<GlweSecretKey64, Plaintext64, GgswCiphertext64> for DefaultEngine
Description:
Implementation of GgswCiphertextScalarEncryptionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &Plaintext64,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> Result<GgswCiphertext64, GgswCiphertextScalarEncryptionError<Self::EngineError>>
fn encrypt_scalar_ggsw_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &Plaintext64,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> Result<GgswCiphertext64, GgswCiphertextScalarEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize,
};
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 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext =
engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &Plaintext64,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> GgswCiphertext64
unsafe fn encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &Plaintext64,
noise: Variance,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog
) -> GgswCiphertext64
Unsafely encrypts a plaintext vector into a GGSW ciphertext. Read more
sourceimpl GgswCiphertextScalarTrivialEncryptionEngine<Plaintext32, GgswCiphertext32> for DefaultEngine
impl GgswCiphertextScalarTrivialEncryptionEngine<Plaintext32, GgswCiphertext32> for DefaultEngine
Description:
Implementation of GgswCiphertextScalarTrivialEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn trivially_encrypt_scalar_ggsw_ciphertext(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext32
) -> Result<GgswCiphertext32, GgswCiphertextScalarTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_scalar_ggsw_ciphertext(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext32
) -> Result<GgswCiphertext32, GgswCiphertextScalarTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize,
};
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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
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(&input)?;
let ciphertext: GgswCiphertext32 = engine.trivially_encrypt_scalar_ggsw_ciphertext(
polynomial_size,
glwe_dimension.to_glwe_size(),
level,
base_log,
&plaintext,
)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
assert_eq!(ciphertext.decomposition_base_log(), base_log);
assert_eq!(ciphertext.decomposition_level_count(), level);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn trivially_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext32
) -> GgswCiphertext32
unsafe fn trivially_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext32
) -> GgswCiphertext32
Unsafely creates the trivial GGSW encryption of the plaintext. Read more
sourceimpl GgswCiphertextScalarTrivialEncryptionEngine<Plaintext64, GgswCiphertext64> for DefaultEngine
impl GgswCiphertextScalarTrivialEncryptionEngine<Plaintext64, GgswCiphertext64> for DefaultEngine
Description:
Implementation of GgswCiphertextScalarTrivialEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn trivially_encrypt_scalar_ggsw_ciphertext(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext64
) -> Result<GgswCiphertext64, GgswCiphertextScalarTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_scalar_ggsw_ciphertext(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext64
) -> Result<GgswCiphertext64, GgswCiphertextScalarTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize,
};
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 level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
let input = 3_u64 << 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: Plaintext64 = engine.create_plaintext(&input)?;
let ciphertext: GgswCiphertext64 = engine.trivially_encrypt_scalar_ggsw_ciphertext(
polynomial_size,
glwe_dimension.to_glwe_size(),
level,
base_log,
&plaintext,
)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn trivially_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext64
) -> GgswCiphertext64
unsafe fn trivially_encrypt_scalar_ggsw_ciphertext_unchecked(
&mut self,
polynomial_size: PolynomialSize,
glwe_size: GlweSize,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
input: &Plaintext64
) -> GgswCiphertext64
Unsafely creates the trivial GGSW encryption of the plaintext. Read more
sourceimpl GlweCiphertextConsumingRetrievalEngine<GlweCiphertext32, Vec<u32, Global>> for DefaultEngine
impl GlweCiphertextConsumingRetrievalEngine<GlweCiphertext32, Vec<u32, Global>> for DefaultEngine
Description:
Implementation of GlweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying vec of a GlweCiphertext32
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertext32
) -> Result<Vec<u32>, GlweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertext32
) -> Result<Vec<u32>, GlweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();
// 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 ciphertext: GlweCiphertext32 =
engine.create_glwe_ciphertext(owned_container, polynomial_size)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertext32
) -> Vec<u32>
unsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertext32
) -> Vec<u32>
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
sourceimpl GlweCiphertextConsumingRetrievalEngine<GlweCiphertext64, Vec<u64, Global>> for DefaultEngine
impl GlweCiphertextConsumingRetrievalEngine<GlweCiphertext64, Vec<u64, Global>> for DefaultEngine
Description:
Implementation of GlweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying vec of a GlweCiphertext64
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertext64
) -> Result<Vec<u64>, GlweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertext64
) -> Result<Vec<u64>, GlweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();
// 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 ciphertext: GlweCiphertext64 =
engine.create_glwe_ciphertext(owned_container, polynomial_size)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertext64
) -> Vec<u64>
unsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertext64
) -> Vec<u64>
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextMutView32<'data>, &'data mut [u32]> for DefaultEngine
impl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextMutView32<'data>, &'data mut [u32]> for DefaultEngine
Description:
Implementation of GlweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a GlweCiphertextMutView32
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextMutView32<'data>
) -> Result<&'data mut [u32], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextMutView32<'data>
) -> Result<&'data mut [u32], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
// 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 ciphertext_view: GlweCiphertextMutView32 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextMutView32<'data>
) -> &'data mut [u32]
unsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextMutView32<'data>
) -> &'data mut [u32]
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextMutView64<'data>, &'data mut [u64]> for DefaultEngine
Description:
Implementation of GlweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a GlweCiphertextMutView64
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextMutView64<'data>
) -> Result<&'data mut [u64], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextMutView64<'data>
) -> Result<&'data mut [u64], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];
let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
// 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 ciphertext_view: GlweCiphertextMutView64 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextMutView64<'data>
) -> &'data mut [u64]
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextView32<'data>, &'data [u32]> for DefaultEngine
impl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextView32<'data>, &'data [u32]> for DefaultEngine
Description:
Implementation of GlweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a GlweCiphertextView32
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextView32<'data>
) -> Result<&'data [u32], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextView32<'data>
) -> Result<&'data [u32], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: GlweCiphertextView32 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextView32<'data>
) -> &'data [u32]
unsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextView32<'data>
) -> &'data [u32]
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextView64<'data>, &'data [u64]> for DefaultEngine
impl<'data> GlweCiphertextConsumingRetrievalEngine<GlweCiphertextView64<'data>, &'data [u64]> for DefaultEngine
Description:
Implementation of GlweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a GlweCiphertextView64
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextView64<'data>
) -> Result<&'data [u64], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext(
&mut self,
ciphertext: GlweCiphertextView64<'data>
) -> Result<&'data [u64], GlweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: GlweCiphertextView64 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextView64<'data>
) -> &'data [u64]
unsafe fn consume_retrieve_glwe_ciphertext_unchecked(
&mut self,
ciphertext: GlweCiphertextView64<'data>
) -> &'data [u64]
Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> GlweCiphertextCreationEngine<&'data [u32], GlweCiphertextView32<'data>> for DefaultEngine
impl<'data> GlweCiphertextCreationEngine<&'data [u32], GlweCiphertextView32<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextCreationEngine
for DefaultEngine
which returns an
immutable GlweCiphertextView32
that does not own its memory.
sourcefn create_glwe_ciphertext(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: GlweCiphertextView32 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextView32<'data>
unsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextView32<'data>
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
sourceimpl<'data> GlweCiphertextCreationEngine<&'data [u64], GlweCiphertextView64<'data>> for DefaultEngine
impl<'data> GlweCiphertextCreationEngine<&'data [u64], GlweCiphertextView64<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextCreationEngine
for DefaultEngine
which returns an
immutable GlweCiphertextView64
that does not own its memory.
sourcefn create_glwe_ciphertext(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::PolynomialSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = 600_usize;
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; (glwe_size + 1) * polynomial_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: GlweCiphertextView64 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextView64<'data>
unsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextView64<'data>
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
sourceimpl<'data> GlweCiphertextCreationEngine<&'data mut [u32], GlweCiphertextMutView32<'data>> for DefaultEngine
impl<'data> GlweCiphertextCreationEngine<&'data mut [u32], GlweCiphertextMutView32<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextCreationEngine
for DefaultEngine
which returns a mutable
GlweCiphertextMutView32
that does not own its memory.
sourcefn create_glwe_ciphertext(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
let slice = &mut owned_container[..];
// 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 ciphertext_view: GlweCiphertextMutView32 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView32<'data>
unsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView32<'data>
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
sourceimpl<'data> GlweCiphertextCreationEngine<&'data mut [u64], GlweCiphertextMutView64<'data>> for DefaultEngine
impl<'data> GlweCiphertextCreationEngine<&'data mut [u64], GlweCiphertextMutView64<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextCreationEngine
for DefaultEngine
which returns a mutable
GlweCiphertextMutView64
that does not own its memory.
sourcefn create_glwe_ciphertext(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweSize, PolynomialSize};
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];
let slice = &mut owned_container[..];
// 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 ciphertext_view: GlweCiphertextMutView64 =
engine.create_glwe_ciphertext(slice, polynomial_size)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView64<'data>
unsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView64<'data>
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
sourceimpl GlweCiphertextCreationEngine<Vec<u32, Global>, GlweCiphertext32> for DefaultEngine
impl GlweCiphertextCreationEngine<Vec<u32, Global>, GlweCiphertext32> for DefaultEngine
Description:
Implementation of GlweCiphertextCreationEngine
for DefaultEngine
which returns a
GlweCiphertext32
.
sourcefn create_glwe_ciphertext(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext32, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext32, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::GlweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0];
// 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 ciphertext: GlweCiphertext32 =
engine.create_glwe_ciphertext(owned_container, polynomial_size)?;
engine.destroy(ciphertext)?;
sourceunsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> GlweCiphertext32
unsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> GlweCiphertext32
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
sourceimpl GlweCiphertextCreationEngine<Vec<u64, Global>, GlweCiphertext64> for DefaultEngine
impl GlweCiphertextCreationEngine<Vec<u64, Global>, GlweCiphertext64> for DefaultEngine
Description:
Implementation of GlweCiphertextCreationEngine
for DefaultEngine
which returns a
GlweCiphertext64
.
sourcefn create_glwe_ciphertext(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext64, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext64, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::GlweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let glwe_size = GlweSize(600);
let polynomial_size = PolynomialSize(1024);
// You have to make sure you size the container properly
let owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0];
// 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 ciphertext: GlweCiphertext64 =
engine.create_glwe_ciphertext(owned_container, polynomial_size)?;
engine.destroy(ciphertext)?;
sourceunsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> GlweCiphertext64
unsafe fn create_glwe_ciphertext_unchecked(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> GlweCiphertext64
Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
sourceimpl GlweCiphertextDecryptionEngine<GlweSecretKey32, GlweCiphertext32, PlaintextVector32> for DefaultEngine
impl GlweCiphertextDecryptionEngine<GlweSecretKey32, GlweCiphertext32, PlaintextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextDecryptionEngine
for DefaultEngine
that operates on 32
bits integers.
sourcefn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> Result<PlaintextVector32, GlweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> Result<PlaintextVector32, GlweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext_vector)?;
sourceunsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> PlaintextVector32
unsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertext32
) -> PlaintextVector32
Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more
sourceimpl GlweCiphertextDecryptionEngine<GlweSecretKey64, GlweCiphertext64, PlaintextVector64> for DefaultEngine
impl GlweCiphertextDecryptionEngine<GlweSecretKey64, GlweCiphertext64, PlaintextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextDecryptionEngine
for DefaultEngine
that operates on 64
bits integers.
sourcefn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> Result<PlaintextVector64, GlweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> Result<PlaintextVector64, GlweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext_vector)?;
sourceunsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> PlaintextVector64
unsafe fn decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertext64
) -> PlaintextVector64
Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more
sourceimpl GlweCiphertextDiscardingDecryptionEngine<GlweSecretKey32, GlweCiphertext32, PlaintextVector32> for DefaultEngine
impl GlweCiphertextDiscardingDecryptionEngine<GlweSecretKey32, GlweCiphertext32, PlaintextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextDiscardingDecryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, PolynomialSize};
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);
// Here a hard-set encoding is applied (shift by 20 bits)
let mut 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext(&key, &mut plaintext_vector, &ciphertext)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(4));
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
)
unsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertext32
)
Unsafely decrypts a GLWE ciphertext . Read more
sourceimpl GlweCiphertextDiscardingDecryptionEngine<GlweSecretKey64, GlweCiphertext64, PlaintextVector64> for DefaultEngine
impl GlweCiphertextDiscardingDecryptionEngine<GlweSecretKey64, GlweCiphertext64, PlaintextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextDiscardingDecryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
) -> Result<(), GlweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, PolynomialSize};
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);
// Here a hard-set encoding is applied (shift by 50 bits)
let mut 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext(&key, &mut plaintext_vector, &ciphertext)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(4));
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
)
unsafe fn discard_decrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertext64
)
Unsafely decrypts a GLWE ciphertext . Read more
sourceimpl GlweCiphertextDiscardingEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertext32> for DefaultEngine
impl GlweCiphertextDiscardingEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of GlweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 4];
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_1: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext = engine.encrypt_glwe_ciphertext(&key_1, &plaintext_vector, noise)?;
// We're going to re-encrypt the input with another secret key
// For this, it is required that the second secret key uses the same GLWE dimension
// and polynomial size as the first one.
let key_2: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
engine.discard_encrypt_glwe_ciphertext(&key_2, &mut ciphertext, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
sourceunsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertext32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext . Read more
sourceimpl GlweCiphertextDiscardingEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertext64> for DefaultEngine
impl GlweCiphertextDiscardingEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of GlweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 4];
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_1: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext = engine.encrypt_glwe_ciphertext(&key_1, &plaintext_vector, noise)?;
// We're going to re-encrypt the input with another secret key
// For this, it is required that the second secret key uses the same GLWE dimension
// and polynomial size as the first one.
let key_2: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
engine.discard_encrypt_glwe_ciphertext(&key_2, &mut ciphertext, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(ciphertext)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
sourceunsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertext64,
input: &PlaintextVector64,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext . Read more
sourceimpl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector32, GlweCiphertext32> for DefaultEngine
impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector32, GlweCiphertext32> for DefaultEngine
sourcefn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertext32,
input: &PlaintextVector32
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
fn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertext32,
input: &PlaintextVector32
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u32 << 20; polynomial_size.0];
// 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(&input)?;
let ct_container = vec![0_u32; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertext32 =
engine.create_glwe_ciphertext(ct_container, polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &PlaintextVector32
)
unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &PlaintextVector32
)
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
sourceimpl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector32, GlweCiphertextMutView32<'_>> for DefaultEngine
impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector32, GlweCiphertextMutView32<'_>> for DefaultEngine
sourcefn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertextMutView32<'_>,
input: &PlaintextVector32
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
fn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertextMutView32<'_>,
input: &PlaintextVector32
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u32 << 20; polynomial_size.0];
// 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(&input)?;
let mut ct_container = vec![0_u32; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertextMutView32 =
engine.create_glwe_ciphertext(&mut ct_container[..], polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertextMutView32<'_>,
input: &PlaintextVector32
)
unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertextMutView32<'_>,
input: &PlaintextVector32
)
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
sourceimpl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector64, GlweCiphertext64> for DefaultEngine
impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector64, GlweCiphertext64> for DefaultEngine
sourcefn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertext64,
input: &PlaintextVector64
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
fn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertext64,
input: &PlaintextVector64
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u64 << 20; polynomial_size.0];
// 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(&input)?;
let ct_container = vec![0_u64; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertext64 =
engine.create_glwe_ciphertext(ct_container, polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &PlaintextVector64
)
unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &PlaintextVector64
)
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
sourceimpl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector64, GlweCiphertextMutView64<'_>> for DefaultEngine
impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector64, GlweCiphertextMutView64<'_>> for DefaultEngine
sourcefn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertextMutView64<'_>,
input: &PlaintextVector64
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
fn discard_trivially_encrypt_glwe_ciphertext(
&mut self,
output: &mut GlweCiphertextMutView64<'_>,
input: &PlaintextVector64
) -> Result<(), GlweCiphertextDiscardingTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u64 << 20; polynomial_size.0];
// 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(&input)?;
let mut ct_container = vec![0_u64; glwe_dimension.to_glwe_size().0 * polynomial_size.0];
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let mut ciphertext: GlweCiphertextMutView64 =
engine.create_glwe_ciphertext(&mut ct_container[..], polynomial_size)?;
engine.discard_trivially_encrypt_glwe_ciphertext(&mut ciphertext, &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertextMutView64<'_>,
input: &PlaintextVector64
)
unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
output: &mut GlweCiphertextMutView64<'_>,
input: &PlaintextVector64
)
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
sourceimpl GlweCiphertextEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertext32> for DefaultEngine
impl GlweCiphertextEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of GlweCiphertextEncryptionEngine
for DefaultEngine
that operates on 32
bits integers.
sourcefn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertext32
unsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertext32
Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
sourceimpl GlweCiphertextEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertext64> for DefaultEngine
impl GlweCiphertextEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of GlweCiphertextEncryptionEngine
for DefaultEngine
that operates on 64
bits integers.
sourcefn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertext64
unsafe fn encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertext64
Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
sourceimpl GlweCiphertextTrivialDecryptionEngine<GlweCiphertext32, PlaintextVector32> for DefaultEngine
impl GlweCiphertextTrivialDecryptionEngine<GlweCiphertext32, PlaintextVector32> for DefaultEngine
sourcefn trivially_decrypt_glwe_ciphertext(
&mut self,
input: &GlweCiphertext32
) -> Result<PlaintextVector32, GlweCiphertextTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_glwe_ciphertext(
&mut self,
input: &GlweCiphertext32
) -> Result<PlaintextVector32, GlweCiphertextTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u32 << 20; polynomial_size.0];
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: GlweCiphertext32 = engine
.trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
let output: PlaintextVector32 = engine.trivially_decrypt_glwe_ciphertext(&ciphertext)?;
assert_eq!(output.plaintext_count(), PlaintextCount(polynomial_size.0));
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext32
) -> PlaintextVector32
unsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext32
) -> PlaintextVector32
Unsafely trivially decrypts a GLWE ciphertext into a plaintext vector. Read more
sourceimpl GlweCiphertextTrivialDecryptionEngine<GlweCiphertext64, PlaintextVector64> for DefaultEngine
impl GlweCiphertextTrivialDecryptionEngine<GlweCiphertext64, PlaintextVector64> for DefaultEngine
sourcefn trivially_decrypt_glwe_ciphertext(
&mut self,
input: &GlweCiphertext64
) -> Result<PlaintextVector64, GlweCiphertextTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_glwe_ciphertext(
&mut self,
input: &GlweCiphertext64
) -> Result<PlaintextVector64, GlweCiphertextTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u64 << 20; polynomial_size.0];
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: GlweCiphertext64 = engine
.trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
let output: PlaintextVector64 = engine.trivially_decrypt_glwe_ciphertext(&ciphertext)?;
assert_eq!(output.plaintext_count(), PlaintextCount(polynomial_size.0));
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext64
) -> PlaintextVector64
unsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext64
) -> PlaintextVector64
Unsafely trivially decrypts a GLWE ciphertext into a plaintext vector. Read more
sourceimpl GlweCiphertextTrivialEncryptionEngine<PlaintextVector32, GlweCiphertext32> for DefaultEngine
impl GlweCiphertextTrivialEncryptionEngine<PlaintextVector32, GlweCiphertext32> for DefaultEngine
sourcefn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> Result<GlweCiphertext32, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> Result<GlweCiphertext32, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u32 << 20; polynomial_size.0];
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: GlweCiphertext32 = engine
.trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> GlweCiphertext32
unsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector32
) -> GlweCiphertext32
Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
sourceimpl GlweCiphertextTrivialEncryptionEngine<PlaintextVector64, GlweCiphertext64> for DefaultEngine
impl GlweCiphertextTrivialEncryptionEngine<PlaintextVector64, GlweCiphertext64> for DefaultEngine
sourcefn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> Result<GlweCiphertext64, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_glwe_ciphertext(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> Result<GlweCiphertext64, GlweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u64 << 20; polynomial_size.0];
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: GlweCiphertext64 = engine
.trivially_encrypt_glwe_ciphertext(glwe_dimension.to_glwe_size(), &plaintext_vector)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> GlweCiphertext64
unsafe fn trivially_encrypt_glwe_ciphertext_unchecked(
&mut self,
glwe_size: GlweSize,
input: &PlaintextVector64
) -> GlweCiphertext64
Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
sourceimpl GlweCiphertextVectorDecryptionEngine<GlweSecretKey32, GlweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl GlweCiphertextVectorDecryptionEngine<GlweSecretKey32, GlweCiphertextVector32, PlaintextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorDecryptionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> Result<PlaintextVector32, GlweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> Result<PlaintextVector32, GlweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_glwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> PlaintextVector32
unsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &GlweCiphertextVector32
) -> PlaintextVector32
Unsafely decrypts a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorDecryptionEngine<GlweSecretKey64, GlweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl GlweCiphertextVectorDecryptionEngine<GlweSecretKey64, GlweCiphertextVector64, PlaintextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorDecryptionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> Result<PlaintextVector64, GlweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> Result<PlaintextVector64, GlweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_glwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> PlaintextVector64
unsafe fn decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &GlweCiphertextVector64
) -> PlaintextVector64
Unsafely decrypts a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorDiscardingDecryptionEngine<GlweSecretKey32, GlweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl GlweCiphertextVectorDiscardingDecryptionEngine<GlweSecretKey32, GlweCiphertextVector32, PlaintextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorDiscardingDecryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(8));
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
)
unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut PlaintextVector32,
input: &GlweCiphertextVector32
)
Unsafely encrypts a GLWE ciphertext vector . Read more
sourceimpl GlweCiphertextVectorDiscardingDecryptionEngine<GlweSecretKey64, GlweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl GlweCiphertextVectorDiscardingDecryptionEngine<GlweSecretKey64, GlweCiphertextVector64, PlaintextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorDiscardingDecryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
) -> Result<(), GlweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PlaintextCount, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_glwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(8));
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
)
unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut PlaintextVector64,
input: &GlweCiphertextVector64
)
Unsafely encrypts a GLWE ciphertext vector . Read more
sourceimpl GlweCiphertextVectorDiscardingEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertextVector32> for DefaultEngine
impl GlweCiphertextVectorDiscardingEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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_1: GlweSecretKey32 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey32 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key_1, &plaintext_vector, noise)?;
engine.discard_encrypt_glwe_ciphertext_vector(
&key_2,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
sourceunsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
output: &mut GlweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext vector . Read more
sourceimpl GlweCiphertextVectorDiscardingEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertextVector64> for DefaultEngine
impl GlweCiphertextVectorDiscardingEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), GlweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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_1: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key_1, &plaintext_vector, noise)?;
engine.discard_encrypt_glwe_ciphertext_vector(
&key_2,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key_1)?;
engine.destroy(key_2)?;
sourceunsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
output: &mut GlweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
Unsafely encrypts a GLWE ciphertext vector . Read more
sourceimpl GlweCiphertextVectorEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertextVector32> for DefaultEngine
impl GlweCiphertextVectorEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorEncryptionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertextVector32
unsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweCiphertextVector32
Unsafely encrypts a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertextVector64> for DefaultEngine
impl GlweCiphertextVectorEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorEncryptionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertextVector64
unsafe fn encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweCiphertextVector64
Unsafely encrypts a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorTrivialDecryptionEngine<GlweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl GlweCiphertextVectorTrivialDecryptionEngine<GlweCiphertextVector32, PlaintextVector32> for DefaultEngine
sourcefn trivially_decrypt_glwe_ciphertext_vector(
&mut self,
input: &GlweCiphertextVector32
) -> Result<PlaintextVector32, GlweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_glwe_ciphertext_vector(
&mut self,
input: &GlweCiphertextVector32
) -> Result<PlaintextVector32, GlweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u32 << 20; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector32 = engine
.trivially_encrypt_glwe_ciphertext_vector(
glwe_dimension.to_glwe_size(),
ciphertext_count,
&plaintext_vector,
)?;
let output: PlaintextVector32 =
engine.trivially_decrypt_glwe_ciphertext_vector(&ciphertext_vector)?;
assert_eq!(output.plaintext_count(), PlaintextCount(8));
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
input: &GlweCiphertextVector32
) -> PlaintextVector32
unsafe fn trivially_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
input: &GlweCiphertextVector32
) -> PlaintextVector32
Unsafely trivially decrypts a GLWE ciphertext vector into a plaintext vector. Read more
sourceimpl GlweCiphertextVectorTrivialDecryptionEngine<GlweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl GlweCiphertextVectorTrivialDecryptionEngine<GlweCiphertextVector64, PlaintextVector64> for DefaultEngine
sourcefn trivially_decrypt_glwe_ciphertext_vector(
&mut self,
input: &GlweCiphertextVector64
) -> Result<PlaintextVector64, GlweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_glwe_ciphertext_vector(
&mut self,
input: &GlweCiphertextVector64
) -> Result<PlaintextVector64, GlweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u64 << 50; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector64 = engine
.trivially_encrypt_glwe_ciphertext_vector(
glwe_dimension.to_glwe_size(),
ciphertext_count,
&plaintext_vector,
)?;
let output: PlaintextVector64 =
engine.trivially_decrypt_glwe_ciphertext_vector(&ciphertext_vector)?;
assert_eq!(output.plaintext_count(), PlaintextCount(8));
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
input: &GlweCiphertextVector64
) -> PlaintextVector64
unsafe fn trivially_decrypt_glwe_ciphertext_vector_unchecked(
&mut self,
input: &GlweCiphertextVector64
) -> PlaintextVector64
Unsafely trivially decrypts a GLWE ciphertext vector into a plaintext vector. Read more
sourceimpl GlweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, GlweCiphertextVector32> for DefaultEngine
impl GlweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, GlweCiphertextVector32> for DefaultEngine
sourcefn trivially_encrypt_glwe_ciphertext_vector(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector32
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_glwe_ciphertext_vector(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector32
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u32 << 20; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector32 = engine
.trivially_encrypt_glwe_ciphertext_vector(
glwe_dimension.to_glwe_size(),
ciphertext_count,
&plaintext_vector,
)?;
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn trivially_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector32
) -> GlweCiphertextVector32
unsafe fn trivially_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector32
) -> GlweCiphertextVector32
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, GlweCiphertextVector64> for DefaultEngine
impl GlweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, GlweCiphertextVector64> for DefaultEngine
sourcefn trivially_encrypt_glwe_ciphertext_vector(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector64
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_glwe_ciphertext_vector(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector64
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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 input = vec![3_u64 << 50; 2 * polynomial_size.0];
let ciphertext_count = GlweCiphertextCount(2);
// 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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: GlweCiphertextVector64 = engine
.trivially_encrypt_glwe_ciphertext_vector(
glwe_dimension.to_glwe_size(),
ciphertext_count,
&plaintext_vector,
)?;
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn trivially_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector64
) -> GlweCiphertextVector64
unsafe fn trivially_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_size: GlweSize,
glwe_ciphertext_count: GlweCiphertextCount,
input: &PlaintextVector64
) -> GlweCiphertextVector64
Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorZeroEncryptionEngine<GlweSecretKey32, GlweCiphertextVector32> for DefaultEngine
impl GlweCiphertextVectorZeroEncryptionEngine<GlweSecretKey32, GlweCiphertextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorZeroEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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(1024);
let ciphertext_count = GlweCiphertextCount(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: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext_vector =
engine.zero_encrypt_glwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(key)?;
sourceunsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector32
unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector32
Unsafely encrypts zero in a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextVectorZeroEncryptionEngine<GlweSecretKey64, GlweCiphertextVector64> for DefaultEngine
impl GlweCiphertextVectorZeroEncryptionEngine<GlweSecretKey64, GlweCiphertextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorZeroEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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(1024);
let ciphertext_count = GlweCiphertextCount(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: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext_vector =
engine.zero_encrypt_glwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.glwe_ciphertext_count(), ciphertext_count);
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(key)?;
sourceunsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector64
unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance,
count: GlweCiphertextCount
) -> GlweCiphertextVector64
Unsafely encrypts zero in a GLWE ciphertext vector. Read more
sourceimpl GlweCiphertextZeroEncryptionEngine<GlweSecretKey32, GlweCiphertext32> for DefaultEngine
impl GlweCiphertextZeroEncryptionEngine<GlweSecretKey32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of GlweCiphertextZeroEncryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> Result<GlweCiphertext32, GlweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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(1024);
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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext = engine.zero_encrypt_glwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
sourceunsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> GlweCiphertext32
unsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
noise: Variance
) -> GlweCiphertext32
Unsafely encrypts a zero in a GLWE ciphertext. Read more
sourceimpl GlweCiphertextZeroEncryptionEngine<GlweSecretKey64, GlweCiphertext64> for DefaultEngine
impl GlweCiphertextZeroEncryptionEngine<GlweSecretKey64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of GlweCiphertextZeroEncryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_glwe_ciphertext(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> Result<GlweCiphertext64, GlweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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(1024);
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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let ciphertext = engine.zero_encrypt_glwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
sourceunsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> GlweCiphertext64
unsafe fn zero_encrypt_glwe_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
noise: Variance
) -> GlweCiphertext64
Unsafely encrypts a zero in a GLWE ciphertext. Read more
sourceimpl GlweSecretKeyCreationEngine<GlweSecretKey32> for DefaultEngine
impl GlweSecretKeyCreationEngine<GlweSecretKey32> for DefaultEngine
Description:
Implementation of GlweSecretKeyCreationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, GlweSecretKeyCreationError<Self::EngineError>>
fn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, GlweSecretKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
engine.destroy(glwe_secret_key)?;
sourceunsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
unsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
Unsafely creates a new GLWE secret key. Read more
sourceimpl GlweSecretKeyCreationEngine<GlweSecretKey64> for DefaultEngine
impl GlweSecretKeyCreationEngine<GlweSecretKey64> for DefaultEngine
Description:
Implementation of GlweSecretKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, GlweSecretKeyCreationError<Self::EngineError>>
fn create_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, GlweSecretKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
engine.destroy(glwe_secret_key)?;
sourceunsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
unsafe fn create_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
Unsafely creates a new GLWE secret key. Read more
sourceimpl GlweSeededCiphertextEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweSeededCiphertext32> for DefaultEngine
impl GlweSeededCiphertextEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweSeededCiphertext32> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextEncryptionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn encrypt_glwe_seeded_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweSeededCiphertext32, GlweSeededCiphertextEncryptionError<Self::EngineError>>
fn encrypt_glwe_seeded_ciphertext(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweSeededCiphertext32, GlweSeededCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(seeded_ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(seeded_ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(seeded_ciphertext)?;
sourceunsafe fn encrypt_glwe_seeded_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweSeededCiphertext32
unsafe fn encrypt_glwe_seeded_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweSeededCiphertext32
Unsafely encrypts a seeded GLWE ciphertext. Read more
sourceimpl GlweSeededCiphertextEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweSeededCiphertext64> for DefaultEngine
impl GlweSeededCiphertextEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweSeededCiphertext64> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextEncryptionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn encrypt_glwe_seeded_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweSeededCiphertext64, GlweSeededCiphertextEncryptionError<Self::EngineError>>
fn encrypt_glwe_seeded_ciphertext(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweSeededCiphertext64, GlweSeededCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(seeded_ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(seeded_ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(seeded_ciphertext)?;
sourceunsafe fn encrypt_glwe_seeded_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweSeededCiphertext64
unsafe fn encrypt_glwe_seeded_ciphertext_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweSeededCiphertext64
Unsafely encrypts a seeded GLWE ciphertext. Read more
sourceimpl GlweSeededCiphertextToGlweCiphertextTransformationEngine<GlweSeededCiphertext32, GlweCiphertext32> for DefaultEngine
impl GlweSeededCiphertextToGlweCiphertextTransformationEngine<GlweSeededCiphertext32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextToGlweCiphertextTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn transform_glwe_seeded_ciphertext_to_glwe_ciphertext(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext32
) -> Result<GlweCiphertext32, GlweSeededCiphertextToGlweCiphertextTransformationEngineError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext32
) -> Result<GlweCiphertext32, GlweSeededCiphertextToGlweCiphertextTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
let ciphertext =
engine.transform_glwe_seeded_ciphertext_to_glwe_ciphertext(seeded_ciphertext)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext_unchecked(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext32
) -> GlweCiphertext32
unsafe fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext_unchecked(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext32
) -> GlweCiphertext32
Unsafely transforms a GLWE seeded ciphertext into a GLWE ciphertext Read more
sourceimpl GlweSeededCiphertextToGlweCiphertextTransformationEngine<GlweSeededCiphertext64, GlweCiphertext64> for DefaultEngine
impl GlweSeededCiphertextToGlweCiphertextTransformationEngine<GlweSeededCiphertext64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextToGlweCiphertextTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn transform_glwe_seeded_ciphertext_to_glwe_ciphertext(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext64
) -> Result<GlweCiphertext64, GlweSeededCiphertextToGlweCiphertextTransformationEngineError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext64
) -> Result<GlweCiphertext64, GlweSeededCiphertextToGlweCiphertextTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
let ciphertext =
engine.transform_glwe_seeded_ciphertext_to_glwe_ciphertext(seeded_ciphertext)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext)?;
sourceunsafe fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext_unchecked(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext64
) -> GlweCiphertext64
unsafe fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext_unchecked(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext64
) -> GlweCiphertext64
Unsafely transforms a GLWE seeded ciphertext into a GLWE ciphertext Read more
sourceimpl GlweSeededCiphertextVectorEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweSeededCiphertextVector32> for DefaultEngine
impl GlweSeededCiphertextVectorEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweSeededCiphertextVector32> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextVectorEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn encrypt_glwe_seeded_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweSeededCiphertextVector32, GlweSeededCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_glwe_seeded_ciphertext_vector(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<GlweSeededCiphertextVector32, GlweSeededCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(seeded_ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(seeded_ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(seeded_ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn encrypt_glwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweSeededCiphertextVector32
unsafe fn encrypt_glwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> GlweSeededCiphertextVector32
Unsafely encrypts a GLWE seeded ciphertext vector. Read more
sourceimpl GlweSeededCiphertextVectorEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweSeededCiphertextVector64> for DefaultEngine
impl GlweSeededCiphertextVectorEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweSeededCiphertextVector64> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextVectorEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn encrypt_glwe_seeded_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweSeededCiphertextVector64, GlweSeededCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_glwe_seeded_ciphertext_vector(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<GlweSeededCiphertextVector64, GlweSeededCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(seeded_ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(seeded_ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(seeded_ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn encrypt_glwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweSeededCiphertextVector64
unsafe fn encrypt_glwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &GlweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> GlweSeededCiphertextVector64
Unsafely encrypts a GLWE seeded ciphertext vector. Read more
sourceimpl GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine<GlweSeededCiphertextVector32, GlweCiphertextVector32> for DefaultEngine
impl GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine<GlweSeededCiphertextVector32, GlweCiphertextVector32> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector32
) -> Result<GlweCiphertextVector32, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngineError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector32
) -> Result<GlweCiphertextVector32, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let ciphertext_vector = engine.transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(seeded_ciphertext_vector)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector32
) -> GlweCiphertextVector32
unsafe fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector32
) -> GlweCiphertextVector32
Unsafely transforms a GLWE seeded ciphertext vector into a GLWE ciphertext vector Read more
sourceimpl GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine<GlweSeededCiphertextVector64, GlweCiphertextVector64> for DefaultEngine
impl GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine<GlweSeededCiphertextVector64, GlweCiphertextVector64> for DefaultEngine
Description:
Implementation of GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector64
) -> Result<GlweCiphertextVector64, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngineError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector64
) -> Result<GlweCiphertextVector64, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{GlweCiphertextCount, GlweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let ciphertext_vector = engine.transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(seeded_ciphertext_vector)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
engine.destroy(ciphertext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(key)?;
sourceunsafe fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector64
) -> GlweCiphertextVector64
unsafe fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector_unchecked(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector64
) -> GlweCiphertextVector64
Unsafely transforms a GLWE seeded ciphertext vector into a GLWE ciphertext vector Read more
sourceimpl GlweToLweSecretKeyTransformationEngine<GlweSecretKey32, LweSecretKey32> for DefaultEngine
impl GlweToLweSecretKeyTransformationEngine<GlweSecretKey32, LweSecretKey32> for DefaultEngine
sourcefn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> Result<LweSecretKey32, GlweToLweSecretKeyTransformationEngineError<Self::EngineError>>
fn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> Result<LweSecretKey32, GlweToLweSecretKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
let lwe_secret_key = engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
engine.destroy(lwe_secret_key)?;
sourceunsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> LweSecretKey32
unsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> LweSecretKey32
Unsafely transforms a GLWE secret key into an LWE secret key Read more
sourceimpl GlweToLweSecretKeyTransformationEngine<GlweSecretKey64, LweSecretKey64> for DefaultEngine
impl GlweToLweSecretKeyTransformationEngine<GlweSecretKey64, LweSecretKey64> for DefaultEngine
sourcefn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransformationEngineError<Self::EngineError>>
fn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
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);
// 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.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
let lwe_secret_key = engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_secret_key)?;
assert_eq!(lwe_secret_key.lwe_dimension(), LweDimension(8));
engine.destroy(lwe_secret_key)?;
sourceunsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> LweSecretKey64
unsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> LweSecretKey64
Unsafely transforms a GLWE secret key into an LWE secret key Read more
sourceimpl LweBootstrapKeyCreationEngine<LweSecretKey32, GlweSecretKey32, LweBootstrapKey32> for DefaultEngine
impl LweBootstrapKeyCreationEngine<LweSecretKey32, GlweSecretKey32, LweBootstrapKey32> for DefaultEngine
Description:
Implementation of LweBootstrapKeyCreationEngine
for DefaultEngine
that operates on
32 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
Unsafely creates an LWE bootstrap key. Read more
sourceimpl LweBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultEngine
impl LweBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultEngine
Description:
Implementation of LweBootstrapKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
engine.create_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
unsafe fn create_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
Unsafely creates an LWE bootstrap key. Read more
sourceimpl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertext32, Cleartext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertext32, Cleartext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
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 cleartext: Cleartext32 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(cleartext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Cleartext32
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertext64, Cleartext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertext64, Cleartext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 cleartext_input = 12_u64;
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 cleartext: Cleartext64 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(cleartext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Cleartext64
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView32<'_>, Cleartext32, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView32<'_>, Cleartext32, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for DefaultEngine
that operates on views containing 32 bits integers.
sourcefn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Cleartext32
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Cleartext32
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
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 cleartext: Cleartext32 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(cleartext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Cleartext32
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Cleartext32
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView64<'_>, Cleartext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView64<'_>, Cleartext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for DefaultEngine
that operates on views containing 64 bits integers.
sourcefn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 cleartext_input = 12_u64;
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 cleartext: Cleartext64 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(cleartext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl LweCiphertextCleartextFusingMultiplicationEngine<LweCiphertext32, Cleartext32> for DefaultEngine
impl LweCiphertextCleartextFusingMultiplicationEngine<LweCiphertext32, Cleartext32> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextFusingMultiplicationEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
fn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input = 3_u32 << 20;
let cleartext_input = 12_u32;
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 cleartext: Cleartext32 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_mul_lwe_ciphertext_cleartext(&mut ciphertext, &cleartext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(cleartext)?;
sourceunsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
)
unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Cleartext32
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl LweCiphertextCleartextFusingMultiplicationEngine<LweCiphertext64, Cleartext64> for DefaultEngine
impl LweCiphertextCleartextFusingMultiplicationEngine<LweCiphertext64, Cleartext64> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextFusingMultiplicationEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
fn fuse_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
) -> Result<(), LweCiphertextCleartextFusingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 cleartext_input = 12_u64;
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 cleartext: Cleartext64 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_mul_lwe_ciphertext_cleartext(&mut ciphertext, &cleartext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(cleartext)?;
sourceunsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
)
unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Cleartext64
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl LweCiphertextConsumingRetrievalEngine<LweCiphertext32, Vec<u32, Global>> for DefaultEngine
impl LweCiphertextConsumingRetrievalEngine<LweCiphertext32, Vec<u32, Global>> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying vec of a LweCiphertext32
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertext32
) -> Result<Vec<u32>, LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertext32
) -> Result<Vec<u32>, LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let original_vec_ptr = owned_container.as_ptr();
// 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 ciphertext: LweCiphertext32 = engine.create_lwe_ciphertext(owned_container)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertext32
) -> Vec<u32>
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertext32
) -> Vec<u32>
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl LweCiphertextConsumingRetrievalEngine<LweCiphertext64, Vec<u64, Global>> for DefaultEngine
impl LweCiphertextConsumingRetrievalEngine<LweCiphertext64, Vec<u64, Global>> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying vec of a LweCiphertext64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertext64
) -> Result<Vec<u64>, LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertext64
) -> Result<Vec<u64>, LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let original_vec_ptr = owned_container.as_ptr();
// 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 ciphertext: LweCiphertext64 = engine.create_lwe_ciphertext(owned_container)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext(ciphertext)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertext64
) -> Vec<u64>
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertext64
) -> Vec<u64>
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextMutView32<'data>, &'data mut [u32]> for DefaultEngine
impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextMutView32<'data>, &'data mut [u32]> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a LweCiphertextMutView32
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextMutView32<'data>
) -> Result<&'data mut [u32], LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextMutView32<'data>
) -> Result<&'data mut [u32], LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
// 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 ciphertext_view: LweCiphertextMutView32 = engine.create_lwe_ciphertext(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextMutView32<'data>
) -> &'data mut [u32]
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextMutView32<'data>
) -> &'data mut [u32]
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextMutView64<'data>, &'data mut [u64]> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a LweCiphertextMutView64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> Result<&'data mut [u64], LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> Result<&'data mut [u64], LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
// 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 ciphertext_view: LweCiphertextMutView64 = engine.create_lwe_ciphertext(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> &'data mut [u64]
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextView32<'data>, &'data [u32]> for DefaultEngine
impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextView32<'data>, &'data [u32]> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a LweCiphertextView32
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextView32<'data>
) -> Result<&'data [u32], LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextView32<'data>
) -> Result<&'data [u32], LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextView32<'data>
) -> &'data [u32]
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextView32<'data>
) -> &'data [u32]
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextView64<'data>, &'data [u64]> for DefaultEngine
impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextView64<'data>, &'data [u64]> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a LweCiphertextView64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextView64<'data>
) -> Result<&'data [u64], LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextView64<'data>
) -> Result<&'data [u64], LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: LweCiphertextView64 = engine.create_lwe_ciphertext(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextView64<'data>
) -> &'data [u64]
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextView64<'data>
) -> &'data [u64]
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> LweCiphertextCreationEngine<&'data [u32], LweCiphertextView32<'data>> for DefaultEngine
impl<'data> LweCiphertextCreationEngine<&'data [u32], LweCiphertextView32<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns an
immutable LweCiphertextView32
that does not own its memory.
sourcefn create_lwe_ciphertext(
&mut self,
container: &'data [u32]
) -> Result<LweCiphertextView32<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: &'data [u32]
) -> Result<LweCiphertextView32<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let slice = &owned_container[..];
// 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 ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext(slice)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data [u32]
) -> LweCiphertextView32<'data>
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data [u32]
) -> LweCiphertextView32<'data>
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl<'data> LweCiphertextCreationEngine<&'data [u64], LweCiphertextView64<'data>> for DefaultEngine
impl<'data> LweCiphertextCreationEngine<&'data [u64], LweCiphertextView64<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns an
immutable LweCiphertextView64
that does not own its memory.
sourcefn create_lwe_ciphertext(
&mut self,
container: &'data [u64]
) -> Result<LweCiphertextView64<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: &'data [u64]
) -> Result<LweCiphertextView64<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let mut owned_container = vec![0_u64; 128];
let slice = &owned_container[..];
// 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 ciphertext_view: LweCiphertextView64 = engine.create_lwe_ciphertext(slice)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data [u64]
) -> LweCiphertextView64<'data>
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data [u64]
) -> LweCiphertextView64<'data>
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl<'data> LweCiphertextCreationEngine<&'data mut [u32], LweCiphertextMutView32<'data>> for DefaultEngine
impl<'data> LweCiphertextCreationEngine<&'data mut [u32], LweCiphertextMutView32<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns a mutable
LweCiphertextMutView32
that does not own its memory.
sourcefn create_lwe_ciphertext(
&mut self,
container: &'data mut [u32]
) -> Result<LweCiphertextMutView32<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: &'data mut [u32]
) -> Result<LweCiphertextMutView32<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u32; lwe_size.0];
let slice = &mut owned_container[..];
// 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 ciphertext_view: LweCiphertextMutView32 = engine.create_lwe_ciphertext(slice)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u32]
) -> LweCiphertextMutView32<'data>
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u32]
) -> LweCiphertextMutView32<'data>
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl<'data> LweCiphertextCreationEngine<&'data mut [u64], LweCiphertextMutView64<'data>> for DefaultEngine
impl<'data> LweCiphertextCreationEngine<&'data mut [u64], LweCiphertextMutView64<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns a mutable
LweCiphertextMutView64
that does not own its memory.
sourcefn create_lwe_ciphertext(
&mut self,
container: &'data mut [u64]
) -> Result<LweCiphertextMutView64<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: &'data mut [u64]
) -> Result<LweCiphertextMutView64<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let slice = &mut owned_container[..];
// 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 ciphertext_view: LweCiphertextMutView64 = engine.create_lwe_ciphertext(slice)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u64]
) -> LweCiphertextMutView64<'data>
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u64]
) -> LweCiphertextMutView64<'data>
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl LweCiphertextCreationEngine<Vec<u32, Global>, LweCiphertext32> for DefaultEngine
impl LweCiphertextCreationEngine<Vec<u32, Global>, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns an
LweCiphertext32
.
sourcefn create_lwe_ciphertext(
&mut self,
container: Vec<u32>
) -> Result<LweCiphertext32, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: Vec<u32>
) -> Result<LweCiphertext32, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let owned_container = vec![0_u32; lwe_size.0];
// 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 ciphertext: LweCiphertext32 = engine.create_lwe_ciphertext(owned_container)?;
engine.destroy(ciphertext)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: Vec<u32>
) -> LweCiphertext32
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: Vec<u32>
) -> LweCiphertext32
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl LweCiphertextCreationEngine<Vec<u64, Global>, LweCiphertext64> for DefaultEngine
impl LweCiphertextCreationEngine<Vec<u64, Global>, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns an
LweCiphertext64
.
sourcefn create_lwe_ciphertext(
&mut self,
container: Vec<u64>
) -> Result<LweCiphertext64, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: Vec<u64>
) -> Result<LweCiphertext64, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(128);
let owned_container = vec![0_u64; lwe_size.0];
// 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 ciphertext: LweCiphertext64 = engine.create_lwe_ciphertext(owned_container)?;
engine.destroy(ciphertext)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: Vec<u64>
) -> LweCiphertext64
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: Vec<u64>
) -> LweCiphertext64
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertext32, Plaintext32> for DefaultEngine
impl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertext32, Plaintext32> for DefaultEngine
Description:
Implementation of LweCiphertextDecryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext)?;
sourceunsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Plaintext32
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertext32
) -> Plaintext32
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertextView32<'_>, Plaintext32> for DefaultEngine
impl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertextView32<'_>, Plaintext32> for DefaultEngine
Description:
Implementation of LweCiphertextDecryptionEngine
for DefaultEngine
that operates on
an LweCiphertextView32
containing 32 bits integers.
sourcefn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextView32<'_>
) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextView32<'_>
) -> Result<Plaintext32, LweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut raw_ciphertext[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_view, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
let ciphertext_view: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext[..])?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_view)?;
engine.destroy(decrypted_plaintext)?;
sourceunsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextView32<'_>
) -> Plaintext32
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextView32<'_>
) -> Plaintext32
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextDecryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(decrypted_plaintext)?;
sourceunsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Plaintext64
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertext64
) -> Plaintext64
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertextView64<'_>, Plaintext64> for DefaultEngine
impl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertextView64<'_>, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextDecryptionEngine
for DefaultEngine
that operates on
an LweCiphertextView64
containing 64 bits integers.
sourcefn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Result<Plaintext64, LweCiphertextDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input = 3_u64 << 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: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut raw_ciphertext[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_view, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
let ciphertext_view: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext[..])?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_view)?;
engine.destroy(decrypted_plaintext)?;
sourceunsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Plaintext64
unsafe fn decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextView64<'_>
) -> Plaintext64
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingAdditionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingAdditionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingAdditionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
let mut ciphertext_3 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
)
Unsafely adds two LWE ciphertexts. Read more
sourceimpl LweCiphertextDiscardingAdditionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingAdditionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingAdditionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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_1 = 3_u64 << 50;
let input_2 = 7_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
let mut ciphertext_3 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
)
Unsafely adds two LWE ciphertexts. Read more
sourceimpl LweCiphertextDiscardingAdditionEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingAdditionEngine
for DefaultEngine
that operates
on views containing 32 bits integers.
sourcefn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &LweCiphertextView32<'_>
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &LweCiphertextView32<'_>
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext_1, noise)?;
let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_2, &plaintext_2, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_2[..])?;
let mut ciphertext_3_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_3: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_3_container[..])?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &LweCiphertextView32<'_>
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &LweCiphertextView32<'_>
)
Unsafely adds two LWE ciphertexts. Read more
sourceimpl LweCiphertextDiscardingAdditionEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingAdditionEngine
for DefaultEngine
that operates
on on views containing 64 bits integers.
sourcefn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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_1 = 3_u64 << 50;
let input_2 = 7_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext_1, noise)?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_2, &plaintext_2, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_2[..])?;
let mut ciphertext_3_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_3: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_3_container[..])?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
)
Unsafely adds two LWE ciphertexts. Read more
sourceimpl LweCiphertextDiscardingDecryptionEngine<LweSecretKey32, LweCiphertext32, Plaintext32> for DefaultEngine
impl LweCiphertextDiscardingDecryptionEngine<LweSecretKey32, LweCiphertext32, Plaintext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingDecryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_decrypt_lwe_ciphertext(&key, &mut plaintext, &ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
)
unsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut Plaintext32,
input: &LweCiphertext32
)
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextDiscardingDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingDecryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_decrypt_lwe_ciphertext(&key, &mut plaintext, &ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
)
unsafe fn discard_decrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut Plaintext64,
input: &LweCiphertext64
)
Unsafely decrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertext32,
input: &Plaintext32,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextMutView32<'_>,
input: &Plaintext32,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextMutView32<'_>,
input: &Plaintext32,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut output_cipertext_container = vec![0_32; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut output_cipertext_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(output_ciphertext)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextMutView32<'_>,
input: &Plaintext32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextMutView32<'_>,
input: &Plaintext32,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertext64,
input: &Plaintext64,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut output_cipertext_container = vec![0_64; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut output_cipertext_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(output_ciphertext)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingExtractionEngine<GlweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingExtractionEngine<GlweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingExtractionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
fn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
GlweDimension, LweDimension, MonomialIndex, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
// The target LWE dimension should be equal to the polynomial size + 1
// since we're going to extract one sample from the GLWE ciphertext
let lwe_dimension = LweDimension(8);
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// We're going to extract the first one
// 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 glwe_key: GlweSecretKey32 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let glwe_ciphertext = engine.encrypt_glwe_ciphertext(&glwe_key, &plaintext_vector, noise)?;
// We first create an LWE ciphertext encrypting zeros
let mut lwe_ciphertext = engine.zero_encrypt_lwe_ciphertext(&lwe_key, noise)?;
// Then we extract the first sample from the GLWE ciphertext to store it into the LWE
engine.discard_extract_lwe_ciphertext(
&mut lwe_ciphertext,
&glwe_ciphertext,
MonomialIndex(0),
)?;
assert_eq!(lwe_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(glwe_key)?;
engine.destroy(lwe_key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(glwe_ciphertext)?;
engine.destroy(lwe_ciphertext)?;
sourceunsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
)
unsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &GlweCiphertext32,
nth: MonomialIndex
)
Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingExtractionEngine<GlweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingExtractionEngine<GlweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingExtractionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
fn discard_extract_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
) -> Result<(), LweCiphertextDiscardingExtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
GlweDimension, LweDimension, MonomialIndex, PolynomialSize,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
// The target LWE dimension should be equal to the polynomial size + 1
// since we're going to extract one sample from the GLWE ciphertext
let lwe_dimension = LweDimension(8);
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// We're going to extract the first one
// 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 glwe_key: GlweSecretKey64 =
engine.create_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector(&input)?;
let glwe_ciphertext = engine.encrypt_glwe_ciphertext(&glwe_key, &plaintext_vector, noise)?;
// We first create an LWE ciphertext encrypting zeros
let mut lwe_ciphertext = engine.zero_encrypt_lwe_ciphertext(&lwe_key, noise)?;
// Then we extract the first sample from the GLWE ciphertext to store it into the LWE
engine.discard_extract_lwe_ciphertext(
&mut lwe_ciphertext,
&glwe_ciphertext,
MonomialIndex(0),
)?;
assert_eq!(lwe_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(glwe_key)?;
engine.destroy(lwe_key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(glwe_ciphertext)?;
engine.destroy(lwe_ciphertext)?;
sourceunsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
)
unsafe fn discard_extract_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &GlweCiphertext64,
nth: MonomialIndex
)
Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.));
// 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 input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&input_key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&output_key, noise)?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32,
ksk: &LweKeyswitchKey32
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on views containing 32 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.));
// 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 input_key: LweSecretKey32 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext_1_container = vec![0_u32; input_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&input_key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut raw_ciphertext_2_container = vec![0_u32; output_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_2_container[..])?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>,
ksk: &LweKeyswitchKey32
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.));
// 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 input_key: LweSecretKey64 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&input_key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&output_key, noise)?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64,
ksk: &LweKeyswitchKey64
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on views containing 64 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.));
// 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 input_key: LweSecretKey64 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext_1_container = vec![0_u64; input_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&input_key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut raw_ciphertext_2_container = vec![0_u64; output_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_2_container[..])?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingOppositeEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingOppositeEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingOppositeEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
fn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
unsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingOppositeEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingOppositeEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingOppositeEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
fn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
unsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingOppositeEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextDiscardingOppositeEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingOppositeEngine
for DefaultEngine
that operates
on views containing 32 bits integers.
sourcefn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
fn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>
)
unsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input: &LweCiphertextView32<'_>
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingOppositeEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingOppositeEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingOppositeEngine
for DefaultEngine
that operates
on views containing 64 bits integers.
sourcefn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
fn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
)
unsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingSubtractionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingSubtractionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingSubtractionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
) -> Result<(), LweCiphertextDiscardingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 7_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
let mut ciphertext_3 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_sub_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
)
unsafe fn discard_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &LweCiphertext32
)
Unsafely substracts two LWE ciphertexts. Read more
sourceimpl LweCiphertextDiscardingSubtractionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingSubtractionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingSubtractionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
) -> Result<(), LweCiphertextDiscardingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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_1 = 3_u64 << 50;
let input_2 = 7_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
let mut ciphertext_3 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_sub_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
)
unsafe fn discard_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &LweCiphertext64
)
Unsafely substracts two LWE ciphertexts. Read more
sourceimpl LweCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextEncryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> Result<LweCiphertext32, LweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> Result<LweCiphertext32, LweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> LweCiphertext32
unsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> LweCiphertext32
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextEncryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweCiphertext64
unsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweCiphertext64
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextFusingAdditionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextFusingAdditionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextFusingAdditionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
engine.fuse_add_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(ciphertext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
unsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
Unsafely add an LWE ciphertext to an other. Read more
sourceimpl LweCiphertextFusingAdditionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextFusingAdditionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextFusingAdditionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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_1 = 3_u64 << 50;
let input_2 = 5_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
engine.fuse_add_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(ciphertext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
unsafe fn fuse_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
Unsafely add an LWE ciphertext to an other. Read more
sourceimpl LweCiphertextFusingOppositeEngine<LweCiphertext32> for DefaultEngine
impl LweCiphertextFusingOppositeEngine<LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextFusingOppositeEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn fuse_opp_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext32
) -> Result<(), LweCiphertextFusingOppositeError<Self::EngineError>>
fn fuse_opp_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext32
) -> Result<(), LweCiphertextFusingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_opp_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext32
)
unsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext32
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextFusingOppositeEngine<LweCiphertext64> for DefaultEngine
impl LweCiphertextFusingOppositeEngine<LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextFusingOppositeEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn fuse_opp_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext64
) -> Result<(), LweCiphertextFusingOppositeError<Self::EngineError>>
fn fuse_opp_lwe_ciphertext(
&mut self,
input: &mut LweCiphertext64
) -> Result<(), LweCiphertextFusingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_opp_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext64
)
unsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext64
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextFusingSubtractionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextFusingSubtractionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextFusingSubtractionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn fuse_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
) -> Result<(), LweCiphertextFusingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
engine.fuse_sub_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(ciphertext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn fuse_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
unsafe fn fuse_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &LweCiphertext32
)
Unsafely subtracts an LWE ciphertext to another. Read more
sourceimpl LweCiphertextFusingSubtractionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextFusingSubtractionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextFusingSubtractionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn fuse_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
) -> Result<(), LweCiphertextFusingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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_1 = 3_u64 << 50;
let input_2 = 5_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
let mut ciphertext_2 = engine.encrypt_lwe_ciphertext(&key, &plaintext_2, noise)?;
engine.fuse_sub_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(ciphertext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn fuse_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
unsafe fn fuse_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &LweCiphertext64
)
Unsafely subtracts an LWE ciphertext to another. Read more
sourceimpl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertext32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertext32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
)
Unsafely adds a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertext64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertext64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
)
Unsafely adds a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView32<'_>, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine
impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView32<'_>, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine
for DefaultEngine
that
operates on views containing 32 bits integers.
sourcefn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView32 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2 = engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Plaintext32
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView32<'_>,
input_1: &LweCiphertextView32<'_>,
input_2: &Plaintext32
)
Unsafely adds a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView64<'_>, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView64<'_>, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine
for DefaultEngine
that
operates on views containing 64 bits integers.
sourcefn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2 = engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
)
Unsafely adds a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextDiscardingSubtractionEngine<LweCiphertext32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextPlaintextDiscardingSubtractionEngine<LweCiphertext32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingSubtractionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn discard_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
) -> Result<(), LweCiphertextPlaintextDiscardingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_sub_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
)
unsafe fn discard_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input_1: &LweCiphertext32,
input_2: &Plaintext32
)
Unsafely subtracts a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextDiscardingSubtractionEngine<LweCiphertext64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextPlaintextDiscardingSubtractionEngine<LweCiphertext64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingSubtractionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_sub_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
)
unsafe fn discard_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input_1: &LweCiphertext64,
input_2: &Plaintext64
)
Unsafely subtracts a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextFusingAdditionEngine<LweCiphertext32, Plaintext32> for DefaultEngine
impl LweCiphertextPlaintextFusingAdditionEngine<LweCiphertext32, Plaintext32> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextFusingAdditionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
engine.fuse_add_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext)?;
sourceunsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
)
unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
)
Unsafely add a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextFusingAdditionEngine<LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextPlaintextFusingAdditionEngine<LweCiphertext64, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextFusingAdditionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 40 bits)
let input_1 = 3_u64 << 40;
let input_2 = 5_u64 << 40;
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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
engine.fuse_add_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext)?;
sourceunsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
)
unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
)
Unsafely add a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextFusingSubtractionEngine<LweCiphertext32, Plaintext32> for DefaultEngine
impl LweCiphertextPlaintextFusingSubtractionEngine<LweCiphertext32, Plaintext32> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextFusingSubtractionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn fuse_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextPlaintextFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextPlaintextFusingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_1 = 3_u32 << 20;
let input_2 = 5_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
engine.fuse_sub_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext)?;
sourceunsafe fn fuse_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
)
unsafe fn fuse_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext32,
input: &Plaintext32
)
Unsafely subtracts a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextPlaintextFusingSubtractionEngine<LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextPlaintextFusingSubtractionEngine<LweCiphertext64, Plaintext64> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextFusingSubtractionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn fuse_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextPlaintextFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextPlaintextFusingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 40 bits)
let input_1 = 3_u64 << 40;
let input_2 = 5_u64 << 40;
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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext_1, noise)?;
engine.fuse_sub_lwe_ciphertext_plaintext(&mut ciphertext, &plaintext_2)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext)?;
sourceunsafe fn fuse_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
)
unsafe fn fuse_sub_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertext64,
input: &Plaintext64
)
Unsafely subtracts a plaintext to an LWE ciphertext. Read more
sourceimpl LweCiphertextTrivialDecryptionEngine<LweCiphertext32, Plaintext32> for DefaultEngine
impl LweCiphertextTrivialDecryptionEngine<LweCiphertext32, Plaintext32> for DefaultEngine
sourcefn trivially_decrypt_lwe_ciphertext(
&mut self,
input: &LweCiphertext32
) -> Result<Plaintext32, LweCiphertextTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_lwe_ciphertext(
&mut self,
input: &LweCiphertext32
) -> Result<Plaintext32, LweCiphertextTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext32 =
engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;
let output: Plaintext32 = engine.trivially_decrypt_lwe_ciphertext(&ciphertext)?;
let res = engine.retrieve_plaintext(&output)?;
assert_eq!(res, input);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext32
) -> Plaintext32
unsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext32
) -> Plaintext32
Unsafely trivially decrypts an LWE ciphertext into a plaintext. Read more
sourceimpl LweCiphertextTrivialDecryptionEngine<LweCiphertext64, Plaintext64> for DefaultEngine
impl LweCiphertextTrivialDecryptionEngine<LweCiphertext64, Plaintext64> for DefaultEngine
sourcefn trivially_decrypt_lwe_ciphertext(
&mut self,
input: &LweCiphertext64
) -> Result<Plaintext64, LweCiphertextTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_lwe_ciphertext(
&mut self,
input: &LweCiphertext64
) -> Result<Plaintext64, LweCiphertextTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = 3_u64 << 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: Plaintext64 = engine.create_plaintext(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext64 =
engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;
let output: Plaintext64 = engine.trivially_decrypt_lwe_ciphertext(&ciphertext)?;
let res = engine.retrieve_plaintext(&output)?;
assert_eq!(res, input);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext64
) -> Plaintext64
unsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext64
) -> Plaintext64
Unsafely trivially decrypts an LWE ciphertext into a plaintext. Read more
sourceimpl LweCiphertextTrivialEncryptionEngine<Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextTrivialEncryptionEngine<Plaintext32, LweCiphertext32> for DefaultEngine
sourcefn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext32
) -> Result<LweCiphertext32, LweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext32
) -> Result<LweCiphertext32, LweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext32 =
engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;
assert_eq!(ciphertext.lwe_dimension().to_lwe_size(), lwe_size);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext32
) -> LweCiphertext32
unsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext32
) -> LweCiphertext32
Unsafely creates the trivial LWE encryption of the plaintext. Read more
sourceimpl LweCiphertextTrivialEncryptionEngine<Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextTrivialEncryptionEngine<Plaintext64, LweCiphertext64> for DefaultEngine
sourcefn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> Result<LweCiphertext64, LweCiphertextTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> Result<LweCiphertext64, LweCiphertextTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{CiphertextCount, LweSize};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = 3_u64 << 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 plaintext: Plaintext64 = engine.create_plaintext(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext: LweCiphertext64 =
engine.trivially_encrypt_lwe_ciphertext(lwe_size, &plaintext)?;
assert_eq!(ciphertext.lwe_dimension().to_lwe_size(), lwe_size);
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> LweCiphertext64
unsafe fn trivially_encrypt_lwe_ciphertext_unchecked(
&mut self,
lwe_size: LweSize,
input: &Plaintext64
) -> LweCiphertext64
Unsafely creates the trivial LWE encryption of the plaintext. Read more
sourceimpl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDecryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;
// 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; 18];
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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(18)
);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
sourceunsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> PlaintextVector32
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> PlaintextVector32
Unsafely decrypts an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDecryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;
// 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; 18];
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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(18)
);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
sourceunsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> PlaintextVector64
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVector64
) -> PlaintextVector64
Unsafely decrypts an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAdditionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_add_lwe_ciphertext_vector(
&mut output_ciphertext_vector,
&ciphertext_vector,
&ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn discard_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
)
unsafe fn discard_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
)
Unsafely adds two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAdditionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_add_lwe_ciphertext_vector(
&mut output_ciphertext_vector,
&ciphertext_vector,
&ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn discard_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
unsafe fn discard_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
Unsafely adds two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let weights_input = vec![2_u32; 8];
let bias_input = 8_u32 << 20;
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector32 = engine.create_cleartext_vector(&input_vector)?;
let bias: Plaintext32 = engine.create_plaintext(&bias_input)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_affine_transform_lwe_ciphertext_vector(
&mut output_ciphertext,
&ciphertext_vector,
&weights,
&bias,
)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(weights)?;
engine.destroy(bias)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext)?;
sourceunsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
)
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
)
Unsafely performs the affine transform of an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector64, CleartextVector64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector64, CleartextVector64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let weights_input = vec![2_u64; 8];
let bias_input = 8_u64 << 50;
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector64 = engine.create_cleartext_vector(&input_vector)?;
let bias: Plaintext64 = engine.create_plaintext(&bias_input)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_affine_transform_lwe_ciphertext_vector(
&mut output_ciphertext,
&ciphertext_vector,
&weights,
&bias,
)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(weights)?;
engine.destroy(bias)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext)?;
sourceunsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
)
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext64,
inputs: &LweCiphertextVector64,
weights: &CleartextVector64,
bias: &Plaintext64
)
Unsafely performs the affine transform of an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;
// 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; 18];
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.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_lwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
)
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
)
Unsafely decrypts an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;
// 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; 18];
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.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_lwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
)
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut PlaintextVector64,
input: &LweCiphertextVector64
)
Unsafely decrypts an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;
engine.discard_encrypt_lwe_ciphertext_vector(
&key,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encryprs an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;
engine.discard_encrypt_lwe_ciphertext_vector(
&key,
&mut ciphertext_vector,
&plaintext_vector,
noise,
);
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVector64,
input: &PlaintextVector64,
noise: Variance
)
Unsafely encryprs an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingSubtractionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_sub_lwe_ciphertext_vector(
&mut output_ciphertext_vector,
&ciphertext_vector,
&ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn discard_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
)
unsafe fn discard_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input_1: &LweCiphertextVector32,
input_2: &LweCiphertextVector32
)
Unsafely subtracts two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorDiscardingSubtractionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<Self::EngineError>>
fn discard_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorDiscardingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_sub_lwe_ciphertext_vector(
&mut output_ciphertext_vector,
&ciphertext_vector,
&ciphertext_vector,
)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn discard_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
unsafe fn discard_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input_1: &LweCiphertextVector64,
input_2: &LweCiphertextVector64
)
Unsafely subtracts two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweCiphertextVector32
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweCiphertextVector32
Unsafely encrypts an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweCiphertextVector64, LweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweCiphertextVector64, LweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweCiphertextVector64
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweCiphertextVector64
Unsafely encrypts an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingAdditionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.fuse_add_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn fuse_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
)
unsafe fn fuse_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
)
Unsafely add two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingAdditionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorFusingAdditionError<Self::EngineError>>
fn fuse_add_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorFusingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.fuse_add_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn fuse_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
)
unsafe fn fuse_add_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
)
Unsafely add two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingSubtractionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorFusingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.fuse_sub_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn fuse_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
)
unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector32,
input: &LweCiphertextVector32
)
Unsafely subtracts two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorFusingSubtractionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorFusingSubtractionError<Self::EngineError>>
fn fuse_sub_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
) -> Result<(), LweCiphertextVectorFusingSubtractionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 20 bits)
let input_vector = vec![3_u64 << 50; 8];
let noise = Variance::from_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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.fuse_sub_lwe_ciphertext_vector(&mut output_ciphertext_vector, &ciphertext_vector)?;
assert_eq!(output_ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext_vector)?;
sourceunsafe fn fuse_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
)
unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertextVector64,
input: &LweCiphertextVector64
)
Unsafely subtracts two LWE ciphertext vectors. Read more
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<PackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<PackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &PackingKeyswitchKey32
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &PackingKeyswitchKey32
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 20 bits)
let input_vector = vec![3_u32 << 20, 256];
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
engine.create_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.create_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext_vector = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;
engine.discard_packing_keyswitch_lwe_ciphertext_vector(
&mut ciphertext_output,
&ciphertext_vector,
&packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(packing_keyswitch_key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(ciphertext_output)?;
sourceunsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &PackingKeyswitchKey32
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &PackingKeyswitchKey32
)
Unsafely packing keyswitches an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<PackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<PackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &PackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &PackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_glwe_dimension = GlweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let polynomial_size = PolynomialSize(256);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input_vector = vec![3_u64 << 50, 256];
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
engine.create_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.create_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext_vector = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector =
engine.encrypt_lwe_ciphertext_vector(&input_key, &plaintext_vector, noise)?;
let mut ciphertext_output = engine.zero_encrypt_glwe_ciphertext(&output_key, noise)?;
engine.discard_packing_keyswitch_lwe_ciphertext_vector(
&mut ciphertext_output,
&ciphertext_vector,
&packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(packing_keyswitch_key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(ciphertext_output)?;
sourceunsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &PackingKeyswitchKey64
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &PackingKeyswitchKey64
)
Unsafely packing keyswitches an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine
sourcefn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector32 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
let output: PlaintextVector32 =
engine.trivially_decrypt_lwe_ciphertext_vector(&ciphertext_vector)?;
assert_eq!(output.plaintext_count(), PlaintextCount(3));
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
input: &LweCiphertextVector32
) -> PlaintextVector32
unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
input: &LweCiphertextVector32
) -> PlaintextVector32
Unsafely trivially decrypts an LWE ciphertext vector into a plaintext vector. Read more
sourceimpl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector64, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector64, PlaintextVector64> for DefaultEngine
sourcefn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
fn trivially_decrypt_lwe_ciphertext_vector(
&mut self,
input: &LweCiphertextVector64
) -> Result<PlaintextVector64, LweCiphertextVectorTrivialDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u64 << 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: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector64 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
let output: PlaintextVector64 =
engine.trivially_decrypt_lwe_ciphertext_vector(&ciphertext_vector)?;
assert_eq!(output.plaintext_count(), PlaintextCount(3));
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output)?;
sourceunsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
input: &LweCiphertextVector64
) -> PlaintextVector64
unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
input: &LweCiphertextVector64
) -> PlaintextVector64
Unsafely trivially decrypts an LWE ciphertext vector into a plaintext vector. Read more
sourceimpl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine
sourcefn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
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(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector32 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
assert_eq!(ciphertext_vector.lwe_dimension().to_lwe_size(), lwe_size);
assert_eq!(
ciphertext_vector.lwe_ciphertext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> LweCiphertextVector32
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> LweCiphertextVector32
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
sourceimpl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, LweCiphertextVector64> for DefaultEngine
sourcefn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> Result<LweCiphertextVector64, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> Result<LweCiphertextVector64, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u64 << 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: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
// DISCLAIMER: trivial encryption is NOT secure, and DOES NOT hide the message at all.
let ciphertext_vector: LweCiphertextVector64 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
assert_eq!(ciphertext_vector.lwe_dimension().to_lwe_size(), lwe_size);
assert_eq!(
ciphertext_vector.lwe_ciphertext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> LweCiphertextVector64
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector64
) -> LweCiphertextVector64
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(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.create_lwe_secret_key(lwe_dimension)?;
let ciphertext_vector =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
engine.destroy(key)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
Unsafely encrypts zeros in an LWE ciphertext vector. Read more
sourceimpl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector64, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(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.create_lwe_secret_key(lwe_dimension)?;
let ciphertext_vector =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
engine.destroy(key)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector64
Unsafely encrypts zeros in an LWE ciphertext vector. Read more
sourceimpl LweCiphertextZeroEncryptionEngine<LweSecretKey32, LweCiphertext32> for DefaultEngine
impl LweCiphertextZeroEncryptionEngine<LweSecretKey32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextZeroEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> Result<LweCiphertext32, LweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> Result<LweCiphertext32, LweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
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.create_lwe_secret_key(lwe_dimension)?;
let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
sourceunsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> LweCiphertext32
unsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance
) -> LweCiphertext32
Safely encrypts zero into an LWE ciphertext. Read more
sourceimpl LweCiphertextZeroEncryptionEngine<LweSecretKey64, LweCiphertext64> for DefaultEngine
impl LweCiphertextZeroEncryptionEngine<LweSecretKey64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextZeroEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> Result<LweCiphertext64, LweCiphertextZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
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.create_lwe_secret_key(lwe_dimension)?;
let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(ciphertext)?;
sourceunsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> LweCiphertext64
unsafe fn zero_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
noise: Variance
) -> LweCiphertext64
Safely encrypts zero into an LWE ciphertext. Read more
sourceimpl LweKeyswitchKeyCreationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
Description:
Implementation of LweKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
unsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
Unsafely creates an LWE keyswitch key. Read more
sourceimpl LweKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine
Description:
Implementation of LweKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey64
unsafe fn create_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey64
Unsafely creates an LWE keyswitch key. Read more
sourceimpl LweSecretKeyCreationEngine<LweSecretKey32> for DefaultEngine
impl LweSecretKeyCreationEngine<LweSecretKey32> for DefaultEngine
Description:
Implementation of LweSecretKeyCreationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey32, LweSecretKeyCreationError<Self::EngineError>>
fn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey32, LweSecretKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
engine.destroy(lwe_secret_key)?;
sourceunsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey32
unsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey32
Unsafely creates an LWE secret key. Read more
sourceimpl LweSecretKeyCreationEngine<LweSecretKey64> for DefaultEngine
impl LweSecretKeyCreationEngine<LweSecretKey64> for DefaultEngine
Description:
Implementation of LweSecretKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey64, LweSecretKeyCreationError<Self::EngineError>>
fn create_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey64, LweSecretKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
engine.destroy(lwe_secret_key)?;
sourceunsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey64
unsafe fn create_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey64
Unsafely creates an LWE secret key. Read more
sourceimpl LweSeededBootstrapKeyCreationEngine<LweSecretKey32, GlweSecretKey32, LweSeededBootstrapKey32> for DefaultEngine
impl LweSeededBootstrapKeyCreationEngine<LweSecretKey32, GlweSecretKey32, LweSeededBootstrapKey32> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyCreationEngine
for DefaultEngine
that operates on
32 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn create_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey32, LweSeededBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey32, LweSeededBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweSeededBootstrapKey32 =
engine.create_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn create_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey32
unsafe fn create_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey32
Unsafely creates a seeded LWE bootstrap key. Read more
sourceimpl LweSeededBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultEngine
impl LweSeededBootstrapKeyCreationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyCreationEngine
for DefaultEngine
that operates on
64 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn create_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyCreationError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweSeededBootstrapKey64 =
engine.create_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn create_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey64
unsafe fn create_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey64
Unsafely creates a seeded LWE bootstrap key. Read more
sourceimpl LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine<LweSeededBootstrapKey32, LweBootstrapKey32> for DefaultEngine
impl LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine<LweSeededBootstrapKey32, LweBootstrapKey32> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine
for
DefaultEngine
that operates on 32 bits integers. It outputs a bootstrap key in the
standard domain.
sourcefn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey32
) -> Result<LweBootstrapKey32, LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey32
) -> Result<LweBootstrapKey32, LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let seeded_bsk: LweSeededBootstrapKey32 =
engine.create_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let bsk = engine.transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(seeded_bsk)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key_unchecked(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey32
) -> LweBootstrapKey32
unsafe fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key_unchecked(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey32
) -> LweBootstrapKey32
Unsafely transforms an LWE seeded bootstrap key into an LWE bootstrap key Read more
sourceimpl LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine<LweSeededBootstrapKey64, LweBootstrapKey64> for DefaultEngine
impl LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine<LweSeededBootstrapKey64, LweBootstrapKey64> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngine
for
DefaultEngine
that operates on 64 bits integers. It outputs a bootstrap key in the
standard domain.
sourcefn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey64
) -> Result<LweBootstrapKey64, LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey64
) -> Result<LweBootstrapKey64, LweSeededBootstrapKeyToLweBootstrapKeyTransformationEngineError<Self::EngineError>>
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.create_glwe_secret_key(glwe_dim, poly_size)?;
let seeded_bsk: LweSeededBootstrapKey64 =
engine.create_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let bsk = engine.transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(seeded_bsk)?;
assert_eq!(bsk.glwe_dimension(), glwe_dim);
assert_eq!(bsk.polynomial_size(), poly_size);
assert_eq!(bsk.input_lwe_dimension(), lwe_dim);
assert_eq!(bsk.decomposition_base_log(), dec_bl);
assert_eq!(bsk.decomposition_level_count(), dec_lc);
engine.destroy(lwe_sk)?;
engine.destroy(glwe_sk)?;
engine.destroy(bsk)?;
sourceunsafe fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key_unchecked(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey64
) -> LweBootstrapKey64
unsafe fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key_unchecked(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey64
) -> LweBootstrapKey64
Unsafely transforms an LWE seeded bootstrap key into an LWE bootstrap key Read more
sourceimpl LweSeededCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweSeededCiphertext32> for DefaultEngine
impl LweSeededCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweSeededCiphertext32> for DefaultEngine
Description:
Implementation of LweSeededCiphertextEncryptionEngine
for DefaultEngine
that operates
on 32 bits integers.
sourcefn encrypt_lwe_seeded_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> Result<LweSeededCiphertext32, LweSeededCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_seeded_ciphertext(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> Result<LweSeededCiphertext32, LweSeededCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_lwe_seeded_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> LweSeededCiphertext32
unsafe fn encrypt_lwe_seeded_ciphertext_unchecked(
&mut self,
key: &LweSecretKey32,
input: &Plaintext32,
noise: Variance
) -> LweSeededCiphertext32
Unsafely encrypts a seeded LWE ciphertext. Read more
sourceimpl LweSeededCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweSeededCiphertext64> for DefaultEngine
impl LweSeededCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweSeededCiphertext64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextEncryptionEngine
for DefaultEngine
that operates
on 64 bits integers.
sourcefn encrypt_lwe_seeded_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweSeededCiphertext64, LweSeededCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_seeded_ciphertext(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> Result<LweSeededCiphertext64, LweSeededCiphertextEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn encrypt_lwe_seeded_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweSeededCiphertext64
unsafe fn encrypt_lwe_seeded_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
input: &Plaintext64,
noise: Variance
) -> LweSeededCiphertext64
Unsafely encrypts a seeded LWE ciphertext. Read more
sourceimpl LweSeededCiphertextToLweCiphertextTransformationEngine<LweSeededCiphertext32, LweCiphertext32> for DefaultEngine
impl LweSeededCiphertextToLweCiphertextTransformationEngine<LweSeededCiphertext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweSeededCiphertextToLweCiphertextTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn transform_lwe_seeded_ciphertext_to_lwe_ciphertext(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext32
) -> Result<LweCiphertext32, LweSeededCiphertextToLweCiphertextTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext32
) -> Result<LweCiphertext32, LweSeededCiphertextToLweCiphertextTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let seeded_ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let ciphertext = engine.transform_lwe_seeded_ciphertext_to_lwe_ciphertext(seeded_ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext_unchecked(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext32
) -> LweCiphertext32
unsafe fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext_unchecked(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext32
) -> LweCiphertext32
Unsafely transforms an LWE seeded ciphertext into an LWE ciphertext Read more
sourceimpl LweSeededCiphertextToLweCiphertextTransformationEngine<LweSeededCiphertext64, LweCiphertext64> for DefaultEngine
impl LweSeededCiphertextToLweCiphertextTransformationEngine<LweSeededCiphertext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextToLweCiphertextTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn transform_lwe_seeded_ciphertext_to_lwe_ciphertext(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext64
) -> Result<LweCiphertext64, LweSeededCiphertextToLweCiphertextTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext64
) -> Result<LweCiphertext64, LweSeededCiphertextToLweCiphertextTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let seeded_ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
let ciphertext = engine.transform_lwe_seeded_ciphertext_to_lwe_ciphertext(seeded_ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext)?;
sourceunsafe fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext_unchecked(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext64
) -> LweCiphertext64
unsafe fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext_unchecked(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext64
) -> LweCiphertext64
Unsafely transforms an LWE seeded ciphertext into an LWE ciphertext Read more
sourceimpl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweSeededCiphertextVector32> for DefaultEngine
impl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweSeededCiphertextVector32> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorEncryptionEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn encrypt_lwe_seeded_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweSeededCiphertextVector32, LweSeededCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_seeded_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweSeededCiphertextVector32, LweSeededCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweSeededCiphertextVector32 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweSeededCiphertextVector32
unsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweSeededCiphertextVector32
Unsafely encrypts a seeded LWE ciphertext vector. Read more
sourceimpl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweSeededCiphertextVector64> for DefaultEngine
impl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweSeededCiphertextVector64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn encrypt_lwe_seeded_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweSeededCiphertextVector64, LweSeededCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_seeded_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> Result<LweSeededCiphertextVector64, LweSeededCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweSeededCiphertextVector64 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweSeededCiphertextVector64
unsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &PlaintextVector64,
noise: Variance
) -> LweSeededCiphertextVector64
Unsafely encrypts a seeded LWE ciphertext vector. Read more
sourceimpl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine
impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32
) -> Result<LweCiphertextVector32, LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32
) -> Result<LweCiphertextVector32, LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut seeded_ciphertext_vector: LweSeededCiphertextVector32 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let ciphertext_vector = engine
.transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
seeded_ciphertext_vector,
)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32
) -> LweCiphertextVector32
unsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32
) -> LweCiphertextVector32
Unsafely transforms an LWE seeded ciphertext vector into an LWE ciphertext vector Read more
sourceimpl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector64, LweCiphertextVector64> for DefaultEngine
impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector64, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> Result<LweCiphertextVector64, LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> Result<LweCiphertextVector64, LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let mut seeded_ciphertext_vector: LweSeededCiphertextVector64 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let ciphertext_vector = engine
.transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
seeded_ciphertext_vector,
)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
sourceunsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> LweCiphertextVector64
unsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> LweCiphertextVector64
Unsafely transforms an LWE seeded ciphertext vector into an LWE ciphertext vector Read more
sourceimpl LweSeededKeyswitchKeyCreationEngine<LweSecretKey32, LweSecretKey32, LweSeededKeyswitchKey32> for DefaultEngine
impl LweSeededKeyswitchKeyCreationEngine<LweSecretKey32, LweSecretKey32, LweSeededKeyswitchKey32> for DefaultEngine
sourcefn create_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey32, LweSeededKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey32, LweSeededKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(seeded_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(seeded_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(seeded_keyswitch_key)?;
sourceunsafe fn create_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey32
unsafe fn create_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey32
Unsafely creates a seeded LWE keyswitch key. Read more
sourceimpl LweSeededKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine
impl LweSeededKeyswitchKeyCreationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine
sourcefn create_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey64, LweSeededKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey64, LweSeededKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(seeded_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(seeded_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(seeded_keyswitch_key)?;
sourceunsafe fn create_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey64
unsafe fn create_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey64
Unsafely creates a seeded LWE keyswitch key. Read more
sourceimpl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine
impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine
sourcefn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let keyswitch_key = engine.transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(seeded_keyswitch_key)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> LweKeyswitchKey32
unsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> LweKeyswitchKey32
Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
sourceimpl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey64, LweKeyswitchKey64> for DefaultEngine
impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey64, LweKeyswitchKey64> for DefaultEngine
sourcefn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey64
) -> Result<LweKeyswitchKey64, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey64
) -> Result<LweKeyswitchKey64, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngineError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.create_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let keyswitch_key = engine.transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(seeded_keyswitch_key)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
sourceunsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey64
) -> LweKeyswitchKey64
unsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey64
) -> LweKeyswitchKey64
Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
sourceimpl LweToGlweSecretKeyTransformationEngine<LweSecretKey32, GlweSecretKey32> for DefaultEngine
impl LweToGlweSecretKeyTransformationEngine<LweSecretKey32, GlweSecretKey32> for DefaultEngine
sourcefn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey32,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, LweToGlweSecretKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey32,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, LweToGlweSecretKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(8);
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 lwe_secret_key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
let glwe_secret_key =
engine.transform_lwe_secret_key_to_glwe_secret_key(lwe_secret_key, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), GlweDimension(2));
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
engine.destroy(glwe_secret_key)?;
sourceunsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked(
&mut self,
lwe_secret_key: LweSecretKey32,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
unsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked(
&mut self,
lwe_secret_key: LweSecretKey32,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
Unsafely transforms an LWE secret key into a GLWE secret key Read more
sourceimpl LweToGlweSecretKeyTransformationEngine<LweSecretKey64, GlweSecretKey64> for DefaultEngine
impl LweToGlweSecretKeyTransformationEngine<LweSecretKey64, GlweSecretKey64> for DefaultEngine
sourcefn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, LweToGlweSecretKeyTransformationEngineError<Self::EngineError>>
fn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, LweToGlweSecretKeyTransformationEngineError<Self::EngineError>>
Example
use concrete_commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(8);
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 lwe_secret_key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
let glwe_secret_key =
engine.transform_lwe_secret_key_to_glwe_secret_key(lwe_secret_key, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), GlweDimension(2));
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
engine.destroy(glwe_secret_key)?;
sourceunsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
unsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
Unsafely transforms an LWE secret key into a GLWE secret key Read more
sourceimpl PackingKeyswitchKeyCreationEngine<LweSecretKey32, GlweSecretKey32, PackingKeyswitchKey32> for DefaultEngine
impl PackingKeyswitchKeyCreationEngine<LweSecretKey32, GlweSecretKey32, PackingKeyswitchKey32> for DefaultEngine
Description:
Implementation of PackingKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn create_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<PackingKeyswitchKey32, PackingKeyswitchKeyCreationError<Self::EngineError>>
fn create_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<PackingKeyswitchKey32, PackingKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let packing_keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(packing_keyswitch_key)?;
sourceunsafe fn create_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> PackingKeyswitchKey32
unsafe fn create_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> PackingKeyswitchKey32
Unsafely creates a packing keyswitch key. Read more
sourceimpl PackingKeyswitchKeyCreationEngine<LweSecretKey64, GlweSecretKey64, PackingKeyswitchKey64> for DefaultEngine
impl PackingKeyswitchKeyCreationEngine<LweSecretKey64, GlweSecretKey64, PackingKeyswitchKey64> for DefaultEngine
Description:
Implementation of PackingKeyswitchKeyCreationEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn create_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<PackingKeyswitchKey64, PackingKeyswitchKeyCreationError<Self::EngineError>>
fn create_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<PackingKeyswitchKey64, PackingKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// 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.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let packing_keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(packing_keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(packing_keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(packing_keyswitch_key)?;
sourceunsafe fn create_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> PackingKeyswitchKey64
unsafe fn create_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> PackingKeyswitchKey64
Unsafely creates a packing keyswitch key. Read more
sourceimpl PlaintextCreationEngine<u32, Plaintext32> for DefaultEngine
impl PlaintextCreationEngine<u32, Plaintext32> for DefaultEngine
Description:
Implementation of PlaintextCreationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn create_plaintext(
&mut self,
input: &u32
) -> Result<Plaintext32, PlaintextCreationError<Self::EngineError>>
fn create_plaintext(
&mut self,
input: &u32
) -> Result<Plaintext32, PlaintextCreationError<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(&input)?;
engine.destroy(plaintext)?;
sourceunsafe fn create_plaintext_unchecked(&mut self, input: &u32) -> Plaintext32
unsafe fn create_plaintext_unchecked(&mut self, input: &u32) -> Plaintext32
Unsafely creates a plaintext from an arbitrary value. Read more
sourceimpl PlaintextCreationEngine<u64, Plaintext64> for DefaultEngine
impl PlaintextCreationEngine<u64, Plaintext64> for DefaultEngine
Description:
Implementation of PlaintextCreationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn create_plaintext(
&mut self,
input: &u64
) -> Result<Plaintext64, PlaintextCreationError<Self::EngineError>>
fn create_plaintext(
&mut self,
input: &u64
) -> Result<Plaintext64, PlaintextCreationError<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(&input)?;
engine.destroy(plaintext)?;
sourceunsafe fn create_plaintext_unchecked(&mut self, input: &u64) -> Plaintext64
unsafe fn create_plaintext_unchecked(&mut self, input: &u64) -> Plaintext64
Unsafely creates a plaintext from an arbitrary value. Read more
sourceimpl PlaintextDecodingEngine<FloatEncoder, Plaintext32, CleartextF64> for DefaultEngine
impl PlaintextDecodingEngine<FloatEncoder, Plaintext32, CleartextF64> for DefaultEngine
Description:
Implementation of PlaintextDecodingEngine
for DefaultEngine
that decodes 32 bits
integers to 64 bits floating point numbers.
sourcefn decode_plaintext(
&mut self,
encoder: &FloatEncoder,
input: &Plaintext32
) -> Result<CleartextF64, PlaintextDecodingError<Self::EngineError>>
fn decode_plaintext(
&mut self,
encoder: &FloatEncoder,
input: &Plaintext32
) -> Result<CleartextF64, PlaintextDecodingError<Self::EngineError>>
Example:
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 = engine.create_encoder(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext(&5.)?;
let plaintext: Plaintext32 = engine.encode_cleartext(&encoder, &cleartext)?;
let recovered_cleartext: CleartextF64 = engine.decode_plaintext(&encoder, &plaintext)?;
engine.destroy(encoder)?;
engine.destroy(cleartext)?;
engine.destroy(plaintext)?;
engine.destroy(recovered_cleartext)?;
sourceunsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext32,
encoder: &FloatEncoder
) -> CleartextF64
unsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext32,
encoder: &FloatEncoder
) -> CleartextF64
Unsafely decodes a plaintext. Read more
sourceimpl PlaintextDecodingEngine<FloatEncoder, Plaintext64, CleartextF64> for DefaultEngine
impl PlaintextDecodingEngine<FloatEncoder, Plaintext64, CleartextF64> for DefaultEngine
Description:
Implementation of PlaintextDecodingEngine
for DefaultEngine
that decodes 64 bits
integers to 64 bits floating point numbers.
sourcefn decode_plaintext(
&mut self,
encoder: &FloatEncoder,
input: &Plaintext64
) -> Result<CleartextF64, PlaintextDecodingError<Self::EngineError>>
fn decode_plaintext(
&mut self,
encoder: &FloatEncoder,
input: &Plaintext64
) -> Result<CleartextF64, PlaintextDecodingError<Self::EngineError>>
Example:
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 = engine.create_encoder(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext(&5.)?;
let plaintext: Plaintext64 = engine.encode_cleartext(&encoder, &cleartext)?;
let recovered_cleartext: CleartextF64 = engine.decode_plaintext(&encoder, &plaintext)?;
engine.destroy(encoder)?;
engine.destroy(cleartext)?;
engine.destroy(plaintext)?;
engine.destroy(recovered_cleartext)?;
sourceunsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext64,
encoder: &FloatEncoder
) -> CleartextF64
unsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext64,
encoder: &FloatEncoder
) -> CleartextF64
Unsafely decodes a plaintext. Read more
sourceimpl PlaintextDiscardingRetrievalEngine<Plaintext32, u32> for DefaultEngine
impl PlaintextDiscardingRetrievalEngine<Plaintext32, u32> for DefaultEngine
Description:
Implementation of PlaintextDiscardingRetrievalEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn discard_retrieve_plaintext(
&mut self,
output: &mut u32,
input: &Plaintext32
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext(
&mut self,
output: &mut u32,
input: &Plaintext32
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let mut output = 0_u32;
// 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(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;
assert_eq!(output, 3_u32 << 20);
engine.destroy(plaintext)?;
sourceunsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u32,
input: &Plaintext32
)
unsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u32,
input: &Plaintext32
)
Unsafely retrieves an arbitrary value from a plaintext inplace. Read more
sourceimpl PlaintextDiscardingRetrievalEngine<Plaintext64, u64> for DefaultEngine
impl PlaintextDiscardingRetrievalEngine<Plaintext64, u64> for DefaultEngine
sourcefn discard_retrieve_plaintext(
&mut self,
output: &mut u64,
input: &Plaintext64
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext(
&mut self,
output: &mut u64,
input: &Plaintext64
) -> Result<(), PlaintextDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u64 << 20;
let mut output = 0_u64;
// 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(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;
assert_eq!(output, 3_u64 << 20);
engine.destroy(plaintext)?;
sourceunsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u64,
input: &Plaintext64
)
unsafe fn discard_retrieve_plaintext_unchecked(
&mut self,
output: &mut u64,
input: &Plaintext64
)
Unsafely retrieves an arbitrary value from a plaintext inplace. Read more
sourceimpl PlaintextRetrievalEngine<Plaintext32, u32> for DefaultEngine
impl PlaintextRetrievalEngine<Plaintext32, u32> for DefaultEngine
Description:
Implementation of PlaintextRetrievalEngine
for DefaultEngine
that operates on 64 bits
integers.
sourcefn retrieve_plaintext(
&mut self,
plaintext: &Plaintext32
) -> Result<u32, PlaintextRetrievalError<Self::EngineError>>
fn retrieve_plaintext(
&mut self,
plaintext: &Plaintext32
) -> Result<u32, PlaintextRetrievalError<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(&input)?;
let output: u32 = engine.retrieve_plaintext(&plaintext)?;
assert_eq!(output, 3_u32 << 20);
engine.destroy(plaintext)?;
sourceunsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext32) -> u32
unsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext32) -> u32
Unsafely retrieves an arbitrary value from a plaintext. Read more
sourceimpl PlaintextRetrievalEngine<Plaintext64, u64> for DefaultEngine
impl PlaintextRetrievalEngine<Plaintext64, u64> for DefaultEngine
Description:
Implementation of PlaintextRetrievalEngine
for DefaultEngine
that operates on 64 bits
integers.
sourcefn retrieve_plaintext(
&mut self,
plaintext: &Plaintext64
) -> Result<u64, PlaintextRetrievalError<Self::EngineError>>
fn retrieve_plaintext(
&mut self,
plaintext: &Plaintext64
) -> Result<u64, PlaintextRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u64 << 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: Plaintext64 = engine.create_plaintext(&input)?;
let output: u64 = engine.retrieve_plaintext(&plaintext)?;
assert_eq!(output, 3_u64 << 20);
engine.destroy(plaintext)?;
sourceunsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext64) -> u64
unsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext64) -> u64
Unsafely retrieves an arbitrary value from a plaintext. Read more
sourceimpl PlaintextVectorCreationEngine<u32, PlaintextVector32> for DefaultEngine
impl PlaintextVectorCreationEngine<u32, PlaintextVector32> for DefaultEngine
Description:
Implementation of PlaintextVectorCreationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn create_plaintext_vector(
&mut self,
input: &[u32]
) -> Result<PlaintextVector32, PlaintextVectorCreationError<Self::EngineError>>
fn create_plaintext_vector(
&mut self,
input: &[u32]
) -> Result<PlaintextVector32, PlaintextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// 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(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
engine.destroy(plaintext_vector)?;
sourceunsafe fn create_plaintext_vector_unchecked(
&mut self,
input: &[u32]
) -> PlaintextVector32
unsafe fn create_plaintext_vector_unchecked(
&mut self,
input: &[u32]
) -> PlaintextVector32
Unsafely creates a plaintext vector from a slice of arbitrary values. Read more
sourceimpl PlaintextVectorCreationEngine<u64, PlaintextVector64> for DefaultEngine
impl PlaintextVectorCreationEngine<u64, PlaintextVector64> for DefaultEngine
Description:
Implementation of PlaintextVectorCreationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn create_plaintext_vector(
&mut self,
input: &[u64]
) -> Result<PlaintextVector64, PlaintextVectorCreationError<Self::EngineError>>
fn create_plaintext_vector(
&mut self,
input: &[u64]
) -> Result<PlaintextVector64, PlaintextVectorCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// 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(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
engine.destroy(plaintext_vector)?;
sourceunsafe fn create_plaintext_vector_unchecked(
&mut self,
input: &[u64]
) -> PlaintextVector64
unsafe fn create_plaintext_vector_unchecked(
&mut self,
input: &[u64]
) -> PlaintextVector64
Unsafely creates a plaintext vector from a slice of arbitrary values. Read more
sourceimpl PlaintextVectorDecodingEngine<FloatEncoderVector, PlaintextVector32, CleartextVectorF64> for DefaultEngine
impl PlaintextVectorDecodingEngine<FloatEncoderVector, PlaintextVector32, CleartextVectorF64> for DefaultEngine
Description:
Implementation of PlaintextVectorDecodingEngine
for DefaultEngine
that decodes 32 bits
integers to 64 bits floating point numbers.
sourcefn decode_plaintext_vector(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector32
) -> Result<CleartextVectorF64, PlaintextVectorDecodingError<Self::EngineError>>
fn decode_plaintext_vector(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector32
) -> Result<CleartextVectorF64, PlaintextVectorDecodingError<Self::EngineError>>
Example:
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(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector32 =
engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
let recovered_cleartext_vector: CleartextVectorF64 =
engine.decode_plaintext_vector(&encoder_vector, &plaintext_vector)?;
assert_eq!(
recovered_cleartext_vector.cleartext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(encoder_vector)?;
engine.destroy(cleartext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(recovered_cleartext_vector)?;
sourceunsafe fn decode_plaintext_vector_unchecked(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector32
) -> CleartextVectorF64
unsafe fn decode_plaintext_vector_unchecked(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector32
) -> CleartextVectorF64
Unsafely decodes a plaintext vector. Read more
sourceimpl PlaintextVectorDecodingEngine<FloatEncoderVector, PlaintextVector64, CleartextVectorF64> for DefaultEngine
impl PlaintextVectorDecodingEngine<FloatEncoderVector, PlaintextVector64, CleartextVectorF64> for DefaultEngine
Description:
Implementation of PlaintextVectorDecodingEngine
for DefaultEngine
that decodes 64 bits
integers to 64 bits floating point numbers.
sourcefn decode_plaintext_vector(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector64
) -> Result<CleartextVectorF64, PlaintextVectorDecodingError<Self::EngineError>>
fn decode_plaintext_vector(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector64
) -> Result<CleartextVectorF64, PlaintextVectorDecodingError<Self::EngineError>>
Example:
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(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector(&vec![5.; 100])?;
let plaintext_vector: PlaintextVector32 =
engine.encode_cleartext_vector(&encoder_vector, &cleartext_vector)?;
let recovered_cleartext_vector: CleartextVectorF64 =
engine.decode_plaintext_vector(&encoder_vector, &plaintext_vector)?;
assert_eq!(
recovered_cleartext_vector.cleartext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(encoder_vector)?;
engine.destroy(cleartext_vector)?;
engine.destroy(plaintext_vector)?;
engine.destroy(recovered_cleartext_vector)?;
sourceunsafe fn decode_plaintext_vector_unchecked(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector64
) -> CleartextVectorF64
unsafe fn decode_plaintext_vector_unchecked(
&mut self,
encoder: &FloatEncoderVector,
input: &PlaintextVector64
) -> CleartextVectorF64
Unsafely decodes a plaintext vector. Read more
sourceimpl PlaintextVectorDiscardingRetrievalEngine<PlaintextVector32, u32> for DefaultEngine
impl PlaintextVectorDiscardingRetrievalEngine<PlaintextVector32, u32> for DefaultEngine
Description:
Implementation of PlaintextVectorDiscardingRetrievalEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let mut output = vec![0_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 plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
engine.destroy(plaintext_vector)?;
sourceunsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
)
unsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u32],
input: &PlaintextVector32
)
Unsafely retrieves arbitrary values from a plaintext vector. Read more
sourceimpl PlaintextVectorDiscardingRetrievalEngine<PlaintextVector64, u64> for DefaultEngine
impl PlaintextVectorDiscardingRetrievalEngine<PlaintextVector64, u64> for DefaultEngine
Description:
Implementation of PlaintextVectorDiscardingRetrievalEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
fn discard_retrieve_plaintext_vector(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
) -> Result<(), PlaintextVectorDiscardingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u64 << 20; 3];
let mut output = vec![0_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 plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
engine.destroy(plaintext_vector)?;
sourceunsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
)
unsafe fn discard_retrieve_plaintext_vector_unchecked(
&mut self,
output: &mut [u64],
input: &PlaintextVector64
)
Unsafely retrieves arbitrary values from a plaintext vector. Read more
sourceimpl PlaintextVectorRetrievalEngine<PlaintextVector32, u32> for DefaultEngine
impl PlaintextVectorRetrievalEngine<PlaintextVector32, u32> for DefaultEngine
Description:
Implementation of PlaintextVectorRetrievalEngine
for DefaultEngine
that operates on 32
bits integers.
sourcefn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector32
) -> Result<Vec<u32>, PlaintextVectorRetrievalError<Self::EngineError>>
fn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector32
) -> Result<Vec<u32>, PlaintextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// 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(&input)?;
let output: Vec<u32> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
engine.destroy(plaintext_vector)?;
sourceunsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector32
) -> Vec<u32>
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector32
) -> Vec<u32>
Unsafely retrieves arbitrary values from a plaintext vector. Read more
sourceimpl PlaintextVectorRetrievalEngine<PlaintextVector64, u64> for DefaultEngine
impl PlaintextVectorRetrievalEngine<PlaintextVector64, u64> for DefaultEngine
Description:
Implementation of PlaintextVectorRetrievalEngine
for DefaultEngine
that operates on 64
bits integers.
sourcefn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector64
) -> Result<Vec<u64>, PlaintextVectorRetrievalError<Self::EngineError>>
fn retrieve_plaintext_vector(
&mut self,
plaintext: &PlaintextVector64
) -> Result<Vec<u64>, PlaintextVectorRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::PlaintextCount;
use concrete_core::prelude::*;
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u64 << 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: PlaintextVector64 = engine.create_plaintext_vector(&input)?;
let output: Vec<u64> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
engine.destroy(plaintext_vector)?;
sourceunsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector64
) -> Vec<u64>
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector64
) -> Vec<u64>
Unsafely retrieves arbitrary values from a plaintext vector. Read more
Auto Trait Implementations
impl RefUnwindSafe for DefaultEngine
impl Send for DefaultEngine
impl Sync for DefaultEngine
impl Unpin for DefaultEngine
impl UnwindSafe for DefaultEngine
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more