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
type Parameters = Box<dyn Seeder + 'static, Global>
type Parameters = Box<dyn Seeder + 'static, Global>
sourcefn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>
fn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>
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_from(
&mut self,
value: &f64
) -> Result<CleartextF64, CleartextCreationError<Self::EngineError>>
fn create_cleartext_from(
&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_from(&input)?;
sourceunsafe fn create_cleartext_from_unchecked(&mut self, value: &f64) -> CleartextF64
unsafe fn create_cleartext_from_unchecked(&mut self, value: &f64) -> CleartextF64
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_from(
&mut self,
input: &u32
) -> Result<Cleartext32, CleartextCreationError<Self::EngineError>>
fn create_cleartext_from(
&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_from(&input)?;
sourceunsafe fn create_cleartext_from_unchecked(&mut self, input: &u32) -> Cleartext32
unsafe fn create_cleartext_from_unchecked(&mut self, input: &u32) -> Cleartext32
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_from(
&mut self,
input: &u64
) -> Result<Cleartext64, CleartextCreationError<Self::EngineError>>
fn create_cleartext_from(
&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_from(&input)?;
sourceunsafe fn create_cleartext_from_unchecked(&mut self, input: &u64) -> Cleartext64
unsafe fn create_cleartext_from_unchecked(&mut self, input: &u64) -> Cleartext64
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_from(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3_u32);
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
)
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_from(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3_u64);
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
)
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_from(&input)?;
engine.discard_retrieve_cleartext(&mut output, &cleartext)?;
assert_eq!(output, 3.0);
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
)
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_from(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext32 = engine.encode_cleartext(&encoder, &cleartext)?;
sourceunsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext32
unsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext32
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_from(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext64 = engine.encode_cleartext(&encoder, &cleartext)?;
sourceunsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext64
unsafe fn encode_cleartext_unchecked(
&mut self,
encoder: &FloatEncoder,
cleartext: &CleartextF64
) -> Plaintext64
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_from(&input)?;
let output: u32 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3_u32);
sourceunsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext32) -> u32
unsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext32) -> u32
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_from(&input)?;
let output: u64 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3_u64);
sourceunsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext64) -> u64
unsafe fn retrieve_cleartext_unchecked(&mut self, cleartext: &Cleartext64) -> u64
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_from(&input)?;
let output: f64 = engine.retrieve_cleartext(&cleartext)?;
assert_eq!(output, 3.0);
sourceunsafe fn retrieve_cleartext_unchecked(
&mut self,
cleartext: &CleartextF64
) -> f64
unsafe fn retrieve_cleartext_unchecked(
&mut self,
cleartext: &CleartextF64
) -> f64
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_from(
&mut self,
values: &[f64]
) -> Result<CleartextVectorF64, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector_from(
&mut self,
values: &[f64]
) -> Result<CleartextVectorF64, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{CleartextCount, *};
let input = vec![3.0_f64; 100];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector_from(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
sourceunsafe fn create_cleartext_vector_from_unchecked(
&mut self,
values: &[f64]
) -> CleartextVectorF64
unsafe fn create_cleartext_vector_from_unchecked(
&mut self,
values: &[f64]
) -> CleartextVectorF64
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_from(
&mut self,
input: &[u32]
) -> Result<CleartextVector32, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector_from(
&mut self,
input: &[u32]
) -> Result<CleartextVector32, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{CleartextCount, *};
let input = vec![3_u32; 100];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector_from(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
sourceunsafe fn create_cleartext_vector_from_unchecked(
&mut self,
input: &[u32]
) -> CleartextVector32
unsafe fn create_cleartext_vector_from_unchecked(
&mut self,
input: &[u32]
) -> CleartextVector32
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_from(
&mut self,
input: &[u64]
) -> Result<CleartextVector64, CleartextVectorCreationError<Self::EngineError>>
fn create_cleartext_vector_from(
&mut self,
input: &[u64]
) -> Result<CleartextVector64, CleartextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{CleartextCount, *};
let input = vec![3_u64; 100];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector_from(&input)?;
assert_eq!(cleartext_vector.cleartext_count(), CleartextCount(100));
sourceunsafe fn create_cleartext_vector_from_unchecked(
&mut self,
input: &[u64]
) -> CleartextVector64
unsafe fn create_cleartext_vector_from_unchecked(
&mut self,
input: &[u64]
) -> CleartextVector64
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_core::prelude::{CleartextCount, *};
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_from(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3_u32);
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
)
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_core::prelude::{CleartextCount, *};
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_from(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3_u64);
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
)
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_core::prelude::{CleartextCount, *};
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_from(&input)?;
engine.discard_retrieve_cleartext_vector(retrieved.as_mut_slice(), &cleartext_vector)?;
assert_eq!(retrieved[0], 3.0_f64);
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
)
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_from(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 =
engine.create_cleartext_vector_from(&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
);
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
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_from(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 =
engine.create_cleartext_vector_from(&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
);
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
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_core::prelude::{CleartextCount, *};
let input = vec![3_u32; 100];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector32 = engine.create_cleartext_vector_from(&input)?;
let retrieved: Vec<u32> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3_u32);
sourceunsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector32
) -> Vec<u32>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector32
) -> Vec<u32>
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_core::prelude::{CleartextCount, *};
let input = vec![3_u64; 100];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVector64 = engine.create_cleartext_vector_from(&input)?;
let retrieved: Vec<u64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3_u64);
sourceunsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector64
) -> Vec<u64>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVector64
) -> Vec<u64>
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_core::prelude::{CleartextCount, *};
let input = vec![3.0_f64; 100];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext_vector: CleartextVectorF64 = engine.create_cleartext_vector_from(&input)?;
let retrieved: Vec<f64> = engine.retrieve_cleartext_vector(&cleartext_vector)?;
assert_eq!(retrieved[0], 3.0_f64);
sourceunsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVectorF64
) -> Vec<f64>
unsafe fn retrieve_cleartext_vector_unchecked(
&mut self,
cleartext: &CleartextVectorF64
) -> Vec<f64>
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_from(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> Result<FloatEncoder, EncoderCreationError<Self::EngineError>>
fn create_encoder_from(
&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_from(&FloatEncoderCenterRadiusConfig {
center: 10.,
radius: 5.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
sourceunsafe fn create_encoder_from_unchecked(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> FloatEncoder
unsafe fn create_encoder_from_unchecked(
&mut self,
config: &FloatEncoderCenterRadiusConfig
) -> FloatEncoder
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_from(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> Result<FloatEncoder, EncoderCreationError<Self::EngineError>>
fn create_encoder_from(
&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_from(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
sourceunsafe fn create_encoder_from_unchecked(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> FloatEncoder
unsafe fn create_encoder_from_unchecked(
&mut self,
config: &FloatEncoderMinMaxConfig
) -> FloatEncoder
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_from(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> Result<FloatEncoderVector, EncoderVectorCreationError<Self::EngineError>>
fn create_encoder_vector_from(
&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_from(&vec![
FloatEncoderCenterRadiusConfig {
center: 10.,
radius: 5.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
1
])?;
sourceunsafe fn create_encoder_vector_from_unchecked(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> FloatEncoderVector
unsafe fn create_encoder_vector_from_unchecked(
&mut self,
config: &[FloatEncoderCenterRadiusConfig]
) -> FloatEncoderVector
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_from(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> Result<FloatEncoderVector, EncoderVectorCreationError<Self::EngineError>>
fn create_encoder_vector_from(
&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_from(
vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
1
]
.as_slice(),
)?;
sourceunsafe fn create_encoder_vector_from_unchecked(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> FloatEncoderVector
unsafe fn create_encoder_vector_from_unchecked(
&mut self,
config: &[FloatEncoderMinMaxConfig]
) -> FloatEncoderVector
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
let level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&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.generate_new_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);
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
)
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
let level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key_1: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&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.generate_new_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);
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
)
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
let level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext =
engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
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
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
let level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext =
engine.encrypt_scalar_ggsw_ciphertext(&key, &plaintext, noise, level, base_log)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
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
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
let level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
let input = 3_u32 << 20;
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext: Plaintext32 = engine.create_plaintext_from(&input)?;
let 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);
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
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, PolynomialSize, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
let level = DecompositionLevelCount(1);
let base_log = DecompositionBaseLog(4);
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_from(&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);
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
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_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(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>
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_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(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>
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_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(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]
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_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(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]
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_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(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]
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_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(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]
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_from(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext_from(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(slice, polynomial_size)?;
sourceunsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextView32<'data>
unsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextView32<'data>
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_from(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext_from(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{PolynomialSize, *};
// 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_from(slice, polynomial_size)?;
sourceunsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextView64<'data>
unsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextView64<'data>
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_from(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext_from(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView32<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(slice, polynomial_size)?;
sourceunsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView32<'data>
unsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u32],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView32<'data>
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_from(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext_from(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextMutView64<'data>, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweSize, PolynomialSize, *};
// 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_from(slice, polynomial_size)?;
sourceunsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView64<'data>
unsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u64],
polynomial_size: PolynomialSize
) -> GlweCiphertextMutView64<'data>
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_from(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext32, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext_from(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext32, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweSize, *};
// 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_from(owned_container, polynomial_size)?;
sourceunsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> GlweCiphertext32
unsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u32>,
polynomial_size: PolynomialSize
) -> GlweCiphertext32
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_from(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext64, GlweCiphertextCreationError<Self::EngineError>>
fn create_glwe_ciphertext_from(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertext64, GlweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweSize, *};
// 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_from(owned_container, polynomial_size)?;
sourceunsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> GlweCiphertext64
unsafe fn create_glwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u64>,
polynomial_size: PolynomialSize
) -> GlweCiphertext64
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector = engine.decrypt_glwe_ciphertext(&key, &ciphertext)?;
assert_eq!(
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
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_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Here a hard-set encoding is applied (shift by 20 bits)
let 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
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
)
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_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Here a hard-set encoding is applied (shift by 50 bits)
let 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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.generate_new_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);
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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.generate_new_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);
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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_from(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);
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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_from(&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);
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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_from(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);
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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_from(&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);
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
)
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext = engine.encrypt_glwe_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(ciphertext.polynomial_size(), polynomial_size);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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));
sourceunsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext32
) -> PlaintextVector32
unsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext32
) -> PlaintextVector32
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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));
sourceunsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext64
) -> PlaintextVector64
unsafe fn trivially_decrypt_glwe_ciphertext_unchecked(
&mut self,
input: &GlweCiphertext64
) -> PlaintextVector64
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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);
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
sourceimpl GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVector32, Vec<u32, Global>> for DefaultEngine
impl GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVector32, Vec<u32, Global>> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a GlweCiphertextVector32
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVector32
) -> Result<Vec<u32>, GlweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVector32
) -> Result<Vec<u32>, GlweCiphertextVectorConsumingRetrievalError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.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_vector: GlweCiphertextVector32 = engine.create_glwe_ciphertext_vector_from(
owned_container,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVector32
) -> Vec<u32>
unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVector32
) -> Vec<u32>
sourceimpl GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVector64, Vec<u64, Global>> for DefaultEngine
impl GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVector64, Vec<u64, Global>> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a GlweCiphertextVector64
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVector64
) -> Result<Vec<u64>, GlweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVector64
) -> Result<Vec<u64>, GlweCiphertextVectorConsumingRetrievalError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.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_vector: GlweCiphertextVector64 = engine.create_glwe_ciphertext_vector_from(
owned_container,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
let retrieved_container = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVector64
) -> Vec<u64>
unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVector64
) -> Vec<u64>
sourceimpl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorMutView32<'data>, &'data mut [u32]> for DefaultEngine
impl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorMutView32<'data>, &'data mut [u32]> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns
the underlying slice of a GlweCiphertextVectorMutView32
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView32<'data>
) -> Result<&'data mut [u32], GlweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView32<'data>
) -> Result<&'data mut [u32], GlweCiphertextVectorConsumingRetrievalError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.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_vector_view: GlweCiphertextVectorMutView32 = engine
.create_glwe_ciphertext_vector_from(
slice,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView32<'data>
) -> &'data mut [u32]
unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView32<'data>
) -> &'data mut [u32]
sourceimpl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorMutView64<'data>, &'data mut [u64]> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns
the underlying slice of a GlweCiphertextVectorMutView64
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView64<'data>
) -> Result<&'data mut [u64], GlweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView64<'data>
) -> Result<&'data mut [u64], GlweCiphertextVectorConsumingRetrievalError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.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_vector_view: GlweCiphertextVectorMutView64 = engine
.create_glwe_ciphertext_vector_from(
slice,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorMutView64<'data>
) -> &'data mut [u64]
sourceimpl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorView32<'data>, &'data [u32]> for DefaultEngine
impl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorView32<'data>, &'data [u32]> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a GlweCiphertextVectorView32
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorView32<'data>
) -> Result<&'data [u32], GlweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorView32<'data>
) -> Result<&'data [u32], GlweCiphertextVectorConsumingRetrievalError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.0];
let original_vec_ptr = owned_container.as_ptr();
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_vector: GlweCiphertextVector32 = engine.create_glwe_ciphertext_vector_from(
slice.to_vec(),
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorView32<'data>
) -> &'data [u32]
unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorView32<'data>
) -> &'data [u32]
sourceimpl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorView64<'data>, &'data [u64]> for DefaultEngine
impl<'data> GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVectorView64<'data>, &'data [u64]> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a GlweCiphertextVectorView64
consuming it in the process
sourcefn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorView64<'data>
) -> Result<&'data [u64], GlweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_glwe_ciphertext_vector(
&mut self,
ciphertext_vector: GlweCiphertextVectorView64<'data>
) -> Result<&'data [u64], GlweCiphertextVectorConsumingRetrievalError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.0];
let original_vec_ptr = owned_container.as_ptr();
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_vector: GlweCiphertextVector64 = engine.create_glwe_ciphertext_vector_from(
slice.to_vec(),
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
let retrieved_slice = engine.consume_retrieve_glwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorView64<'data>
) -> &'data [u64]
unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked(
&mut self,
ciphertext_vector: GlweCiphertextVectorView64<'data>
) -> &'data [u64]
sourceimpl<'data> GlweCiphertextVectorCreationEngine<&'data [u32], GlweCiphertextVectorView32<'data>> for DefaultEngine
impl<'data> GlweCiphertextVectorCreationEngine<&'data [u32], GlweCiphertextVectorView32<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorCreationEngine
for DefaultEngine
which returns an
immutable GlweCiphertextVectorView32
that does not own its memory.
sourcefn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorView32<'data>, GlweCiphertextVectorCreationError<Self::EngineError>>
fn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorView32<'data>, GlweCiphertextVectorCreationError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.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: GlweCiphertextVectorView32 = engine.create_glwe_ciphertext_vector_from(
slice,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
sourceunsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorView32<'data>
unsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorView32<'data>
sourceimpl<'data> GlweCiphertextVectorCreationEngine<&'data [u64], GlweCiphertextVectorView64<'data>> for DefaultEngine
impl<'data> GlweCiphertextVectorCreationEngine<&'data [u64], GlweCiphertextVectorView64<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorCreationEngine
for DefaultEngine
which returns an
immutable GlweCiphertextVectorView64
that does not own its memory.
sourcefn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorView64<'data>, GlweCiphertextVectorCreationError<Self::EngineError>>
fn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorView64<'data>, GlweCiphertextVectorCreationError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.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: GlweCiphertextVectorView64 = engine.create_glwe_ciphertext_vector_from(
slice,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
sourceunsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorView64<'data>
unsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorView64<'data>
sourceimpl<'data> GlweCiphertextVectorCreationEngine<&'data mut [u32], GlweCiphertextVectorMutView32<'data>> for DefaultEngine
impl<'data> GlweCiphertextVectorCreationEngine<&'data mut [u32], GlweCiphertextVectorMutView32<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
mutable
GlweCiphertextVectorMutView32
that does not own its memory.
sourcefn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorMutView32<'data>, GlweCiphertextVectorCreationError<Self::EngineError>>
fn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorMutView32<'data>, GlweCiphertextVectorCreationError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.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: GlweCiphertextVectorMutView32 = engine
.create_glwe_ciphertext_vector_from(
slice,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
sourceunsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorMutView32<'data>
unsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u32],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorMutView32<'data>
sourceimpl<'data> GlweCiphertextVectorCreationEngine<&'data mut [u64], GlweCiphertextVectorMutView64<'data>> for DefaultEngine
impl<'data> GlweCiphertextVectorCreationEngine<&'data mut [u64], GlweCiphertextVectorMutView64<'data>> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
mutable
GlweCiphertextVectorMutView64
that does not own its memory.
sourcefn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorMutView64<'data>, GlweCiphertextVectorCreationError<Self::EngineError>>
fn create_glwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVectorMutView64<'data>, GlweCiphertextVectorCreationError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.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: GlweCiphertextVectorMutView64 = engine
.create_glwe_ciphertext_vector_from(
slice,
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
sourceunsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorMutView64<'data>
unsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u64],
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVectorMutView64<'data>
sourceimpl GlweCiphertextVectorCreationEngine<Vec<u32, Global>, GlweCiphertextVector32> for DefaultEngine
impl GlweCiphertextVectorCreationEngine<Vec<u32, Global>, GlweCiphertextVector32> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorCreationEngine
for DefaultEngine
which returns an
GlweCiphertextVector32
.
sourcefn create_glwe_ciphertext_vector_from(
&mut self,
container: Vec<u32>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorCreationError<Self::EngineError>>
fn create_glwe_ciphertext_vector_from(
&mut self,
container: Vec<u32>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVector32, GlweCiphertextVectorCreationError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u32; glwe_size.0 * polynomial_size.0 * glwe_count.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: GlweCiphertextVector32 = engine.create_glwe_ciphertext_vector_from(
slice.to_vec(),
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
sourceunsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u32>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVector32
unsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u32>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVector32
sourceimpl GlweCiphertextVectorCreationEngine<Vec<u64, Global>, GlweCiphertextVector64> for DefaultEngine
impl GlweCiphertextVectorCreationEngine<Vec<u64, Global>, GlweCiphertextVector64> for DefaultEngine
Description:
Implementation of GlweCiphertextVectorCreationEngine
for DefaultEngine
which returns an
GlweCiphertextVector64
.
sourcefn create_glwe_ciphertext_vector_from(
&mut self,
container: Vec<u64>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorCreationError<Self::EngineError>>
fn create_glwe_ciphertext_vector_from(
&mut self,
container: Vec<u64>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweCiphertextVector64, GlweCiphertextVectorCreationError<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 glwe_size = GlweSize(6);
let polynomial_size = PolynomialSize(512);
let glwe_count = GlweCiphertextCount(2);
// You have to make sure you size the container properly
let mut owned_container = vec![0_u64; glwe_size.0 * polynomial_size.0 * glwe_count.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: GlweCiphertextVector64 = engine.create_glwe_ciphertext_vector_from(
slice.to_vec(),
glwe_size.to_glwe_dimension(),
polynomial_size,
)?;
sourceunsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u64>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVector64
unsafe fn create_glwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u64>,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweCiphertextVector64
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_glwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_glwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
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
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_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 8];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
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
)
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_core::prelude::{GlweDimension, PlaintextCount, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 8];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let mut plaintext_vector = engine.create_plaintext_vector_from(&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));
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
)
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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!(
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
)
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let key_2: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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!(
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
)
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let ciphertext_vector =
engine.encrypt_glwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(ciphertext_vector.glwe_dimension(), glwe_dimension);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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));
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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));
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
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_from(&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);
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
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_core::prelude::{GlweCiphertextCount, GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(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.generate_new_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);
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
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_core::prelude::{GlweCiphertextCount, GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(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.generate_new_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);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(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.generate_new_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);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(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.generate_new_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);
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
sourceimpl GlweSecretKeyGenerationEngine<GlweSecretKey32> for DefaultEngine
impl GlweSecretKeyGenerationEngine<GlweSecretKey32> for DefaultEngine
Description:
Implementation of GlweSecretKeyGenerationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn generate_new_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, GlweSecretKeyGenerationError<Self::EngineError>>
fn generate_new_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, GlweSecretKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_secret_key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
sourceunsafe fn generate_new_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
unsafe fn generate_new_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey32
sourceimpl GlweSecretKeyGenerationEngine<GlweSecretKey64> for DefaultEngine
impl GlweSecretKeyGenerationEngine<GlweSecretKey64> for DefaultEngine
Description:
Implementation of GlweSecretKeyGenerationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn generate_new_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, GlweSecretKeyGenerationError<Self::EngineError>>
fn generate_new_glwe_secret_key(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, GlweSecretKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_secret_key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
assert_eq!(glwe_secret_key.glwe_dimension(), glwe_dimension);
assert_eq!(glwe_secret_key.polynomial_size(), polynomial_size);
sourceunsafe fn generate_new_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
unsafe fn generate_new_glwe_secret_key_unchecked(
&mut self,
glwe_dimension: GlweDimension,
polynomial_size: PolynomialSize
) -> GlweSecretKey64
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(seeded_ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(seeded_ciphertext.polynomial_size(), polynomial_size);
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
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_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
assert_eq!(seeded_ciphertext.glwe_dimension(), glwe_dimension);
assert_eq!(seeded_ciphertext.polynomial_size(), polynomial_size);
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
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, GlweSeededCiphertextToGlweCiphertextTransformationError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext32
) -> Result<GlweCiphertext32, GlweSeededCiphertextToGlweCiphertextTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
let 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);
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
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, GlweSeededCiphertextToGlweCiphertextTransformationError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext(
&mut self,
glwe_seeded_ciphertext: GlweSeededCiphertext64
) -> Result<GlweCiphertext64, GlweSeededCiphertextToGlweCiphertextTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::{GlweDimension, PolynomialSize, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// There are always polynomial_size messages encrypted in the GLWE ciphertext
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; polynomial_size.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext =
engine.encrypt_glwe_seeded_ciphertext(&key, &plaintext_vector, noise)?;
let 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);
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(seeded_ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(seeded_ciphertext_vector.glwe_dimension(), glwe_dimension);
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(
assert_eq!(seeded_ciphertext_vector.polynomial_size(), polynomial_size);
assert_eq!(seeded_ciphertext_vector.glwe_dimension(), glwe_dimension);
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
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, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector32
) -> Result<GlweCiphertextVector32, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let 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);
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
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, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationError<Self::EngineError>>
fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector(
&mut self,
glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector64
) -> Result<GlweCiphertextVector64, GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let seeded_ciphertext_vector =
engine.encrypt_glwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
let 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);
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
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, GlweToLweSecretKeyTransformationError<Self::EngineError>>
fn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey32
) -> Result<LweSecretKey32, GlweToLweSecretKeyTransformationError<Self::EngineError>>
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_secret_key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
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));
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
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, GlweToLweSecretKeyTransformationError<Self::EngineError>>
fn transform_glwe_secret_key_to_lwe_secret_key(
&mut self,
glwe_secret_key: GlweSecretKey64
) -> Result<LweSecretKey64, GlweToLweSecretKeyTransformationError<Self::EngineError>>
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let glwe_dimension = GlweDimension(2);
let polynomial_size = PolynomialSize(4);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let glwe_secret_key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
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));
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
sourceimpl LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKey32, Vec<u32, Global>> for DefaultEngine
impl LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKey32, Vec<u32, Global>> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKey32
) -> Result<Vec<u32>, LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKey32
) -> Result<Vec<u32>, LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();
let lwe_bootstrap_key: LweBootstrapKey32 = engine.create_lwe_bootstrap_key_from(
owned_container,
glwe_size,
polynomial_size,
base_log,
level,
)?;
let retrieved_container = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKey32
) -> Vec<u32>
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKey32
) -> Vec<u32>
sourceimpl LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKey64, Vec<u64, Global>> for DefaultEngine
impl LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKey64, Vec<u64, Global>> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKey64
) -> Result<Vec<u64>, LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKey64
) -> Result<Vec<u64>, LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let original_vec_ptr = owned_container.as_ptr();
let lwe_bootstrap_key: LweBootstrapKey64 = engine.create_lwe_bootstrap_key_from(
owned_container,
glwe_size,
polynomial_size,
base_log,
level,
)?;
let retrieved_container = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKey64
) -> Vec<u64>
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKey64
) -> Vec<u64>
sourceimpl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView32<'data>, &'data mut [u32]> for DefaultEngine
impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView32<'data>, &'data mut [u32]> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyMutView32<'data>
) -> Result<&'data mut [u32], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyMutView32<'data>
) -> Result<&'data mut [u32], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container =
vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let mut slice = owned_container.as_mut_slice();
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
let lwe_bootstrap_key: LweBootstrapKeyMutView32 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyMutView32<'data>
) -> &'data mut [u32]
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyMutView32<'data>
) -> &'data mut [u32]
sourceimpl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> Result<&'data mut [u64], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> Result<&'data mut [u64], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let mut slice = owned_container.as_mut_slice();
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
let lwe_bootstrap_key: LweBootstrapKeyMutView64 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> &'data mut [u64]
sourceimpl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyView32<'data>, &'data [u32]> for DefaultEngine
impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyView32<'data>, &'data [u32]> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyView32<'data>
) -> Result<&'data [u32], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyView32<'data>
) -> Result<&'data [u32], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let slice = owned_container.as_slice();
let lwe_bootstrap_key: LweBootstrapKeyView32 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyView32<'data>
) -> &'data [u32]
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyView32<'data>
) -> &'data [u32]
sourceimpl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyView64<'data>, &'data [u64]> for DefaultEngine
impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyView64<'data>, &'data [u64]> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyView64<'data>
) -> Result<&'data [u64], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyView64<'data>
) -> Result<&'data [u64], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let slice = owned_container.as_slice();
let lwe_bootstrap_key: LweBootstrapKeyView64 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyView64<'data>
) -> &'data [u64]
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyView64<'data>
) -> &'data [u64]
sourceimpl<'data> LweBootstrapKeyCreationEngine<&'data [u32], LweBootstrapKeyView32<'data>> for DefaultEngine
impl<'data> LweBootstrapKeyCreationEngine<&'data [u32], LweBootstrapKeyView32<'data>> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: &'data [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyView32<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: &'data [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyView32<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let slice = owned_container.as_slice();
let lwe_bootstrap_key: LweBootstrapKeyView32 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyView32<'data>
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyView32<'data>
sourceimpl<'data> LweBootstrapKeyCreationEngine<&'data [u64], LweBootstrapKeyView64<'data>> for DefaultEngine
impl<'data> LweBootstrapKeyCreationEngine<&'data [u64], LweBootstrapKeyView64<'data>> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: &'data [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyView64<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: &'data [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyView64<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let slice = owned_container.as_slice();
let lwe_bootstrap_key: LweBootstrapKeyView64 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyView64<'data>
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyView64<'data>
sourceimpl<'data> LweBootstrapKeyCreationEngine<&'data mut [u32], LweBootstrapKeyMutView32<'data>> for DefaultEngine
impl<'data> LweBootstrapKeyCreationEngine<&'data mut [u32], LweBootstrapKeyMutView32<'data>> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: &'data mut [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyMutView32<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: &'data mut [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyMutView32<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container =
vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let mut slice = owned_container.as_mut_slice();
let lwe_bootstrap_key: LweBootstrapKeyMutView32 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data mut [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyMutView32<'data>
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data mut [u32],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyMutView32<'data>
sourceimpl<'data> LweBootstrapKeyCreationEngine<&'data mut [u64], LweBootstrapKeyMutView64<'data>> for DefaultEngine
impl<'data> LweBootstrapKeyCreationEngine<&'data mut [u64], LweBootstrapKeyMutView64<'data>> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyMutView64<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyMutView64<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let mut slice = owned_container.as_mut_slice();
let lwe_bootstrap_key: LweBootstrapKeyMutView64 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyMutView64<'data>
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyMutView64<'data>
sourceimpl LweBootstrapKeyCreationEngine<Vec<u32, Global>, LweBootstrapKey32> for DefaultEngine
impl LweBootstrapKeyCreationEngine<Vec<u32, Global>, LweBootstrapKey32> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: Vec<u32>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: Vec<u32>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKey32, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u32; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let lwe_bootstrap_key: LweBootstrapKey32 = engine.create_lwe_bootstrap_key_from(
owned_container,
glwe_size,
polynomial_size,
base_log,
level,
)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: Vec<u32>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKey32
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: Vec<u32>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKey32
sourceimpl LweBootstrapKeyCreationEngine<Vec<u64, Global>, LweBootstrapKey64> for DefaultEngine
impl LweBootstrapKeyCreationEngine<Vec<u64, Global>, LweBootstrapKey64> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: Vec<u64>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKey64, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: Vec<u64>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKey64, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let lwe_bootstrap_key: LweBootstrapKey64 = engine.create_lwe_bootstrap_key_from(
owned_container,
glwe_size,
polynomial_size,
base_log,
level,
)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: Vec<u64>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKey64
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: Vec<u64>,
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKey64
sourceimpl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey32, LweBootstrapKeyMutView32<'_>> for DefaultEngine
impl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey32, LweBootstrapKeyMutView32<'_>> for DefaultEngine
sourcefn discard_convert_lwe_bootstrap_key(
&mut self,
output: &mut LweBootstrapKeyMutView32<'_>,
input: &LweBootstrapKey32
) -> Result<(), LweBootstrapKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_bootstrap_key(
&mut self,
output: &mut LweBootstrapKeyMutView32<'_>,
input: &LweBootstrapKey32
) -> Result<(), LweBootstrapKeyDiscardingConversionError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let mut owned_container = vec![
0_u32;
lwe_dim.0
* dec_lc.0
* glwe_dim.to_glwe_size().0
* glwe_dim.to_glwe_size().0
* poly_size.0
];
let mut out_bsk_mut_view: LweBootstrapKeyMutView32 = default_engine
.create_lwe_bootstrap_key_from(
owned_container.as_mut_slice(),
glwe_dim.to_glwe_size(),
poly_size,
dec_bl,
dec_lc,
)?;
default_engine.discard_convert_lwe_bootstrap_key(&mut out_bsk_mut_view, &bsk)?;
assert_eq!(out_bsk_mut_view.glwe_dimension(), glwe_dim);
assert_eq!(out_bsk_mut_view.polynomial_size(), poly_size);
assert_eq!(out_bsk_mut_view.input_lwe_dimension(), lwe_dim);
assert_eq!(out_bsk_mut_view.decomposition_base_log(), dec_bl);
assert_eq!(out_bsk_mut_view.decomposition_level_count(), dec_lc);
// Check content is the same
let original_bsk_container = default_engine.consume_retrieve_lwe_bootstrap_key(bsk)?;
let mut_view_bsk_container =
default_engine.consume_retrieve_lwe_bootstrap_key(out_bsk_mut_view)?;
assert_eq!(original_bsk_container, mut_view_bsk_container);
sourceunsafe fn discard_convert_lwe_bootstrap_key_unchecked(
&mut self,
output: &mut LweBootstrapKeyMutView32<'_>,
input: &LweBootstrapKey32
)
unsafe fn discard_convert_lwe_bootstrap_key_unchecked(
&mut self,
output: &mut LweBootstrapKeyMutView32<'_>,
input: &LweBootstrapKey32
)
sourceimpl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey64, LweBootstrapKeyMutView64<'_>> for DefaultEngine
impl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey64, LweBootstrapKeyMutView64<'_>> for DefaultEngine
sourcefn discard_convert_lwe_bootstrap_key(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
) -> Result<(), LweBootstrapKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_bootstrap_key(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
) -> Result<(), LweBootstrapKeyDiscardingConversionError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let mut owned_container = vec![
0_u64;
lwe_dim.0
* dec_lc.0
* glwe_dim.to_glwe_size().0
* glwe_dim.to_glwe_size().0
* poly_size.0
];
let mut out_bsk_mut_view: LweBootstrapKeyMutView64 = default_engine
.create_lwe_bootstrap_key_from(
owned_container.as_mut_slice(),
glwe_dim.to_glwe_size(),
poly_size,
dec_bl,
dec_lc,
)?;
default_engine.discard_convert_lwe_bootstrap_key(&mut out_bsk_mut_view, &bsk)?;
assert_eq!(out_bsk_mut_view.glwe_dimension(), glwe_dim);
assert_eq!(out_bsk_mut_view.polynomial_size(), poly_size);
assert_eq!(out_bsk_mut_view.input_lwe_dimension(), lwe_dim);
assert_eq!(out_bsk_mut_view.decomposition_base_log(), dec_bl);
assert_eq!(out_bsk_mut_view.decomposition_level_count(), dec_lc);
// Check content is the same
let original_bsk_container = default_engine.consume_retrieve_lwe_bootstrap_key(bsk)?;
let mut_view_bsk_container =
default_engine.consume_retrieve_lwe_bootstrap_key(out_bsk_mut_view)?;
assert_eq!(original_bsk_container, mut_view_bsk_container);
sourceunsafe fn discard_convert_lwe_bootstrap_key_unchecked(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
)
unsafe fn discard_convert_lwe_bootstrap_key_unchecked(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
)
sourceimpl LweBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweBootstrapKey32> for DefaultEngine
impl LweBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweBootstrapKey32> for DefaultEngine
Description:
Implementation of LweBootstrapKeyGenerationEngine
for DefaultEngine
that operates on
32 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey32, LweBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey32 =
engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
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);
sourceunsafe fn generate_new_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 generate_new_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey32
sourceimpl LweBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultEngine
impl LweBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweBootstrapKey64> for DefaultEngine
Description:
Implementation of LweBootstrapKeyGenerationEngine
for DefaultEngine
that operates on
64 bits integers. It outputs a bootstrap key in the standard domain.
sourcefn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweBootstrapKey64, LweBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
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);
sourceunsafe fn generate_new_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 generate_new_lwe_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweBootstrapKey64
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let 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_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 =
engine.trivially_encrypt_lwe_ciphertext(lwe_dimension.to_lwe_size(), &plaintext)?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_1 = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let mut ciphertext_2 =
engine.trivially_encrypt_lwe_ciphertext(lwe_dimension.to_lwe_size(), &plaintext)?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let 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_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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_from(&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_from(&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_from(&mut ciphertext_2_container[..])?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let cleartext: Cleartext64 = engine.create_cleartext_from(&cleartext_input)?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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_from(&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_from(&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_from(&mut ciphertext_2_container[..])?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let 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_from(&cleartext_input)?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let 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_from(&cleartext_input)?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweSize, *};
// 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_from(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>
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_core::prelude::{LweSize, *};
// 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_from(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>
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 container 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_core::prelude::{LweSize, *};
// 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_from(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]
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 container 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_core::prelude::{LweSize, *};
// 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_from(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]
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 container 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_core::prelude::{LweSize, *};
// 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_from(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]
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 container 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_core::prelude::{LweSize, *};
// 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_from(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]
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_from(
&mut self,
container: &'data [u32]
) -> Result<LweCiphertextView32<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from(
&mut self,
container: &'data [u32]
) -> Result<LweCiphertextView32<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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_from(slice)?;
sourceunsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u32]
) -> LweCiphertextView32<'data>
unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u32]
) -> LweCiphertextView32<'data>
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_from(
&mut self,
container: &'data [u64]
) -> Result<LweCiphertextView64<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from(
&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_from(slice)?;
sourceunsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u64]
) -> LweCiphertextView64<'data>
unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data [u64]
) -> LweCiphertextView64<'data>
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_from(
&mut self,
container: &'data mut [u32]
) -> Result<LweCiphertextMutView32<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from(
&mut self,
container: &'data mut [u32]
) -> Result<LweCiphertextMutView32<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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_from(slice)?;
sourceunsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u32]
) -> LweCiphertextMutView32<'data>
unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u32]
) -> LweCiphertextMutView32<'data>
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_from(
&mut self,
container: &'data mut [u64]
) -> Result<LweCiphertextMutView64<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from(
&mut self,
container: &'data mut [u64]
) -> Result<LweCiphertextMutView64<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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_from(slice)?;
sourceunsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u64]
) -> LweCiphertextMutView64<'data>
unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: &'data mut [u64]
) -> LweCiphertextMutView64<'data>
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_from(
&mut self,
container: Vec<u32>
) -> Result<LweCiphertext32, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from(
&mut self,
container: Vec<u32>
) -> Result<LweCiphertext32, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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_from(owned_container)?;
sourceunsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u32>
) -> LweCiphertext32
unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u32>
) -> LweCiphertext32
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_from(
&mut self,
container: Vec<u64>
) -> Result<LweCiphertext64, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext_from(
&mut self,
container: Vec<u64>
) -> Result<LweCiphertext64, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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_from(owned_container)?;
sourceunsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u64>
) -> LweCiphertext64
unsafe fn create_lwe_ciphertext_from_unchecked(
&mut self,
container: Vec<u64>
) -> LweCiphertext64
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut raw_ciphertext = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&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_from(&raw_ciphertext[..])?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext)?;
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut raw_ciphertext = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_view: LweCiphertextMutView64 =
engine.create_lwe_ciphertext_from(&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_from(&raw_ciphertext[..])?;
let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ciphertext_view)?;
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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_from(&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_from(&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_from(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView32 =
engine.create_lwe_ciphertext_from(&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_from(&mut ciphertext_3_container[..])?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
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<'_>
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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_from(&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_from(&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_from(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView64 =
engine.create_lwe_ciphertext_from(&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_from(&mut ciphertext_3_container[..])?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
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<'_>
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let 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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut output_cipertext_container = vec![0_32; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&mut output_cipertext_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let 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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut output_cipertext_container = vec![0_64; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView64 =
engine.create_lwe_ciphertext_from(&mut output_cipertext_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{
GlweDimension, LweDimension, MonomialIndex, PolynomialSize, Variance, *,
};
// 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{
GlweDimension, LweDimension, MonomialIndex, PolynomialSize, Variance, *,
};
// 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.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// 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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// 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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext_from(&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_from(&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_from(&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_from(&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);
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
)
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// 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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// 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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext_from(&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_from(&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_from(&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_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&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_from(&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_from(&mut ciphertext_2_container[..])?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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<'_>
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext_from(&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_from(&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_from(&mut ciphertext_2_container[..])?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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<'_>
)
sourceimpl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey32, Plaintext32, LweCiphertext32> for DefaultEngine
impl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey32, Plaintext32, LweCiphertext32> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn discard_encrypt_lwe_ciphertext_with_public_key(
&mut self,
key: &LwePublicKey32,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextDiscardingPublicKeyEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_with_public_key(
&mut self,
key: &LwePublicKey32,
output: &mut LweCiphertext32,
input: &Plaintext32
) -> Result<(), LweCiphertextDiscardingPublicKeyEncryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(7);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey32 = engine.generate_new_lwe_public_key(
&secret_key,
noise,
lwe_public_key_zero_encryption_count,
)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_container = vec![0u32; lwe_dimension.to_lwe_size().0];
let mut ciphertext = engine.create_lwe_ciphertext_from(ciphertext_container)?;
engine.discard_encrypt_lwe_ciphertext_with_public_key(
&public_key,
&mut ciphertext,
&plaintext,
)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
sourceunsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked(
&mut self,
key: &LwePublicKey32,
output: &mut LweCiphertext32,
input: &Plaintext32
)
unsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked(
&mut self,
key: &LwePublicKey32,
output: &mut LweCiphertext32,
input: &Plaintext32
)
sourceimpl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey64, Plaintext64, LweCiphertext64> for DefaultEngine
impl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey64, Plaintext64, LweCiphertext64> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext_with_public_key(
&mut self,
key: &LwePublicKey64,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextDiscardingPublicKeyEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_with_public_key(
&mut self,
key: &LwePublicKey64,
output: &mut LweCiphertext64,
input: &Plaintext64
) -> Result<(), LweCiphertextDiscardingPublicKeyEncryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(7);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey64 = engine.generate_new_lwe_public_key(
&secret_key,
noise,
lwe_public_key_zero_encryption_count,
)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_container = vec![0u64; lwe_dimension.to_lwe_size().0];
let mut ciphertext = engine.create_lwe_ciphertext_from(ciphertext_container)?;
engine.discard_encrypt_lwe_ciphertext_with_public_key(
&public_key,
&mut ciphertext,
&plaintext,
)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
sourceunsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked(
&mut self,
key: &LwePublicKey64,
output: &mut LweCiphertext64,
input: &Plaintext64
)
unsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked(
&mut self,
key: &LwePublicKey64,
output: &mut LweCiphertext64,
input: &Plaintext64
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_opp_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
sourceunsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext32
)
unsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext32
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext = engine.encrypt_lwe_ciphertext(&key, &plaintext, noise)?;
engine.fuse_opp_lwe_ciphertext(&mut ciphertext)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
sourceunsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext64
)
unsafe fn fuse_opp_lwe_ciphertext_unchecked(
&mut self,
input: &mut LweCiphertext64
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u32; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView32 =
engine.create_lwe_ciphertext_from(&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_from(&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_from(&mut ciphertext_2_container[..])?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext_from(&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_from(&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_from(&mut ciphertext_2_container[..])?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext_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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext_from(&input_1)?;
let plaintext_2 = engine.create_plaintext_from(&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);
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
)
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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);
sourceunsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext32
) -> Plaintext32
unsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext32
) -> Plaintext32
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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);
sourceunsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext64
) -> Plaintext64
unsafe fn trivially_decrypt_lwe_ciphertext_unchecked(
&mut self,
input: &LweCiphertext64
) -> Plaintext64
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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);
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
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_core::prelude::{CiphertextCount, LweSize, Variance, *};
// 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_from(&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);
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
sourceimpl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32, Global>> for DefaultEngine
impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32, Global>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVector32
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector32
) -> Result<Vec<u32>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector32
) -> Result<Vec<u32>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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
use concrete_core::commons::crypto::lwe::LweCiphertext;
let lwe_size = LweSize(128);
let lwe_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.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_vector: LweCiphertextVector32 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVector32
) -> Vec<u32>
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVector32
) -> Vec<u32>
sourceimpl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector64, Vec<u64, Global>> for DefaultEngine
impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector64, Vec<u64, Global>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVector64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector64
) -> Result<Vec<u64>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVector64
) -> Result<Vec<u64>, LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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
use concrete_core::commons::crypto::lwe::LweCiphertext;
let lwe_size = LweSize(128);
let lwe_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.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_vector: LweCiphertextVector64 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
let retrieved_container = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVector64
) -> Vec<u64>
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVector64
) -> Vec<u64>
sourceimpl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorMutView32<'data>, &'data mut [u32]> for DefaultEngine
impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorMutView32<'data>, &'data mut [u32]> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVectorMutView32
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorMutView32<'data>
) -> Result<&'data mut [u32], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorMutView32<'data>
) -> Result<&'data mut [u32], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_ciphertext_count.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_vector_view: LweCiphertextVectorMutView32 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorMutView32<'data>
) -> &'data mut [u32]
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorMutView32<'data>
) -> &'data mut [u32]
sourceimpl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorMutView64<'data>, &'data mut [u64]> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVectorMutView64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorMutView64<'data>
) -> Result<&'data mut [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorMutView64<'data>
) -> Result<&'data mut [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_ciphertext_count.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_vector_view: LweCiphertextVectorMutView64 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorMutView64<'data>
) -> &'data mut [u64]
sourceimpl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorView32<'data>, &'data [u32]> for DefaultEngine
impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorView32<'data>, &'data [u32]> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVectorView32
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorView32<'data>
) -> Result<&'data [u32], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorView32<'data>
) -> Result<&'data [u32], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_ciphertext_count.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_vector_view: LweCiphertextVectorView32 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorView32<'data>
) -> &'data [u32]
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorView32<'data>
) -> &'data [u32]
sourceimpl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorView64<'data>, &'data [u64]> for DefaultEngine
impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorView64<'data>, &'data [u64]> for DefaultEngine
Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine
for DefaultEngine
that
returns the underlying slice of a LweCiphertextVectorView64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorView64<'data>
) -> Result<&'data [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext_vector(
&mut self,
ciphertext: LweCiphertextVectorView64<'data>
) -> Result<&'data [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_ciphertext_count.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_vector_view: LweCiphertextVectorView64 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorView64<'data>
) -> &'data [u64]
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
&mut self,
ciphertext: LweCiphertextVectorView64<'data>
) -> &'data [u64]
sourceimpl<'data> LweCiphertextVectorCreationEngine<&'data [u32], LweCiphertextVectorView32<'data>> for DefaultEngine
impl<'data> LweCiphertextVectorCreationEngine<&'data [u32], LweCiphertextVectorView32<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns an
immutable LweCiphertextVectorView32
that does not own its memory.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data [u32],
lwe_size: LweSize
) -> Result<LweCiphertextVectorView32<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data [u32],
lwe_size: LweSize
) -> Result<LweCiphertextVectorView32<'data>, LweCiphertextVectorCreationError<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 lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.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_vector_view: LweCiphertextVectorView32 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u32],
lwe_size: LweSize
) -> LweCiphertextVectorView32<'data>
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u32],
lwe_size: LweSize
) -> LweCiphertextVectorView32<'data>
sourceimpl<'data> LweCiphertextVectorCreationEngine<&'data [u64], LweCiphertextVectorView64<'data>> for DefaultEngine
impl<'data> LweCiphertextVectorCreationEngine<&'data [u64], LweCiphertextVectorView64<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns an
immutable LweCiphertextVectorView64
that does not own its memory.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data [u64],
lwe_size: LweSize
) -> Result<LweCiphertextVectorView64<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data [u64],
lwe_size: LweSize
) -> Result<LweCiphertextVectorView64<'data>, LweCiphertextVectorCreationError<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 lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.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_vector_view: LweCiphertextVectorView64 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u64],
lwe_size: LweSize
) -> LweCiphertextVectorView64<'data>
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data [u64],
lwe_size: LweSize
) -> LweCiphertextVectorView64<'data>
sourceimpl<'data> LweCiphertextVectorCreationEngine<&'data mut [u32], LweCiphertextVectorMutView32<'data>> for DefaultEngine
impl<'data> LweCiphertextVectorCreationEngine<&'data mut [u32], LweCiphertextVectorMutView32<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
mutable LweCiphertextVectorMutView32
that does not own its memory.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u32],
lwe_size: LweSize
) -> Result<LweCiphertextVectorMutView32<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u32],
lwe_size: LweSize
) -> Result<LweCiphertextVectorMutView32<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.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_vector_view: LweCiphertextVectorMutView32 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u32],
lwe_size: LweSize
) -> LweCiphertextVectorMutView32<'data>
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u32],
lwe_size: LweSize
) -> LweCiphertextVectorMutView32<'data>
sourceimpl<'data> LweCiphertextVectorCreationEngine<&'data mut [u64], LweCiphertextVectorMutView64<'data>> for DefaultEngine
impl<'data> LweCiphertextVectorCreationEngine<&'data mut [u64], LweCiphertextVectorMutView64<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
mutable LweCiphertextVectorMutView64
that does not own its memory.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u64],
lwe_size: LweSize
) -> Result<LweCiphertextVectorMutView64<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: &'data mut [u64],
lwe_size: LweSize
) -> Result<LweCiphertextVectorMutView64<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweSize, *};
// 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(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.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_vector_view: LweCiphertextVectorMutView64 =
engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u64],
lwe_size: LweSize
) -> LweCiphertextVectorMutView64<'data>
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: &'data mut [u64],
lwe_size: LweSize
) -> LweCiphertextVectorMutView64<'data>
sourceimpl LweCiphertextVectorCreationEngine<Vec<u32, Global>, LweCiphertextVector32> for DefaultEngine
impl LweCiphertextVectorCreationEngine<Vec<u32, Global>, LweCiphertextVector32> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
LweCiphertextVector32
.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u32>,
lwe_size: LweSize
) -> Result<LweCiphertextVector32, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u32>,
lwe_size: LweSize
) -> Result<LweCiphertextVector32, LweCiphertextVectorCreationError<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 lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u32; lwe_size.0 * lwe_count.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_vector: LweCiphertextVector32 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u32>,
lwe_size: LweSize
) -> LweCiphertextVector32
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u32>,
lwe_size: LweSize
) -> LweCiphertextVector32
sourceimpl LweCiphertextVectorCreationEngine<Vec<u64, Global>, LweCiphertextVector64> for DefaultEngine
impl LweCiphertextVectorCreationEngine<Vec<u64, Global>, LweCiphertextVector64> for DefaultEngine
Description:
Implementation of LweCiphertextVectorCreationEngine
for DefaultEngine
which returns a
LweCiphertextVector64
.
sourcefn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> Result<LweCiphertextVector64, LweCiphertextVectorCreationError<Self::EngineError>>
fn create_lwe_ciphertext_vector_from(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> Result<LweCiphertextVector64, LweCiphertextVectorCreationError<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 lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.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_vector: LweCiphertextVector64 =
engine.create_lwe_ciphertext_vector_from(owned_container, lwe_size)?;
sourceunsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> LweCiphertextVector64
unsafe fn create_lwe_ciphertext_vector_from_unchecked(
&mut self,
container: Vec<u64>,
lwe_size: LweSize
) -> LweCiphertextVector64
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_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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)
);
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
sourceimpl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVectorView32<'_>, PlaintextVector32> for DefaultEngine
impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVectorView32<'_>, 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: &LweCiphertextVectorView32<'_>
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVectorView32<'_>
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(18);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; lwe_count.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let mut raw_ciphertext_vector = vec![0_u32; key.lwe_dimension().to_lwe_size().0 * lwe_count.0];
let mut ciphertext_vector_view: LweCiphertextVectorMutView32 = engine
.create_lwe_ciphertext_vector_from(
&mut raw_ciphertext_vector[..],
lwe_dimension.to_lwe_size(),
)?;
engine.discard_encrypt_lwe_ciphertext_vector(
&key,
&mut ciphertext_vector_view,
&plaintext_vector,
noise,
)?;
// Convert MutView to View
let raw_ciphertext_vector =
engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
let ciphertext_vector_view: LweCiphertextVectorView32 = engine
.create_lwe_ciphertext_vector_from(
&raw_ciphertext_vector[..],
lwe_dimension.to_lwe_size(),
)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector_view)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(lwe_count.0)
);
sourceunsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVectorView32<'_>
) -> PlaintextVector32
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVectorView32<'_>
) -> PlaintextVector32
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_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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)
);
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
sourceimpl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVectorView64<'_>, PlaintextVector64> for DefaultEngine
impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVectorView64<'_>, 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: &LweCiphertextVectorView64<'_>
) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVectorView64<'_>
) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(18);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let mut raw_ciphertext_vector = vec![0_u64; key.lwe_dimension().to_lwe_size().0 * lwe_count.0];
let mut ciphertext_vector_view: LweCiphertextVectorMutView64 = engine
.create_lwe_ciphertext_vector_from(
&mut raw_ciphertext_vector[..],
lwe_dimension.to_lwe_size(),
)?;
engine.discard_encrypt_lwe_ciphertext_vector(
&key,
&mut ciphertext_vector_view,
&plaintext_vector,
noise,
)?;
// Convert MutView to View
let raw_ciphertext_vector =
engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
let ciphertext_vector_view: LweCiphertextVectorView64 = engine
.create_lwe_ciphertext_vector_from(
&raw_ciphertext_vector[..],
lwe_dimension.to_lwe_size(),
)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector_view)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(lwe_count.0)
);
sourceunsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVectorView64<'_>
) -> PlaintextVector64
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
input: &LweCiphertextVectorView64<'_>
) -> PlaintextVector64
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector32 = engine.create_cleartext_vector_from(&input_vector)?;
let bias: Plaintext32 = engine.create_plaintext_from(&bias_input)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector64 = engine.create_cleartext_vector_from(&input_vector)?;
let bias: Plaintext64 = engine.create_plaintext_from(&bias_input)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 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.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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));
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
)
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_core::prelude::{LweCiphertextCount, LweDimension, PlaintextCount, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 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.generate_new_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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));
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
)
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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!(
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
)
sourceimpl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVectorMutView32<'_>> for DefaultEngine
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVectorMutView32<'_>> 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 LweCiphertextVectorMutView32<'_>,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVectorMutView32<'_>,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; lwe_count.0];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut output_ciphertext_vector_container = vec![0_32; lwe_dimension.to_lwe_size().0 *
lwe_count.0];
let mut ciphertext_vector: LweCiphertextVectorMutView32 =
engine.create_lwe_ciphertext_vector_from(&mut output_ciphertext_vector_container[..],
lwe_dimension.to_lwe_size())?;
engine.discard_encrypt_lwe_ciphertext_vector(&key, &mut ciphertext_vector,
&plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
sourceunsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVectorMutView32<'_>,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVectorMutView32<'_>,
input: &PlaintextVector32,
noise: Variance
)
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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!(
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
)
sourceimpl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVectorMutView64<'_>> for DefaultEngine
impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVectorMutView64<'_>> 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 LweCiphertextVectorMutView64<'_>,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &PlaintextVector64,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut output_ciphertext_vector_container = vec![0_64; lwe_dimension.to_lwe_size().0 *
lwe_count.0];
let mut ciphertext_vector: LweCiphertextVectorMutView64 =
engine.create_lwe_ciphertext_vector_from(&mut output_ciphertext_vector_container[..],
lwe_dimension.to_lwe_size())?;
engine.discard_encrypt_lwe_ciphertext_vector(&key, &mut ciphertext_vector,
&plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
sourceunsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &PlaintextVector64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextVectorMutView64<'_>,
input: &PlaintextVector64,
noise: Variance
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&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);
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
)
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input_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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&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);
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
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, 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: &LwePackingKeyswitchKey32
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &LwePackingKeyswitchKey32
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
sourceunsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &LwePackingKeyswitchKey32
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
ksk: &LwePackingKeyswitchKey32
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, 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: &LwePackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
fn discard_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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);
sourceunsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
)
unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
ksk: &LwePackingKeyswitchKey64
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine
Description:
Implementation of
LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine
for
DefaultEngine
that operates on 32 bits integers.
sourcefn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<Self::EngineError>>
fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let val = vec![1_u32; output_key.polynomial_size().0];
let polynomial: CleartextVector32 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
StandardDev(noise.get_standard_dev()),
&|x| x,
&polynomial,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut ciphertext_output,
&ciphertext_vector,
&private_functional_packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
sourceunsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32
)
unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext32,
input: &LweCiphertextVector32,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32
)
sourceimpl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine
Description:
Implementation of
LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine
for
DefaultEngine
that operates on 64 bits integers.
sourcefn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<Self::EngineError>>
fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
) -> Result<(), LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 =
engine.generate_new_glwe_secret_key(output_glwe_dimension, polynomial_size)?;
let val = vec![1_u64; output_key.polynomial_size().0];
let polynomial: CleartextVector64 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
StandardDev(noise.get_standard_dev()),
&|x| x,
&polynomial,
)?;
let plaintext_vector = engine.create_plaintext_vector_from(&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_private_functional_packing_keyswitch_lwe_ciphertext_vector(
&mut ciphertext_output,
&ciphertext_vector,
&private_functional_packing_keyswitch_key,
)?;
assert_eq!(ciphertext_output.glwe_dimension(), output_glwe_dimension);
sourceunsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
)
unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut GlweCiphertext64,
input: &LweCiphertextVector64,
pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64
)
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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));
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
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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));
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
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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
);
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
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_core::prelude::{LweSize, Variance, *};
// 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_from(&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
);
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
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_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// 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.generate_new_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);
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
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_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// 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.generate_new_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);
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
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_core::prelude::{LweDimension, Variance, *};
// 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.generate_new_lwe_secret_key(lwe_dimension)?;
let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
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
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_core::prelude::{LweDimension, Variance, *};
// 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.generate_new_lwe_secret_key(lwe_dimension)?;
let ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
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
sourceimpl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey32, GlweSecretKey32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultEngine
impl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey32, GlweSecretKey32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultEngine
Description:
Implementation of LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine
for DefaultEngine
that operates on 32 bits integers.
sourcefn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension,FunctionalPackingKeyswitchKeyCount
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;
let cbs_private_functional_packing_keyswitch_key:
LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32 =
engine
.generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&input_key,
&output_key,
decomposition_base_log,
decomposition_level_count,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(cbs_private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.key_count().0,
output_glwe_dimension.to_glwe_size().0);
sourceunsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32
unsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey32,
output_glwe_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32
sourceimpl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey64, GlweSecretKey64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultEngine
impl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey64, GlweSecretKey64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultEngine
Description:
Implementation of LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine
for DefaultEngine
that operates on 64 bits integers.
sourcefn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension,FunctionalPackingKeyswitchKeyCount
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;
let cbs_private_functional_packing_keyswitch_key:
LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64 =
engine
.generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
&input_key,
&output_key,
decomposition_base_log,
decomposition_level_count,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(cbs_private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
assert_eq!(cbs_private_functional_packing_keyswitch_key.key_count().0,
output_glwe_dimension.to_glwe_size().0);
sourceunsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64
unsafe fn generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys_unchecked(
&mut self,
input_lwe_key: &LweSecretKey64,
output_glwe_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64
sourceimpl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey32, Vec<u32, Global>> for DefaultEngine
impl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey32, Vec<u32, Global>> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKey32
) -> Result<Vec<u32>, LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKey32
) -> Result<Vec<u32>, LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let original_vec_ptr = owned_container.as_ptr();
let keyswitch_key: LweKeyswitchKey32 = engine.create_lwe_keyswitch_key_from(
owned_container,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_container = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKey32
) -> Vec<u32>
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKey32
) -> Vec<u32>
sourceimpl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey64, Vec<u64, Global>> for DefaultEngine
impl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey64, Vec<u64, Global>> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKey64
) -> Result<Vec<u64>, LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKey64
) -> Result<Vec<u64>, LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let original_vec_ptr = owned_container.as_ptr();
let keyswitch_key: LweKeyswitchKey64 = engine.create_lwe_keyswitch_key_from(
owned_container,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_container = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(original_vec_ptr, retrieved_container.as_ptr());
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKey64
) -> Vec<u64>
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKey64
) -> Vec<u64>
sourceimpl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView32<'data>, &'data mut [u32]> for DefaultEngine
impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView32<'data>, &'data mut [u32]> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView32<'data>
) -> Result<&'data mut [u32], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView32<'data>
) -> Result<&'data mut [u32], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
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(-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 mut owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let slice = owned_container.as_mut_slice();
let underlying_ptr = slice.as_ptr();
let keyswitch_key: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
slice,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView32<'data>
) -> &'data mut [u32]
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView32<'data>
) -> &'data mut [u32]
sourceimpl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> Result<&'data mut [u64], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> Result<&'data mut [u64], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
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(-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 mut owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let slice = owned_container.as_mut_slice();
let underlying_ptr = slice.as_ptr();
let keyswitch_key: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
slice,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> &'data mut [u64]
sourceimpl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView32<'data>, &'data [u32]> for DefaultEngine
impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView32<'data>, &'data [u32]> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyView32<'data>
) -> Result<&'data [u32], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyView32<'data>
) -> Result<&'data [u32], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let slice = owned_container.as_slice();
let keyswitch_key: LweKeyswitchKeyView32 = engine.create_lwe_keyswitch_key_from(
slice,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyView32<'data>
) -> &'data [u32]
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyView32<'data>
) -> &'data [u32]
sourceimpl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView64<'data>, &'data [u64]> for DefaultEngine
impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView64<'data>, &'data [u64]> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyView64<'data>
) -> Result<&'data [u64], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyView64<'data>
) -> Result<&'data [u64], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let slice = owned_container.as_slice();
let keyswitch_key: LweKeyswitchKeyView64 = engine.create_lwe_keyswitch_key_from(
slice,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(slice, retrieved_slice);
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyView64<'data>
) -> &'data [u64]
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyView64<'data>
) -> &'data [u64]
sourceimpl<'data> LweKeyswitchKeyCreationEngine<&'data [u32], LweKeyswitchKeyView32<'data>> for DefaultEngine
impl<'data> LweKeyswitchKeyCreationEngine<&'data [u32], LweKeyswitchKeyView32<'data>> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: &'data [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyView32<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: &'data [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyView32<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKeyView32 = engine.create_lwe_keyswitch_key_from(
owned_container.as_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyView32<'data>
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyView32<'data>
sourceimpl<'data> LweKeyswitchKeyCreationEngine<&'data [u64], LweKeyswitchKeyView64<'data>> for DefaultEngine
impl<'data> LweKeyswitchKeyCreationEngine<&'data [u64], LweKeyswitchKeyView64<'data>> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: &'data [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyView64<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: &'data [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyView64<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKeyView64 = engine.create_lwe_keyswitch_key_from(
owned_container.as_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyView64<'data>
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyView64<'data>
sourceimpl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u32], LweKeyswitchKeyMutView32<'data>> for DefaultEngine
impl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u32], LweKeyswitchKeyMutView32<'data>> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: &'data mut [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyMutView32<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: &'data mut [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyMutView32<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
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(-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 mut owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data mut [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyMutView32<'data>
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data mut [u32],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyMutView32<'data>
sourceimpl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u64], LweKeyswitchKeyMutView64<'data>> for DefaultEngine
impl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u64], LweKeyswitchKeyMutView64<'data>> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyMutView64<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyMutView64<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
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(-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 mut owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyMutView64<'data>
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyMutView64<'data>
sourceimpl LweKeyswitchKeyCreationEngine<Vec<u32, Global>, LweKeyswitchKey32> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<Vec<u32, Global>, LweKeyswitchKey32> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: Vec<u32>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: Vec<u32>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u32;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKey32 = engine.create_lwe_keyswitch_key_from(
owned_container,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: Vec<u32>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKey32
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: Vec<u32>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKey32
sourceimpl LweKeyswitchKeyCreationEngine<Vec<u64, Global>, LweKeyswitchKey64> for DefaultEngine
impl LweKeyswitchKeyCreationEngine<Vec<u64, Global>, LweKeyswitchKey64> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: Vec<u64>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: Vec<u64>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
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(-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 owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKey64 = engine.create_lwe_keyswitch_key_from(
owned_container,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: Vec<u64>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKey64
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: Vec<u64>,
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKey64
sourceimpl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey32, LweKeyswitchKeyMutView32<'_>> for DefaultEngine
impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey32, LweKeyswitchKeyMutView32<'_>> for DefaultEngine
sourcefn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView32<'_>,
input: &LweKeyswitchKey32
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView32<'_>,
input: &LweKeyswitchKey32
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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(-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: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut owned_container = vec![
0_u32;
decomposition_level_count.0 * output_lwe_dimension.to_lwe_size().0 * input_lwe_dimension.0
];
let mut out_ksk_mut_view: LweKeyswitchKeyMutView32 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
assert_eq!(
assert_eq!(out_ksk_mut_view.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(out_ksk_mut_view.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView32<'_>,
input: &LweKeyswitchKey32
)
unsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView32<'_>,
input: &LweKeyswitchKey32
)
sourceimpl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey64, LweKeyswitchKeyMutView64<'_>> for DefaultEngine
impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey64, LweKeyswitchKeyMutView64<'_>> for DefaultEngine
sourcefn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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(-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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut owned_container = vec![
0_u64;
decomposition_level_count.0 * output_lwe_dimension.to_lwe_size().0 * input_lwe_dimension.0
];
let mut out_ksk_mut_view: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
assert_eq!(
assert_eq!(out_ksk_mut_view.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(out_ksk_mut_view.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
)
unsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
)
sourceimpl LweKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
impl LweKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine
Description:
Implementation of LweKeyswitchKeyGenerationEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn generate_new_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey32, LweKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn generate_new_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 generate_new_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey32
sourceimpl LweKeyswitchKeyGenerationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine
impl LweKeyswitchKeyGenerationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine
Description:
Implementation of LweKeyswitchKeyGenerationEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn generate_new_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweKeyswitchKey64, LweKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
assert_eq!(
assert_eq!(
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn generate_new_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 generate_new_lwe_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweKeyswitchKey64
sourceimpl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LwePackingKeyswitchKey32> for DefaultEngine
impl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LwePackingKeyswitchKey32> for DefaultEngine
Description:
Implementation of LwePackingKeyswitchKeyGenerationEngine
for DefaultEngine
that
operates on 32 bits integers.
sourcefn generate_new_lwe_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LwePackingKeyswitchKey32, LwePackingKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LwePackingKeyswitchKey32, LwePackingKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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 output_polynomial_size = PolynomialSize(512);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(
output_glwe_dimension,
output_polynomial_size
)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_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_glwe_dimension(), output_glwe_dimension);
assert_eq!(packing_keyswitch_key.output_polynomial_size(), output_polynomial_size);
sourceunsafe fn generate_new_lwe_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LwePackingKeyswitchKey32
unsafe fn generate_new_lwe_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LwePackingKeyswitchKey32
sourceimpl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePackingKeyswitchKey64> for DefaultEngine
impl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePackingKeyswitchKey64> for DefaultEngine
Description:
Implementation of LwePackingKeyswitchKeyGenerationEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn generate_new_lwe_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LwePackingKeyswitchKey64, LwePackingKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LwePackingKeyswitchKey64, LwePackingKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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 output_polynomial_size = PolynomialSize(512);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(
output_glwe_dimension,
output_polynomial_size
)?;
let packing_keyswitch_key = engine.generate_new_lwe_packing_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_glwe_dimension(), output_glwe_dimension);
assert_eq!(packing_keyswitch_key.output_polynomial_size(), output_polynomial_size);
sourceunsafe fn generate_new_lwe_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LwePackingKeyswitchKey64
unsafe fn generate_new_lwe_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LwePackingKeyswitchKey64
sourceimpl LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LwePrivateFunctionalPackingKeyswitchKey32, CleartextVector32, u32> for DefaultEngine
impl LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LwePrivateFunctionalPackingKeyswitchKey32, CleartextVector32, u32> for DefaultEngine
Description:
Implementation of LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine
for
DefaultEngine
that operates on 32 bits integers.
Note that the function applied during keyswitching is of the form m -> m * pol for a polynomial
pol
. The input polynomial
should be a cleartext vector containing the coefficients of pol
starting with the constant term.
sourcefn generate_new_lwe_private_functional_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u32) -> u32,
polynomial: &CleartextVector32
) -> Result<LwePrivateFunctionalPackingKeyswitchKey32, LwePrivateFunctionalLwePackingKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_private_functional_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u32) -> u32,
polynomial: &CleartextVector32
) -> Result<LwePrivateFunctionalPackingKeyswitchKey32, LwePrivateFunctionalLwePackingKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(10);
let output_glwe_dimension = GlweDimension(3);
let polynomial_size = PolynomialSize(256);
let decomposition_base_log = DecompositionBaseLog(3);
let decomposition_level_count = DecompositionLevelCount(5);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey32 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;
let val = vec![1_u32; output_key.polynomial_size().0];
let polynomial: CleartextVector32 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
StandardDev(noise.get_standard_dev()),
&|x|x,
&polynomial,
)?;
assert_eq!(
assert_eq!(
assert_eq!(private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
sourceunsafe fn generate_new_lwe_private_functional_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u32) -> u32,
polynomial: &CleartextVector32
) -> LwePrivateFunctionalPackingKeyswitchKey32
unsafe fn generate_new_lwe_private_functional_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u32) -> u32,
polynomial: &CleartextVector32
) -> LwePrivateFunctionalPackingKeyswitchKey32
sourceimpl LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePrivateFunctionalPackingKeyswitchKey64, CleartextVector64, u64> for DefaultEngine
impl LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePrivateFunctionalPackingKeyswitchKey64, CleartextVector64, u64> for DefaultEngine
Description:
Implementation of LwePrivateFunctionalLwePackingKeyswitchKeyGenerationEngine
for
DefaultEngine
that operates on 64 bits integers.
Note that the function applied during keyswitching is of the form m -> m * pol for a polynomial
pol
. The input polynomial
should be a cleartext vector containing the coefficients of pol
starting with the constant term.
sourcefn generate_new_lwe_private_functional_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u64) -> u64,
polynomial: &CleartextVector64
) -> Result<LwePrivateFunctionalPackingKeyswitchKey64, LwePrivateFunctionalLwePackingKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_private_functional_packing_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u64) -> u64,
polynomial: &CleartextVector64
) -> Result<LwePrivateFunctionalPackingKeyswitchKey64, LwePrivateFunctionalLwePackingKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension, GlweDimension
};
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 polynomial_size = PolynomialSize(256);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: GlweSecretKey64 = engine.generate_new_glwe_secret_key(output_glwe_dimension,
polynomial_size)?;
let val = vec![1_u64; output_key.polynomial_size().0];
let polynomial: CleartextVector64 = engine.create_cleartext_vector_from(&val)?;
let private_functional_packing_keyswitch_key = engine
.generate_new_lwe_private_functional_packing_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
StandardDev(noise.get_standard_dev()),
&|x|x,
&polynomial,
)?;
assert_eq!(
assert_eq!(
assert_eq!(private_functional_packing_keyswitch_key.input_lwe_dimension(),
input_lwe_dimension);
assert_eq!(private_functional_packing_keyswitch_key.output_glwe_dimension(),
output_glwe_dimension);
sourceunsafe fn generate_new_lwe_private_functional_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u64) -> u64,
polynomial: &CleartextVector64
) -> LwePrivateFunctionalPackingKeyswitchKey64
unsafe fn generate_new_lwe_private_functional_packing_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: StandardDev,
f: &dyn Fn(u64) -> u64,
polynomial: &CleartextVector64
) -> LwePrivateFunctionalPackingKeyswitchKey64
sourceimpl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultEngine
impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultEngine
Description:
Implementation of LwePublicKeyGenerationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey32, LwePublicKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey32, LwePublicKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, LwePublicKeyZeroEncryptionCount, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let noise = Variance(2_f64.powf(-50.));
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(42);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey32 = engine.generate_new_lwe_public_key(
&lwe_secret_key,
noise,
lwe_public_key_zero_encryption_count,
)?;
assert_eq!(public_key.lwe_dimension(), lwe_dimension);
assert_eq!(
public_key.lwe_zero_encryption_count(),
lwe_public_key_zero_encryption_count
);
sourceunsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey32
unsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey32,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey32
sourceimpl LwePublicKeyGenerationEngine<LweSecretKey64, LwePublicKey64> for DefaultEngine
impl LwePublicKeyGenerationEngine<LweSecretKey64, LwePublicKey64> for DefaultEngine
Description:
Implementation of LwePublicKeyGenerationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey64, LwePublicKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_public_key(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> Result<LwePublicKey64, LwePublicKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, LwePublicKeyZeroEncryptionCount, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let noise = Variance(2_f64.powf(-50.));
let lwe_public_key_zero_encryption_count = LwePublicKeyZeroEncryptionCount(42);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let public_key: LwePublicKey64 = engine.generate_new_lwe_public_key(
&lwe_secret_key,
noise,
lwe_public_key_zero_encryption_count,
)?;
assert_eq!(public_key.lwe_dimension(), lwe_dimension);
assert_eq!(
public_key.lwe_zero_encryption_count(),
lwe_public_key_zero_encryption_count
);
sourceunsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey64
unsafe fn generate_new_lwe_public_key_unchecked(
&mut self,
lwe_secret_key: &LweSecretKey64,
noise: Variance,
lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount
) -> LwePublicKey64
sourceimpl LweSecretKeyGenerationEngine<LweSecretKey32> for DefaultEngine
impl LweSecretKeyGenerationEngine<LweSecretKey32> for DefaultEngine
Description:
Implementation of LweSecretKeyGenerationEngine
for DefaultEngine
that operates on
32 bits integers.
sourcefn generate_new_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey32, LweSecretKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey32, LweSecretKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
sourceunsafe fn generate_new_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey32
unsafe fn generate_new_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey32
sourceimpl LweSecretKeyGenerationEngine<LweSecretKey64> for DefaultEngine
impl LweSecretKeyGenerationEngine<LweSecretKey64> for DefaultEngine
Description:
Implementation of LweSecretKeyGenerationEngine
for DefaultEngine
that operates on
64 bits integers.
sourcefn generate_new_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey64, LweSecretKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_secret_key(
&mut self,
lwe_dimension: LweDimension
) -> Result<LweSecretKey64, LweSecretKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_secret_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
assert_eq!(lwe_secret_key.lwe_dimension(), lwe_dimension);
sourceunsafe fn generate_new_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey64
unsafe fn generate_new_lwe_secret_key_unchecked(
&mut self,
lwe_dimension: LweDimension
) -> LweSecretKey64
sourceimpl LweSeededBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweSeededBootstrapKey32> for DefaultEngine
impl LweSeededBootstrapKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LweSeededBootstrapKey32> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyGenerationEngine
for DefaultEngine
that operates
on 32 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey32, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey32, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweSeededBootstrapKey32 =
engine.generate_new_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
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);
sourceunsafe fn generate_new_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 generate_new_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &GlweSecretKey32,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey32
sourceimpl LweSeededBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultEngine
impl LweSeededBootstrapKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LweSeededBootstrapKey64> for DefaultEngine
Description:
Implementation of LweSeededBootstrapKeyGenerationEngine
for DefaultEngine
that operates
on 64 bits integers. It outputs a seeded bootstrap key in the standard domain.
sourcefn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_seeded_bootstrap_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> Result<LweSeededBootstrapKey64, LweSeededBootstrapKeyGenerationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweSeededBootstrapKey64 =
engine.generate_new_lwe_seeded_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
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);
sourceunsafe fn generate_new_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 generate_new_lwe_seeded_bootstrap_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &GlweSecretKey64,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount,
noise: Variance
) -> LweSeededBootstrapKey64
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, LweSeededBootstrapKeyToLweBootstrapKeyTransformationError<Self::EngineError>>
fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey32
) -> Result<LweBootstrapKey32, LweSeededBootstrapKeyToLweBootstrapKeyTransformationError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey32 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let seeded_bsk: LweSeededBootstrapKey32 =
engine.generate_new_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);
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
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, LweSeededBootstrapKeyToLweBootstrapKeyTransformationError<Self::EngineError>>
fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key(
&mut self,
lwe_seeded_bootstrap_key: LweSeededBootstrapKey64
) -> Result<LweBootstrapKey64, LweSeededBootstrapKeyToLweBootstrapKeyTransformationError<Self::EngineError>>
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 = engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let seeded_bsk: LweSeededBootstrapKey64 =
engine.generate_new_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);
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
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
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_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let ciphertext = engine.encrypt_lwe_seeded_ciphertext(&key, &plaintext, noise)?;
assert_eq!(ciphertext.lwe_dimension(), lwe_dimension);
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
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, LweSeededCiphertextToLweCiphertextTransformationError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext32
) -> Result<LweCiphertext32, LweSeededCiphertextToLweCiphertextTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = 3_u32 << 20;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let 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);
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
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, LweSeededCiphertextToLweCiphertextTransformationError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext(
&mut self,
lwe_seeded_ciphertext: LweSeededCiphertext64
) -> Result<LweCiphertext64, LweSeededCiphertextToLweCiphertextTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext_from(&input)?;
let 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);
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweSeededCiphertextVector32 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
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
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_core::prelude::Variance;
use concrete_core::prelude::{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.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweSeededCiphertextVector64 =
engine.encrypt_lwe_seeded_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
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
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, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32
) -> Result<LweCiphertextVector32, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey32 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let mut 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);
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
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, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<Self::EngineError>>
fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector(
&mut self,
lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64
) -> Result<LweCiphertextVector64, LweSeededCiphertextVectorToLweCiphertextVectorTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut 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);
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
sourceimpl LweSeededKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweSeededKeyswitchKey32> for DefaultEngine
impl LweSeededKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweSeededKeyswitchKey32> for DefaultEngine
sourcefn generate_new_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey32, LweSeededKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey32, LweSeededKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
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);
sourceunsafe fn generate_new_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 generate_new_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey32,
output_key: &LweSecretKey32,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey32
sourceimpl LweSeededKeyswitchKeyGenerationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine
impl LweSeededKeyswitchKeyGenerationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine
sourcefn generate_new_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey64, LweSeededKeyswitchKeyGenerationError<Self::EngineError>>
fn generate_new_lwe_seeded_keyswitch_key(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> Result<LweSeededKeyswitchKey64, LweSeededKeyswitchKeyGenerationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
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);
sourceunsafe fn generate_new_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 generate_new_lwe_seeded_keyswitch_key_unchecked(
&mut self,
input_key: &LweSecretKey64,
output_key: &LweSecretKey64,
decomposition_level_count: DecompositionLevelCount,
decomposition_base_log: DecompositionBaseLog,
noise: Variance
) -> LweSeededKeyswitchKey64
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, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationError<Self::EngineError>>
fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32
) -> Result<LweKeyswitchKey32, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey32 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let 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);
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
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, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationError<Self::EngineError>>
fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key(
&mut self,
lwe_seeded_keyswitch_key: LweSeededKeyswitchKey64
) -> Result<LweKeyswitchKey64, LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
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.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let seeded_keyswitch_key = engine.generate_new_lwe_seeded_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let 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);
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
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, LweToGlweSecretKeyTransformationError<Self::EngineError>>
fn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey32,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey32, LweToGlweSecretKeyTransformationError<Self::EngineError>>
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};
// 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.generate_new_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);
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
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, LweToGlweSecretKeyTransformationError<Self::EngineError>>
fn transform_lwe_secret_key_to_glwe_secret_key(
&mut self,
lwe_secret_key: LweSecretKey64,
polynomial_size: PolynomialSize
) -> Result<GlweSecretKey64, LweToGlweSecretKeyTransformationError<Self::EngineError>>
Example
use concrete_core::prelude::{GlweDimension, LweDimension, PolynomialSize, *};
// 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.generate_new_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);
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
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_from(
&mut self,
input: &u32
) -> Result<Plaintext32, PlaintextCreationError<Self::EngineError>>
fn create_plaintext_from(
&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_from(&input)?;
sourceunsafe fn create_plaintext_from_unchecked(&mut self, input: &u32) -> Plaintext32
unsafe fn create_plaintext_from_unchecked(&mut self, input: &u32) -> Plaintext32
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_from(
&mut self,
input: &u64
) -> Result<Plaintext64, PlaintextCreationError<Self::EngineError>>
fn create_plaintext_from(
&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_from(&input)?;
sourceunsafe fn create_plaintext_from_unchecked(&mut self, input: &u64) -> Plaintext64
unsafe fn create_plaintext_from_unchecked(&mut self, input: &u64) -> Plaintext64
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_from(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext32 = engine.encode_cleartext(&encoder, &cleartext)?;
let recovered_cleartext: CleartextF64 = engine.decode_plaintext(&encoder, &plaintext)?;
sourceunsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext32,
encoder: &FloatEncoder
) -> CleartextF64
unsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext32,
encoder: &FloatEncoder
) -> CleartextF64
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_from(&FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
})?;
let cleartext: CleartextF64 = engine.create_cleartext_from(&5.)?;
let plaintext: Plaintext64 = engine.encode_cleartext(&encoder, &cleartext)?;
let recovered_cleartext: CleartextF64 = engine.decode_plaintext(&encoder, &plaintext)?;
sourceunsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext64,
encoder: &FloatEncoder
) -> CleartextF64
unsafe fn decode_plaintext_unchecked(
&mut self,
input: &Plaintext64,
encoder: &FloatEncoder
) -> CleartextF64
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_from(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;
assert_eq!(output, 3_u32 << 20);
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
)
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_from(&input)?;
engine.discard_retrieve_plaintext(&mut output, &plaintext)?;
assert_eq!(output, 3_u64 << 20);
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
)
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_from(&input)?;
let output: u32 = engine.retrieve_plaintext(&plaintext)?;
assert_eq!(output, 3_u32 << 20);
sourceunsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext32) -> u32
unsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext32) -> u32
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_from(&input)?;
let output: u64 = engine.retrieve_plaintext(&plaintext)?;
assert_eq!(output, 3_u64 << 20);
sourceunsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext64) -> u64
unsafe fn retrieve_plaintext_unchecked(&mut self, plaintext: &Plaintext64) -> u64
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_from(
&mut self,
input: &[u32]
) -> Result<PlaintextVector32, PlaintextVectorCreationError<Self::EngineError>>
fn create_plaintext_vector_from(
&mut self,
input: &[u32]
) -> Result<PlaintextVector32, PlaintextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{PlaintextCount, *};
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
sourceunsafe fn create_plaintext_vector_from_unchecked(
&mut self,
input: &[u32]
) -> PlaintextVector32
unsafe fn create_plaintext_vector_from_unchecked(
&mut self,
input: &[u32]
) -> PlaintextVector32
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_from(
&mut self,
input: &[u64]
) -> Result<PlaintextVector64, PlaintextVectorCreationError<Self::EngineError>>
fn create_plaintext_vector_from(
&mut self,
input: &[u64]
) -> Result<PlaintextVector64, PlaintextVectorCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{PlaintextCount, *};
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; 3];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(3));
sourceunsafe fn create_plaintext_vector_from_unchecked(
&mut self,
input: &[u64]
) -> PlaintextVector64
unsafe fn create_plaintext_vector_from_unchecked(
&mut self,
input: &[u64]
) -> PlaintextVector64
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_from(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 =
engine.create_cleartext_vector_from(&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
);
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
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_from(&vec![
FloatEncoderMinMaxConfig {
min: 0.,
max: 10.,
nb_bit_precision: 8,
nb_bit_padding: 1,
};
100
])?;
let cleartext_vector: CleartextVectorF64 =
engine.create_cleartext_vector_from(&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
);
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
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_core::prelude::{PlaintextCount, *};
// 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_from(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
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
)
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_core::prelude::{PlaintextCount, *};
// 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_from(&input)?;
engine.discard_retrieve_plaintext_vector(output.as_mut_slice(), &plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);
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
)
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_core::prelude::{PlaintextCount, *};
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector_from(&input)?;
let output: Vec<u32> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u32 << 20);
sourceunsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector32
) -> Vec<u32>
unsafe fn retrieve_plaintext_vector_unchecked(
&mut self,
plaintext: &PlaintextVector32
) -> Vec<u32>
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_core::prelude::{PlaintextCount, *};
// 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_from(&input)?;
let output: Vec<u64> = engine.retrieve_plaintext_vector(&plaintext_vector)?;
assert_eq!(output[0], 3_u64 << 20);