DefaultEngine

Struct DefaultEngine 

Source
pub struct DefaultEngine { /* private fields */ }

Trait Implementations§

Source§

impl AbstractEngine for DefaultEngine

Source§

type EngineError = DefaultError

The error associated to the engine.
Source§

type Parameters = Box<dyn Seeder>

The constructor parameters type.
Source§

fn new(parameters: Self::Parameters) -> Result<Self, Self::EngineError>

A constructor for the engine.
Source§

impl CleartextCreationEngine<f64, CleartextF64> for DefaultEngine

§Description:

Implementation of CleartextCreationEngine for DefaultEngine that operates on 64 bits floating point numbers.

Source§

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)?;
Source§

unsafe fn create_cleartext_from_unchecked( &mut self, value: &f64, ) -> CleartextF64

Unsafely creates a cleartext from an arbitrary value. Read more
Source§

impl CleartextCreationEngine<u32, Cleartext32> for DefaultEngine

§Description:

Implementation of CleartextCreationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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)?;
Source§

unsafe fn create_cleartext_from_unchecked(&mut self, input: &u32) -> Cleartext32

Unsafely creates a cleartext from an arbitrary value. Read more
Source§

impl CleartextCreationEngine<u64, Cleartext64> for DefaultEngine

§Description:

Implementation of CleartextCreationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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)?;
Source§

unsafe fn create_cleartext_from_unchecked(&mut self, input: &u64) -> Cleartext64

Unsafely creates a cleartext from an arbitrary value. Read more
Source§

impl CleartextDiscardingRetrievalEngine<Cleartext32, u32> for DefaultEngine

§Description:

Implementation of CleartextDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_cleartext_unchecked( &mut self, output: &mut u32, input: &Cleartext32, )

Unsafely retrieves an arbitrary value from a cleartext. Read more
Source§

impl CleartextDiscardingRetrievalEngine<Cleartext64, u64> for DefaultEngine

§Description:

Implementation of CleartextDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_cleartext_unchecked( &mut self, output: &mut u64, input: &Cleartext64, )

Unsafely retrieves an arbitrary value from a cleartext. Read more
Source§

impl CleartextDiscardingRetrievalEngine<CleartextF64, f64> for DefaultEngine

§Description:

Implementation of CleartextDiscardingRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Source§

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);
Source§

unsafe fn discard_retrieve_cleartext_unchecked( &mut self, output: &mut f64, input: &CleartextF64, )

Unsafely retrieves an arbitrary value from a cleartext. Read more
Source§

impl CleartextEncodingEngine<FloatEncoder, CleartextF64, Plaintext32> for DefaultEngine

§Description:

Implementation of CleartextEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 32 bits integers.

Source§

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)?;
Source§

unsafe fn encode_cleartext_unchecked( &mut self, encoder: &FloatEncoder, cleartext: &CleartextF64, ) -> Plaintext32

Unsafely encodes a cleartext into a plaintext. Read more
Source§

impl CleartextEncodingEngine<FloatEncoder, CleartextF64, Plaintext64> for DefaultEngine

§Description:

Implementation of CleartextEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 32 bits integers.

Source§

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)?;
Source§

unsafe fn encode_cleartext_unchecked( &mut self, encoder: &FloatEncoder, cleartext: &CleartextF64, ) -> Plaintext64

Unsafely encodes a cleartext into a plaintext. Read more
Source§

impl CleartextRetrievalEngine<Cleartext32, u32> for DefaultEngine

§Description:

Implementation of CleartextRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn retrieve_cleartext_unchecked( &mut self, cleartext: &Cleartext32, ) -> u32

Unsafely retrieves an arbitrary value from a cleartext. Read more
Source§

impl CleartextRetrievalEngine<Cleartext64, u64> for DefaultEngine

§Description:

Implementation of CleartextRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn retrieve_cleartext_unchecked( &mut self, cleartext: &Cleartext64, ) -> u64

Unsafely retrieves an arbitrary value from a cleartext. Read more
Source§

impl CleartextRetrievalEngine<CleartextF64, f64> for DefaultEngine

§Description:

Implementation of CleartextRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Source§

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);
Source§

unsafe fn retrieve_cleartext_unchecked( &mut self, cleartext: &CleartextF64, ) -> f64

Unsafely retrieves an arbitrary value from a cleartext. Read more
Source§

impl CleartextVectorCreationEngine<f64, CleartextVectorF64> for DefaultEngine

§Description:

Implementation of CleartextVectorCreationEngine for DefaultEngine that operates on 64 bits floating point numbers.

Source§

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));
Source§

unsafe fn create_cleartext_vector_from_unchecked( &mut self, values: &[f64], ) -> CleartextVectorF64

Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
Source§

impl CleartextVectorCreationEngine<u32, CleartextVector32> for DefaultEngine

§Description:

Implementation of CleartextVectorCreationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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));
Source§

unsafe fn create_cleartext_vector_from_unchecked( &mut self, input: &[u32], ) -> CleartextVector32

Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
Source§

impl CleartextVectorCreationEngine<u64, CleartextVector64> for DefaultEngine

§Description:

Implementation of CleartextVectorCreationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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));
Source§

unsafe fn create_cleartext_vector_from_unchecked( &mut self, input: &[u64], ) -> CleartextVector64

Unsafely creates a cleartext vector from a slice of arbitrary values. Read more
Source§

impl CleartextVectorDiscardingRetrievalEngine<CleartextVector32, u32> for DefaultEngine

§Description:

Implementation of CleartextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_cleartext_vector_unchecked( &mut self, output: &mut [u32], input: &CleartextVector32, )

Unsafely retrieves arbitrary values from a cleartext vector. Read more
Source§

impl CleartextVectorDiscardingRetrievalEngine<CleartextVector64, u64> for DefaultEngine

§Description:

Implementation of CleartextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_cleartext_vector_unchecked( &mut self, output: &mut [u64], input: &CleartextVector64, )

Unsafely retrieves arbitrary values from a cleartext vector. Read more
Source§

impl CleartextVectorDiscardingRetrievalEngine<CleartextVectorF64, f64> for DefaultEngine

§Description:

Implementation of CleartextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Source§

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);
Source§

unsafe fn discard_retrieve_cleartext_vector_unchecked( &mut self, output: &mut [f64], input: &CleartextVectorF64, )

Unsafely retrieves arbitrary values from a cleartext vector. Read more
Source§

impl CleartextVectorEncodingEngine<FloatEncoderVector, CleartextVectorF64, PlaintextVector32> for DefaultEngine

§Description:

Implementation of CleartextVectorEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 32 bits integers.

Source§

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
);
Source§

unsafe fn encode_cleartext_vector_unchecked( &mut self, encoder_vector: &FloatEncoderVector, cleartext_vector: &CleartextVectorF64, ) -> PlaintextVector32

Unsafely encodes a cleartext vector into a plaintext vector. Read more
Source§

impl CleartextVectorEncodingEngine<FloatEncoderVector, CleartextVectorF64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of CleartextVectorEncodingEngine for DefaultEngine that encodes 64 bits floating point numbers to 64 bits integers.

Source§

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
);
Source§

unsafe fn encode_cleartext_vector_unchecked( &mut self, encoder_vector: &FloatEncoderVector, cleartext_vector: &CleartextVectorF64, ) -> PlaintextVector64

Unsafely encodes a cleartext vector into a plaintext vector. Read more
Source§

impl CleartextVectorRetrievalEngine<CleartextVector32, u32> for DefaultEngine

§Description:

Implementation of CleartextVectorRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn retrieve_cleartext_vector_unchecked( &mut self, cleartext: &CleartextVector32, ) -> Vec<u32>

Unsafely retrieves arbitrary values from a cleartext vector. Read more
Source§

impl CleartextVectorRetrievalEngine<CleartextVector64, u64> for DefaultEngine

§Description:

Implementation of CleartextVectorRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn retrieve_cleartext_vector_unchecked( &mut self, cleartext: &CleartextVector64, ) -> Vec<u64>

Unsafely retrieves arbitrary values from a cleartext vector. Read more
Source§

impl CleartextVectorRetrievalEngine<CleartextVectorF64, f64> for DefaultEngine

§Description:

Implementation of CleartextVectorRetrievalEngine for DefaultEngine that operates on 64 bits floating point numbers.

Source§

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);
Source§

unsafe fn retrieve_cleartext_vector_unchecked( &mut self, cleartext: &CleartextVectorF64, ) -> Vec<f64>

Unsafely retrieves arbitrary values from a cleartext vector. Read more
Source§

impl EncoderCreationEngine<FloatEncoderCenterRadiusConfig, FloatEncoder> for DefaultEngine

§Description:

Implementation of EncoderCreationEngine for DefaultEngine that creates an encoder to encode 64 bits floating point numbers.

Source§

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,
})?;
Source§

unsafe fn create_encoder_from_unchecked( &mut self, config: &FloatEncoderCenterRadiusConfig, ) -> FloatEncoder

Unsafely creates an encoder from a config. Read more
Source§

impl EncoderCreationEngine<FloatEncoderMinMaxConfig, FloatEncoder> for DefaultEngine

§Description:

Implementation of EncoderCreationEngine for DefaultEngine that creates an encoder to encode 64 bits floating point numbers.

Source§

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,
})?;
Source§

unsafe fn create_encoder_from_unchecked( &mut self, config: &FloatEncoderMinMaxConfig, ) -> FloatEncoder

Unsafely creates an encoder from a config. Read more
Source§

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.

Source§

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
])?;
Source§

unsafe fn create_encoder_vector_from_unchecked( &mut self, config: &[FloatEncoderCenterRadiusConfig], ) -> FloatEncoderVector

Unsafely creates an encoder vector from a config. Read more
Source§

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.

Source§

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(),
)?;
Source§

unsafe fn create_encoder_vector_from_unchecked( &mut self, config: &[FloatEncoderMinMaxConfig], ) -> FloatEncoderVector

Unsafely creates an encoder vector from a config. Read more
Source§

impl GgswCiphertextScalarDiscardingEncryptionEngine<GlweSecretKey32, Plaintext32, GgswCiphertext32> for DefaultEngine

§Description:

Implementation of GgswCiphertextScalarDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_scalar_ggsw_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, output: &mut GgswCiphertext32, input: &Plaintext32, noise: Variance, )

Unsafely encrypts a GGSW ciphertext. Read more
Source§

impl GgswCiphertextScalarDiscardingEncryptionEngine<GlweSecretKey64, Plaintext64, GgswCiphertext64> for DefaultEngine

§Description:

Implementation of GgswCiphertextScalarDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_scalar_ggsw_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, output: &mut GgswCiphertext64, input: &Plaintext64, noise: Variance, )

Unsafely encrypts a GGSW ciphertext. Read more
Source§

impl GgswCiphertextScalarEncryptionEngine<GlweSecretKey32, Plaintext32, GgswCiphertext32> for DefaultEngine

§Description:

Implementation of GgswCiphertextScalarEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_scalar_ggsw_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, input: &Plaintext32, noise: Variance, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, ) -> GgswCiphertext32

Unsafely encrypts a plaintext vector into a GGSW ciphertext. Read more
Source§

impl GgswCiphertextScalarEncryptionEngine<GlweSecretKey64, Plaintext64, GgswCiphertext64> for DefaultEngine

§Description:

Implementation of GgswCiphertextScalarEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_scalar_ggsw_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, input: &Plaintext64, noise: Variance, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, ) -> GgswCiphertext64

Unsafely encrypts a plaintext vector into a GGSW ciphertext. Read more
Source§

impl GgswCiphertextScalarTrivialEncryptionEngine<Plaintext32, GgswCiphertext32> for DefaultEngine

§Description:

Implementation of GgswCiphertextScalarTrivialEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn trivially_encrypt_scalar_ggsw_ciphertext_unchecked( &mut self, polynomial_size: PolynomialSize, glwe_size: GlweSize, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, input: &Plaintext32, ) -> GgswCiphertext32

Unsafely creates the trivial GGSW encryption of the plaintext. Read more
Source§

impl GgswCiphertextScalarTrivialEncryptionEngine<Plaintext64, GgswCiphertext64> for DefaultEngine

§Description:

Implementation of GgswCiphertextScalarTrivialEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn trivially_encrypt_scalar_ggsw_ciphertext_unchecked( &mut self, polynomial_size: PolynomialSize, glwe_size: GlweSize, decomposition_level_count: DecompositionLevelCount, decomposition_base_log: DecompositionBaseLog, input: &Plaintext64, ) -> GgswCiphertext64

Unsafely creates the trivial GGSW encryption of the plaintext. Read more
Source§

impl GlweCiphertextConsumingRetrievalEngine<GlweCiphertext32, Vec<u32>> for DefaultEngine

§Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a GlweCiphertext32 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_unchecked( &mut self, ciphertext: GlweCiphertext32, ) -> Vec<u32>

Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
Source§

impl GlweCiphertextConsumingRetrievalEngine<GlweCiphertext64, Vec<u64>> for DefaultEngine

§Description:

Implementation of GlweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a GlweCiphertext64 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_unchecked( &mut self, ciphertext: GlweCiphertext64, ) -> Vec<u64>

Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_unchecked( &mut self, ciphertext: GlweCiphertextMutView32<'data>, ) -> &'data mut [u32]

Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_unchecked( &mut self, ciphertext: GlweCiphertextMutView64<'data>, ) -> &'data mut [u64]

Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_glwe_ciphertext_unchecked( &mut self, ciphertext: GlweCiphertextView32<'data>, ) -> &'data [u32]

Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_glwe_ciphertext_unchecked( &mut self, ciphertext: GlweCiphertextView64<'data>, ) -> &'data [u64]

Unsafely retrieves the content of the container from a GLWE ciphertext, consuming it in the process. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_glwe_ciphertext_from_unchecked( &mut self, container: &'data [u32], polynomial_size: PolynomialSize, ) -> GlweCiphertextView32<'data>

Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_glwe_ciphertext_from_unchecked( &mut self, container: &'data [u64], polynomial_size: PolynomialSize, ) -> GlweCiphertextView64<'data>

Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_glwe_ciphertext_from_unchecked( &mut self, container: &'data mut [u32], polynomial_size: PolynomialSize, ) -> GlweCiphertextMutView32<'data>

Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_glwe_ciphertext_from_unchecked( &mut self, container: &'data mut [u64], polynomial_size: PolynomialSize, ) -> GlweCiphertextMutView64<'data>

Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Source§

impl GlweCiphertextCreationEngine<Vec<u32>, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of GlweCiphertextCreationEngine for DefaultEngine which returns a GlweCiphertext32.

Source§

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)?;
Source§

unsafe fn create_glwe_ciphertext_from_unchecked( &mut self, container: Vec<u32>, polynomial_size: PolynomialSize, ) -> GlweCiphertext32

Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Source§

impl GlweCiphertextCreationEngine<Vec<u64>, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of GlweCiphertextCreationEngine for DefaultEngine which returns a GlweCiphertext64.

Source§

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)?;
Source§

unsafe fn create_glwe_ciphertext_from_unchecked( &mut self, container: Vec<u64>, polynomial_size: PolynomialSize, ) -> GlweCiphertext64

Unsafely creates a GLWE ciphertext from an arbitrary container. Read more
Source§

impl GlweCiphertextDecryptionEngine<GlweSecretKey32, GlweCiphertext32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn decrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, input: &GlweCiphertext32, ) -> PlaintextVector32

Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more
Source§

impl GlweCiphertextDecryptionEngine<GlweSecretKey64, GlweCiphertext64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn decrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, input: &GlweCiphertext64, ) -> PlaintextVector64

Unsafely decrypts a GLWE ciphertext into a plaintext vector. Read more
Source§

impl GlweCiphertextDiscardingDecryptionEngine<GlweSecretKey32, GlweCiphertext32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextDiscardingDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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));
Source§

unsafe fn discard_decrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, output: &mut PlaintextVector32, input: &GlweCiphertext32, )

Unsafely decrypts a GLWE ciphertext . Read more
Source§

impl GlweCiphertextDiscardingDecryptionEngine<GlweSecretKey64, GlweCiphertext64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextDiscardingDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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));
Source§

unsafe fn discard_decrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, output: &mut PlaintextVector64, input: &GlweCiphertext64, )

Unsafely decrypts a GLWE ciphertext . Read more
Source§

impl GlweCiphertextDiscardingEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of GlweCiphertextDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, output: &mut GlweCiphertext32, input: &PlaintextVector32, noise: Variance, )

Unsafely encrypts a GLWE ciphertext . Read more
Source§

impl GlweCiphertextDiscardingEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of GlweCiphertextDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, output: &mut GlweCiphertext64, input: &PlaintextVector64, noise: Variance, )

Unsafely encrypts a GLWE ciphertext . Read more
Source§

impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector32, GlweCiphertext32> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked( &mut self, output: &mut GlweCiphertext32, input: &PlaintextVector32, )

Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Source§

impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector32, GlweCiphertextMutView32<'_>> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked( &mut self, output: &mut GlweCiphertextMutView32<'_>, input: &PlaintextVector32, )

Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Source§

impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector64, GlweCiphertext64> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked( &mut self, output: &mut GlweCiphertext64, input: &PlaintextVector64, )

Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Source§

impl GlweCiphertextDiscardingTrivialEncryptionEngine<PlaintextVector64, GlweCiphertextMutView64<'_>> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_trivially_encrypt_glwe_ciphertext_unchecked( &mut self, output: &mut GlweCiphertextMutView64<'_>, input: &PlaintextVector64, )

Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext. Read more
Source§

impl GlweCiphertextEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of GlweCiphertextEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> GlweCiphertext32

Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
Source§

impl GlweCiphertextEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of GlweCiphertextEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, input: &PlaintextVector64, noise: Variance, ) -> GlweCiphertext64

Unsafely encrypts a plaintext vector into a GLWE ciphertext. Read more
Source§

impl GlweCiphertextTrivialDecryptionEngine<GlweCiphertext32, PlaintextVector32> for DefaultEngine

Source§

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));
Source§

unsafe fn trivially_decrypt_glwe_ciphertext_unchecked( &mut self, input: &GlweCiphertext32, ) -> PlaintextVector32

Unsafely trivially decrypts a GLWE ciphertext into a plaintext vector. Read more
Source§

impl GlweCiphertextTrivialDecryptionEngine<GlweCiphertext64, PlaintextVector64> for DefaultEngine

Source§

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));
Source§

unsafe fn trivially_decrypt_glwe_ciphertext_unchecked( &mut self, input: &GlweCiphertext64, ) -> PlaintextVector64

Unsafely trivially decrypts a GLWE ciphertext into a plaintext vector. Read more
Source§

impl GlweCiphertextTrivialEncryptionEngine<PlaintextVector32, GlweCiphertext32> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_encrypt_glwe_ciphertext_unchecked( &mut self, glwe_size: GlweSize, input: &PlaintextVector32, ) -> GlweCiphertext32

Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
Source§

impl GlweCiphertextTrivialEncryptionEngine<PlaintextVector64, GlweCiphertext64> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_encrypt_glwe_ciphertext_unchecked( &mut self, glwe_size: GlweSize, input: &PlaintextVector64, ) -> GlweCiphertext64

Unsafely creates the trivial GLWE encryption of the plaintext vector. Read more
Source§

impl GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVector32, Vec<u32>> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVector32 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked( &mut self, ciphertext_vector: GlweCiphertextVector32, ) -> Vec<u32>

Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more
Source§

impl GlweCiphertextVectorConsumingRetrievalEngine<GlweCiphertextVector64, Vec<u64>> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a GlweCiphertextVector64 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked( &mut self, ciphertext_vector: GlweCiphertextVector64, ) -> Vec<u64>

Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked( &mut self, ciphertext_vector: GlweCiphertextVectorMutView32<'data>, ) -> &'data mut [u32]

Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked( &mut self, ciphertext_vector: GlweCiphertextVectorMutView64<'data>, ) -> &'data mut [u64]

Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked( &mut self, ciphertext_vector: GlweCiphertextVectorView32<'data>, ) -> &'data [u32]

Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_glwe_ciphertext_vector_unchecked( &mut self, ciphertext_vector: GlweCiphertextVectorView64<'data>, ) -> &'data [u64]

Unsafely retrieves the content of the container from a GLWE ciphertext vector, consuming it in the process. Read more
Source§

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.

Source§

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,
)?;
Source§

unsafe fn create_glwe_ciphertext_vector_from_unchecked( &mut self, container: &'data [u32], glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweCiphertextVectorView32<'data>

Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Source§

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.

Source§

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,
)?;
Source§

unsafe fn create_glwe_ciphertext_vector_from_unchecked( &mut self, container: &'data [u64], glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweCiphertextVectorView64<'data>

Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Source§

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.

Source§

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,
    )?;
Source§

unsafe fn create_glwe_ciphertext_vector_from_unchecked( &mut self, container: &'data mut [u32], glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweCiphertextVectorMutView32<'data>

Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Source§

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.

Source§

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,
    )?;
Source§

unsafe fn create_glwe_ciphertext_vector_from_unchecked( &mut self, container: &'data mut [u64], glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweCiphertextVectorMutView64<'data>

Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Source§

impl GlweCiphertextVectorCreationEngine<Vec<u32>, GlweCiphertextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorCreationEngine for DefaultEngine which returns an GlweCiphertextVector32.

Source§

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,
)?;
Source§

unsafe fn create_glwe_ciphertext_vector_from_unchecked( &mut self, container: Vec<u32>, glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweCiphertextVector32

Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Source§

impl GlweCiphertextVectorCreationEngine<Vec<u64>, GlweCiphertextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorCreationEngine for DefaultEngine which returns an GlweCiphertextVector64.

Source§

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,
)?;
Source§

unsafe fn create_glwe_ciphertext_vector_from_unchecked( &mut self, container: Vec<u64>, glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweCiphertextVector64

Unsafely creates a GLWE ciphertext vector from an arbitrary container. Read more
Source§

impl GlweCiphertextVectorDecryptionEngine<GlweSecretKey32, GlweCiphertextVector32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn decrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey32, input: &GlweCiphertextVector32, ) -> PlaintextVector32

Unsafely decrypts a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorDecryptionEngine<GlweSecretKey64, GlweCiphertextVector64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn decrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey64, input: &GlweCiphertextVector64, ) -> PlaintextVector64

Unsafely decrypts a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorDiscardingDecryptionEngine<GlweSecretKey32, GlweCiphertextVector32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorDiscardingDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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));
Source§

unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey32, output: &mut PlaintextVector32, input: &GlweCiphertextVector32, )

Unsafely encrypts a GLWE ciphertext vector . Read more
Source§

impl GlweCiphertextVectorDiscardingDecryptionEngine<GlweSecretKey64, GlweCiphertextVector64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorDiscardingDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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));
Source§

unsafe fn discard_decrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey64, output: &mut PlaintextVector64, input: &GlweCiphertextVector64, )

Unsafely encrypts a GLWE ciphertext vector . Read more
Source§

impl GlweCiphertextVectorDiscardingEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey32, output: &mut GlweCiphertextVector32, input: &PlaintextVector32, noise: Variance, )

Unsafely encrypts a GLWE ciphertext vector . Read more
Source§

impl GlweCiphertextVectorDiscardingEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn discard_encrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey64, output: &mut GlweCiphertextVector64, input: &PlaintextVector64, noise: Variance, )

Unsafely encrypts a GLWE ciphertext vector . Read more
Source§

impl GlweCiphertextVectorEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweCiphertextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> GlweCiphertextVector32

Unsafely encrypts a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweCiphertextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey64, input: &PlaintextVector64, noise: Variance, ) -> GlweCiphertextVector64

Unsafely encrypts a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorTrivialDecryptionEngine<GlweCiphertextVector32, PlaintextVector32> for DefaultEngine

Source§

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));
Source§

unsafe fn trivially_decrypt_glwe_ciphertext_vector_unchecked( &mut self, input: &GlweCiphertextVector32, ) -> PlaintextVector32

Unsafely trivially decrypts a GLWE ciphertext vector into a plaintext vector. Read more
Source§

impl GlweCiphertextVectorTrivialDecryptionEngine<GlweCiphertextVector64, PlaintextVector64> for DefaultEngine

Source§

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));
Source§

unsafe fn trivially_decrypt_glwe_ciphertext_vector_unchecked( &mut self, input: &GlweCiphertextVector64, ) -> PlaintextVector64

Unsafely trivially decrypts a GLWE ciphertext vector into a plaintext vector. Read more
Source§

impl GlweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, GlweCiphertextVector32> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_encrypt_glwe_ciphertext_vector_unchecked( &mut self, glwe_size: GlweSize, glwe_ciphertext_count: GlweCiphertextCount, input: &PlaintextVector32, ) -> GlweCiphertextVector32

Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, GlweCiphertextVector64> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_encrypt_glwe_ciphertext_vector_unchecked( &mut self, glwe_size: GlweSize, glwe_ciphertext_count: GlweCiphertextCount, input: &PlaintextVector64, ) -> GlweCiphertextVector64

Unsafely trivially encrypts a plaintext vector into a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorZeroEncryptionEngine<GlweSecretKey32, GlweCiphertextVector32> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorZeroEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey32, noise: Variance, count: GlweCiphertextCount, ) -> GlweCiphertextVector32

Unsafely encrypts zero in a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextVectorZeroEncryptionEngine<GlweSecretKey64, GlweCiphertextVector64> for DefaultEngine

§Description:

Implementation of GlweCiphertextVectorZeroEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_glwe_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey64, noise: Variance, count: GlweCiphertextCount, ) -> GlweCiphertextVector64

Unsafely encrypts zero in a GLWE ciphertext vector. Read more
Source§

impl GlweCiphertextZeroEncryptionEngine<GlweSecretKey32, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of GlweCiphertextZeroEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, noise: Variance, ) -> GlweCiphertext32

Unsafely encrypts a zero in a GLWE ciphertext. Read more
Source§

impl GlweCiphertextZeroEncryptionEngine<GlweSecretKey64, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of GlweCiphertextZeroEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_glwe_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, noise: Variance, ) -> GlweCiphertext64

Unsafely encrypts a zero in a GLWE ciphertext. Read more
Source§

impl GlweSecretKeyGenerationEngine<GlweSecretKey32> for DefaultEngine

§Description:

Implementation of GlweSecretKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn generate_new_glwe_secret_key_unchecked( &mut self, glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweSecretKey32

Unsafely generates a new GLWE secret key. Read more
Source§

impl GlweSecretKeyGenerationEngine<GlweSecretKey64> for DefaultEngine

§Description:

Implementation of GlweSecretKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn generate_new_glwe_secret_key_unchecked( &mut self, glwe_dimension: GlweDimension, polynomial_size: PolynomialSize, ) -> GlweSecretKey64

Unsafely generates a new GLWE secret key. Read more
Source§

impl GlweSeededCiphertextEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweSeededCiphertext32> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_seeded_ciphertext_unchecked( &mut self, key: &GlweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> GlweSeededCiphertext32

Unsafely encrypts a seeded GLWE ciphertext. Read more
Source§

impl GlweSeededCiphertextEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweSeededCiphertext64> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_seeded_ciphertext_unchecked( &mut self, key: &GlweSecretKey64, input: &PlaintextVector64, noise: Variance, ) -> GlweSeededCiphertext64

Unsafely encrypts a seeded GLWE ciphertext. Read more
Source§

impl GlweSeededCiphertextToGlweCiphertextTransformationEngine<GlweSeededCiphertext32, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextToGlweCiphertextTransformationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext_unchecked( &mut self, glwe_seeded_ciphertext: GlweSeededCiphertext32, ) -> GlweCiphertext32

Unsafely transforms a GLWE seeded ciphertext into a GLWE ciphertext Read more
Source§

impl GlweSeededCiphertextToGlweCiphertextTransformationEngine<GlweSeededCiphertext64, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextToGlweCiphertextTransformationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn transform_glwe_seeded_ciphertext_to_glwe_ciphertext_unchecked( &mut self, glwe_seeded_ciphertext: GlweSeededCiphertext64, ) -> GlweCiphertext64

Unsafely transforms a GLWE seeded ciphertext into a GLWE ciphertext Read more
Source§

impl GlweSeededCiphertextVectorEncryptionEngine<GlweSecretKey32, PlaintextVector32, GlweSeededCiphertextVector32> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_seeded_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> GlweSeededCiphertextVector32

Unsafely encrypts a GLWE seeded ciphertext vector. Read more
Source§

impl GlweSeededCiphertextVectorEncryptionEngine<GlweSecretKey64, PlaintextVector64, GlweSeededCiphertextVector64> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_glwe_seeded_ciphertext_vector_unchecked( &mut self, key: &GlweSecretKey64, input: &PlaintextVector64, noise: Variance, ) -> GlweSeededCiphertextVector64

Unsafely encrypts a GLWE seeded ciphertext vector. Read more
Source§

impl GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine<GlweSeededCiphertextVector32, GlweCiphertextVector32> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector_unchecked( &mut self, glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector32, ) -> GlweCiphertextVector32

Unsafely transforms a GLWE seeded ciphertext vector into a GLWE ciphertext vector Read more
Source§

impl GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine<GlweSeededCiphertextVector64, GlweCiphertextVector64> for DefaultEngine

§Description:

Implementation of GlweSeededCiphertextVectorToGlweCiphertextVectorTransformationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn transform_glwe_seeded_ciphertext_vector_to_glwe_ciphertext_vector_unchecked( &mut self, glwe_seeded_ciphertext_vector: GlweSeededCiphertextVector64, ) -> GlweCiphertextVector64

Unsafely transforms a GLWE seeded ciphertext vector into a GLWE ciphertext vector Read more
Source§

impl GlweToLweSecretKeyTransformationEngine<GlweSecretKey32, LweSecretKey32> for DefaultEngine

Source§

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));
Source§

unsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked( &mut self, glwe_secret_key: GlweSecretKey32, ) -> LweSecretKey32

Unsafely transforms a GLWE secret key into an LWE secret key Read more
Source§

impl GlweToLweSecretKeyTransformationEngine<GlweSecretKey64, LweSecretKey64> for DefaultEngine

Source§

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));
Source§

unsafe fn transform_glwe_secret_key_to_lwe_secret_key_unchecked( &mut self, glwe_secret_key: GlweSecretKey64, ) -> LweSecretKey64

Unsafely transforms a GLWE secret key into an LWE secret key Read more
Source§

impl LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKey32, Vec<u32>> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked( &mut self, bootstrap_key: LweBootstrapKey32, ) -> Vec<u32>

Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Source§

impl LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKey64, Vec<u64>> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked( &mut self, bootstrap_key: LweBootstrapKey64, ) -> Vec<u64>

Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Source§

impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView32<'data>, &'data mut [u32]> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked( &mut self, bootstrap_key: LweBootstrapKeyMutView32<'data>, ) -> &'data mut [u32]

Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Source§

impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked( &mut self, bootstrap_key: LweBootstrapKeyMutView64<'data>, ) -> &'data mut [u64]

Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Source§

impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyView32<'data>, &'data [u32]> for DefaultEngine

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked( &mut self, bootstrap_key: LweBootstrapKeyView32<'data>, ) -> &'data [u32]

Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Source§

impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyView64<'data>, &'data [u64]> for DefaultEngine

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked( &mut self, bootstrap_key: LweBootstrapKeyView64<'data>, ) -> &'data [u64]

Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in the process. Read more
Source§

impl<'data> LweBootstrapKeyCreationEngine<&'data [u32], LweBootstrapKeyView32<'data>> for DefaultEngine

Source§

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)?;
Source§

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>

Unsafely creates an LWE bootstrap key from an existing container. Read more
Source§

impl<'data> LweBootstrapKeyCreationEngine<&'data [u64], LweBootstrapKeyView64<'data>> for DefaultEngine

Source§

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)?;
Source§

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>

Unsafely creates an LWE bootstrap key from an existing container. Read more
Source§

impl<'data> LweBootstrapKeyCreationEngine<&'data mut [u32], LweBootstrapKeyMutView32<'data>> for DefaultEngine

Source§

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)?;
Source§

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>

Unsafely creates an LWE bootstrap key from an existing container. Read more
Source§

impl<'data> LweBootstrapKeyCreationEngine<&'data mut [u64], LweBootstrapKeyMutView64<'data>> for DefaultEngine

Source§

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)?;
Source§

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>

Unsafely creates an LWE bootstrap key from an existing container. Read more
Source§

impl LweBootstrapKeyCreationEngine<Vec<u32>, LweBootstrapKey32> for DefaultEngine

Source§

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,
)?;
Source§

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

Unsafely creates an LWE bootstrap key from an existing container. Read more
Source§

impl LweBootstrapKeyCreationEngine<Vec<u64>, LweBootstrapKey64> for DefaultEngine

Source§

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,
)?;
Source§

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

Unsafely creates an LWE bootstrap key from an existing container. Read more
Source§

impl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey32, LweBootstrapKeyMutView32<'_>> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_convert_lwe_bootstrap_key_unchecked( &mut self, output: &mut LweBootstrapKeyMutView32<'_>, input: &LweBootstrapKey32, )

Unsafely converts a LWE bootstrap key . Read more
Source§

impl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey64, LweBootstrapKeyMutView64<'_>> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_convert_lwe_bootstrap_key_unchecked( &mut self, output: &mut LweBootstrapKeyMutView64<'_>, input: &LweBootstrapKey64, )

Unsafely converts a LWE bootstrap key . Read more
Source§

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.

Source§

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);
Source§

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

Unsafely generates a new LWE bootstrap key. Read more
Source§

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.

Source§

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);
Source§

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

Unsafely generates a new LWE bootstrap key. Read more
Source§

impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertext32, Cleartext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertext32, input_1: &LweCiphertext32, input_2: &Cleartext32, )

Unsafely multiply an LWE ciphertext with a cleartext. Read more
Source§

impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertext64, Cleartext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertext64, input_1: &LweCiphertext64, input_2: &Cleartext64, )

Unsafely multiply an LWE ciphertext with a cleartext. Read more
Source§

impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView32<'_>, Cleartext32, LweCiphertextMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine that operates on views containing 32 bits integers.

Source§

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);
Source§

unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &Cleartext32, )

Unsafely multiply an LWE ciphertext with a cleartext. Read more
Source§

impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView64<'_>, Cleartext64, LweCiphertextMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine for DefaultEngine that operates on views containing 64 bits integers.

Source§

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);
Source§

unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertextMutView64<'_>, input_1: &LweCiphertextView64<'_>, input_2: &Cleartext64, )

Unsafely multiply an LWE ciphertext with a cleartext. Read more
Source§

impl LweCiphertextCleartextFusingMultiplicationEngine<LweCiphertext32, Cleartext32> for DefaultEngine

§Description:

Implementation of LweCiphertextCleartextFusingMultiplicationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertext32, input: &Cleartext32, )

Unsafely multiply an LWE ciphertext with a cleartext. Read more
Source§

impl LweCiphertextCleartextFusingMultiplicationEngine<LweCiphertext64, Cleartext64> for DefaultEngine

§Description:

Implementation of LweCiphertextCleartextFusingMultiplicationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_mul_lwe_ciphertext_cleartext_unchecked( &mut self, output: &mut LweCiphertext64, input: &Cleartext64, )

Unsafely multiply an LWE ciphertext with a cleartext. Read more
Source§

impl LweCiphertextConsumingRetrievalEngine<LweCiphertext32, Vec<u32>> for DefaultEngine

§Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a LweCiphertext32 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertext32, ) -> Vec<u32>

Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
Source§

impl LweCiphertextConsumingRetrievalEngine<LweCiphertext64, Vec<u64>> for DefaultEngine

§Description:

Implementation of LweCiphertextConsumingRetrievalEngine for DefaultEngine that returns the underlying vec of a LweCiphertext64 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertext64, ) -> Vec<u64>

Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertextMutView32<'data>, ) -> &'data mut [u32]

Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertextMutView64<'data>, ) -> &'data mut [u64]

Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertextView32<'data>, ) -> &'data [u32]

Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_ciphertext_unchecked( &mut self, ciphertext: LweCiphertextView64<'data>, ) -> &'data [u64]

Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: &'data [u32], ) -> LweCiphertextView32<'data>

Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: &'data [u64], ) -> LweCiphertextView64<'data>

Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: &'data mut [u32], ) -> LweCiphertextMutView32<'data>

Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: &'data mut [u64], ) -> LweCiphertextMutView64<'data>

Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Source§

impl LweCiphertextCreationEngine<Vec<u32>, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextCreationEngine for DefaultEngine which returns an LweCiphertext32.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: Vec<u32>, ) -> LweCiphertext32

Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Source§

impl LweCiphertextCreationEngine<Vec<u64>, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextCreationEngine for DefaultEngine which returns an LweCiphertext64.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_from_unchecked( &mut self, container: Vec<u64>, ) -> LweCiphertext64

Unsafely creates an LWE ciphertext from an arbitrary container. Read more
Source§

impl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertext32, Plaintext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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)?;
Source§

unsafe fn decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, input: &LweCiphertext32, ) -> Plaintext32

Unsafely decrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDecryptionEngine<LweSecretKey32, LweCiphertextView32<'_>, Plaintext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on an LweCiphertextView32 containing 32 bits integers.

Source§

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)?;
Source§

unsafe fn decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, input: &LweCiphertextView32<'_>, ) -> Plaintext32

Unsafely decrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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)?;
Source§

unsafe fn decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, input: &LweCiphertext64, ) -> Plaintext64

Unsafely decrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDecryptionEngine<LweSecretKey64, LweCiphertextView64<'_>, Plaintext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDecryptionEngine for DefaultEngine that operates on an LweCiphertextView64 containing 64 bits integers.

Source§

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)?;
Source§

unsafe fn decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, input: &LweCiphertextView64<'_>, ) -> Plaintext64

Unsafely decrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingAdditionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input_1: &LweCiphertext32, input_2: &LweCiphertext32, )

Unsafely adds two LWE ciphertexts. Read more
Source§

impl LweCiphertextDiscardingAdditionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input_1: &LweCiphertext64, input_2: &LweCiphertext64, )

Unsafely adds two LWE ciphertexts. Read more
Source§

impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates on views containing 32 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &LweCiphertextView32<'_>, )

Unsafely adds two LWE ciphertexts. Read more
Source§

impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingAdditionEngine for DefaultEngine that operates on on views containing 64 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView64<'_>, input_1: &LweCiphertextView64<'_>, input_2: &LweCiphertextView64<'_>, )

Unsafely adds two LWE ciphertexts. Read more
Source§

impl LweCiphertextDiscardingDecryptionEngine<LweSecretKey32, LweCiphertext32, Plaintext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, output: &mut Plaintext32, input: &LweCiphertext32, )

Unsafely decrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingDecryptionEngine<LweSecretKey64, LweCiphertext64, Plaintext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_decrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, output: &mut Plaintext64, input: &LweCiphertext64, )

Unsafely decrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, output: &mut LweCiphertext32, input: &Plaintext32, noise: Variance, )

Unsafely encrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, output: &mut LweCiphertextMutView32<'_>, input: &Plaintext32, noise: Variance, )

Unsafely encrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, output: &mut LweCiphertext64, input: &Plaintext64, noise: Variance, )

Unsafely encrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, output: &mut LweCiphertextMutView64<'_>, input: &Plaintext64, noise: Variance, )

Unsafely encrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingExtractionEngine<GlweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingExtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_extract_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input: &GlweCiphertext32, nth: MonomialIndex, )

Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingExtractionEngine<GlweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingExtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_extract_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input: &GlweCiphertext64, nth: MonomialIndex, )

Unsafely extracts an LWE ciphertext from a GLWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_keyswitch_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input: &LweCiphertext32, ksk: &LweKeyswitchKey32, )

Unsafely keyswitch an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey32, LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates on views containing 32 bits integers.

Source§

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);
Source§

unsafe fn discard_keyswitch_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input: &LweCiphertextView32<'_>, ksk: &LweKeyswitchKey32, )

Unsafely keyswitch an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_keyswitch_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input: &LweCiphertext64, ksk: &LweKeyswitchKey64, )

Unsafely keyswitch an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingKeyswitchEngine for DefaultEngine that operates on views containing 64 bits integers.

Source§

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);
Source§

unsafe fn discard_keyswitch_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView64<'_>, input: &LweCiphertextView64<'_>, ksk: &LweKeyswitchKey64, )

Unsafely keyswitch an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingOppositeEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_opp_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input: &LweCiphertext32, )

Unsafely computes the opposite of an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingOppositeEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_opp_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input: &LweCiphertext64, )

Unsafely computes the opposite of an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingOppositeEngine<LweCiphertextView32<'_>, LweCiphertextMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on views containing 32 bits integers.

Source§

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);
Source§

unsafe fn discard_opp_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input: &LweCiphertextView32<'_>, )

Unsafely computes the opposite of an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingOppositeEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingOppositeEngine for DefaultEngine that operates on views containing 64 bits integers.

Source§

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);
Source§

unsafe fn discard_opp_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertextMutView64<'_>, input: &LweCiphertextView64<'_>, )

Unsafely computes the opposite of an LWE ciphertext. Read more
Source§

impl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked( &mut self, key: &LwePublicKey32, output: &mut LweCiphertext32, input: &Plaintext32, )

Unsafely encrypts an LWE ciphertext using a public key. Read more
Source§

impl LweCiphertextDiscardingPublicKeyEncryptionEngine<LwePublicKey64, Plaintext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingPublicKeyEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_encrypt_lwe_ciphertext_with_public_key_unchecked( &mut self, key: &LwePublicKey64, output: &mut LweCiphertext64, input: &Plaintext64, )

Unsafely encrypts an LWE ciphertext using a public key. Read more
Source§

impl LweCiphertextDiscardingSubtractionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_sub_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input_1: &LweCiphertext32, input_2: &LweCiphertext32, )

Unsafely substracts two LWE ciphertexts. Read more
Source§

impl LweCiphertextDiscardingSubtractionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextDiscardingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_sub_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input_1: &LweCiphertext64, input_2: &LweCiphertext64, )

Unsafely substracts two LWE ciphertexts. Read more
Source§

impl LweCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, input: &Plaintext32, noise: Variance, ) -> LweCiphertext32

Unsafely encrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, input: &Plaintext64, noise: Variance, ) -> LweCiphertext64

Unsafely encrypts an LWE ciphertext. Read more
Source§

impl LweCiphertextFusingAdditionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextFusingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input: &LweCiphertext32, )

Unsafely add an LWE ciphertext to an other. Read more
Source§

impl LweCiphertextFusingAdditionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextFusingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_add_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input: &LweCiphertext64, )

Unsafely add an LWE ciphertext to an other. Read more
Source§

impl LweCiphertextFusingOppositeEngine<LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextFusingOppositeEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_opp_lwe_ciphertext_unchecked( &mut self, input: &mut LweCiphertext32, )

Unsafely computes the opposite of an LWE ciphertext. Read more
Source§

impl LweCiphertextFusingOppositeEngine<LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextFusingOppositeEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_opp_lwe_ciphertext_unchecked( &mut self, input: &mut LweCiphertext64, )

Unsafely computes the opposite of an LWE ciphertext. Read more
Source§

impl LweCiphertextFusingSubtractionEngine<LweCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextFusingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_sub_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext32, input: &LweCiphertext32, )

Unsafely subtracts an LWE ciphertext to another. Read more
Source§

impl LweCiphertextFusingSubtractionEngine<LweCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextFusingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_sub_lwe_ciphertext_unchecked( &mut self, output: &mut LweCiphertext64, input: &LweCiphertext64, )

Unsafely subtracts an LWE ciphertext to another. Read more
Source§

impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertext32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext32, input_1: &LweCiphertext32, input_2: &Plaintext32, )

Unsafely adds a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertext64, Plaintext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext64, input_1: &LweCiphertext64, input_2: &Plaintext64, )

Unsafely adds a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView32<'_>, Plaintext32, LweCiphertextMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on views containing 32 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertextMutView32<'_>, input_1: &LweCiphertextView32<'_>, input_2: &Plaintext32, )

Unsafely adds a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView64<'_>, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextDiscardingAdditionEngine for DefaultEngine that operates on views containing 64 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertextMutView64<'_>, input_1: &LweCiphertextView64<'_>, input_2: &Plaintext64, )

Unsafely adds a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextDiscardingSubtractionEngine<LweCiphertext32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextDiscardingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_sub_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext32, input_1: &LweCiphertext32, input_2: &Plaintext32, )

Unsafely subtracts a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextDiscardingSubtractionEngine<LweCiphertext64, Plaintext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextDiscardingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_sub_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext64, input_1: &LweCiphertext64, input_2: &Plaintext64, )

Unsafely subtracts a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextFusingAdditionEngine<LweCiphertext32, Plaintext32> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextFusingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext32, input: &Plaintext32, )

Unsafely add a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextFusingAdditionEngine<LweCiphertext64, Plaintext64> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextFusingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext64, input: &Plaintext64, )

Unsafely add a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextFusingSubtractionEngine<LweCiphertext32, Plaintext32> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextFusingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_sub_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext32, input: &Plaintext32, )

Unsafely subtracts a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextPlaintextFusingSubtractionEngine<LweCiphertext64, Plaintext64> for DefaultEngine

§Description:

Implementation of LweCiphertextPlaintextFusingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_sub_lwe_ciphertext_plaintext_unchecked( &mut self, output: &mut LweCiphertext64, input: &Plaintext64, )

Unsafely subtracts a plaintext to an LWE ciphertext. Read more
Source§

impl LweCiphertextTrivialDecryptionEngine<LweCiphertext32, Plaintext32> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_decrypt_lwe_ciphertext_unchecked( &mut self, input: &LweCiphertext32, ) -> Plaintext32

Unsafely trivially decrypts an LWE ciphertext into a plaintext. Read more
Source§

impl LweCiphertextTrivialDecryptionEngine<LweCiphertext64, Plaintext64> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_decrypt_lwe_ciphertext_unchecked( &mut self, input: &LweCiphertext64, ) -> Plaintext64

Unsafely trivially decrypts an LWE ciphertext into a plaintext. Read more
Source§

impl LweCiphertextTrivialEncryptionEngine<Plaintext32, LweCiphertext32> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_encrypt_lwe_ciphertext_unchecked( &mut self, lwe_size: LweSize, input: &Plaintext32, ) -> LweCiphertext32

Unsafely creates the trivial LWE encryption of the plaintext. Read more
Source§

impl LweCiphertextTrivialEncryptionEngine<Plaintext64, LweCiphertext64> for DefaultEngine

Source§

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);
Source§

unsafe fn trivially_encrypt_lwe_ciphertext_unchecked( &mut self, lwe_size: LweSize, input: &Plaintext64, ) -> LweCiphertext64

Unsafely creates the trivial LWE encryption of the plaintext. Read more
Source§

impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector32, Vec<u32>> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVector32 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVector32, ) -> Vec<u32>

Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more
Source§

impl LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVector64, Vec<u64>> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that returns the underlying slice of a LweCiphertextVector64 consuming it in the process

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVector64, ) -> Vec<u64>

Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVectorMutView32<'data>, ) -> &'data mut [u32]

Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVectorMutView64<'data>, ) -> &'data mut [u64]

Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVectorView32<'data>, ) -> &'data [u32]

Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more
Source§

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

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVectorView64<'data>, ) -> &'data [u64]

Unsafely retrieves the content of the container from an LWE ciphertext vector, consuming it in the process. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: &'data [u32], lwe_size: LweSize, ) -> LweCiphertextVectorView32<'data>

Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: &'data [u64], lwe_size: LweSize, ) -> LweCiphertextVectorView64<'data>

Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: &'data mut [u32], lwe_size: LweSize, ) -> LweCiphertextVectorMutView32<'data>

Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Source§

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.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: &'data mut [u64], lwe_size: LweSize, ) -> LweCiphertextVectorMutView64<'data>

Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Source§

impl LweCiphertextVectorCreationEngine<Vec<u32>, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a LweCiphertextVector32.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: Vec<u32>, lwe_size: LweSize, ) -> LweCiphertextVector32

Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Source§

impl LweCiphertextVectorCreationEngine<Vec<u64>, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns a LweCiphertextVector64.

Source§

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)?;
Source§

unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: Vec<u64>, lwe_size: LweSize, ) -> LweCiphertextVector64

Unsafely creates an LWE ciphertext vector from an arbitrary container. Read more
Source§

impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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)
);
Source§

unsafe fn decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, input: &LweCiphertextVector32, ) -> PlaintextVector32

Unsafely decrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDecryptionEngine<LweSecretKey32, LweCiphertextVectorView32<'_>, PlaintextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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)
);
Source§

unsafe fn decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, input: &LweCiphertextVectorView32<'_>, ) -> PlaintextVector32

Unsafely decrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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)
);
Source§

unsafe fn decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, input: &LweCiphertextVector64, ) -> PlaintextVector64

Unsafely decrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVectorView64<'_>, PlaintextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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)
);
Source§

unsafe fn decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, input: &LweCiphertextVectorView64<'_>, ) -> PlaintextVector64

Unsafely decrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input_1: &LweCiphertextVector32, input_2: &LweCiphertextVector32, )

Unsafely adds two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorDiscardingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_add_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector64, input_1: &LweCiphertextVector64, input_2: &LweCiphertextVector64, )

Unsafely adds two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector32, CleartextVector32, Plaintext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertext32, inputs: &LweCiphertextVector32, weights: &CleartextVector32, bias: &Plaintext32, )

Unsafely performs the affine transform of an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingAffineTransformationEngine<LweCiphertextVector64, CleartextVector64, Plaintext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertext64, inputs: &LweCiphertextVector64, weights: &CleartextVector64, bias: &Plaintext64, )

Unsafely performs the affine transform of an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey32, LweCiphertextVector32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingDecryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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));
Source§

unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, output: &mut PlaintextVector32, input: &LweCiphertextVector32, )

Unsafely decrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingDecryptionEngine<LweSecretKey64, LweCiphertextVector64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingDecryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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));
Source§

unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, output: &mut PlaintextVector64, input: &LweCiphertextVector64, )

Unsafely decrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, output: &mut LweCiphertextVector32, input: &PlaintextVector32, noise: Variance, )

Unsafely encryprs an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVectorMutView32<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, output: &mut LweCiphertextVectorMutView32<'_>, input: &PlaintextVector32, noise: Variance, )

Unsafely encryprs an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, output: &mut LweCiphertextVector64, input: &PlaintextVector64, noise: Variance, )

Unsafely encryprs an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVectorMutView64<'_>> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, output: &mut LweCiphertextVectorMutView64<'_>, input: &PlaintextVector64, noise: Variance, )

Unsafely encryprs an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_sub_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input_1: &LweCiphertextVector32, input_2: &LweCiphertextVector32, )

Unsafely subtracts two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorDiscardingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorDiscardingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_sub_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector64, input_1: &LweCiphertextVector64, input_2: &LweCiphertextVector64, )

Unsafely subtracts two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> LweCiphertextVector32

Unsafely encrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, input: &PlaintextVector64, noise: Variance, ) -> LweCiphertextVector64

Unsafely encrypts an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorFusingAdditionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_add_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertextVector32, )

Unsafely add two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorFusingAdditionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorFusingAdditionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_add_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector64, input: &LweCiphertextVector64, )

Unsafely add two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorFusingSubtractionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector32, input: &LweCiphertextVector32, )

Unsafely subtracts two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorFusingSubtractionEngine<LweCiphertextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorFusingSubtractionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn fuse_sub_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVector64, input: &LweCiphertextVector64, )

Unsafely subtracts two LWE ciphertext vectors. Read more
Source§

impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext32, input: &LweCiphertextVector32, ksk: &LwePackingKeyswitchKey32, )

Unsafely packing keyswitches an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine<LwePackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorGlweCiphertextDiscardingPackingKeyswitchEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext64, input: &LweCiphertextVector64, ksk: &LwePackingKeyswitchKey64, )

Unsafely packing keyswitches an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey32, LweCiphertextVector32, GlweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext32, input: &LweCiphertextVector32, pfpksk: &LwePrivateFunctionalPackingKeyswitchKey32, )

Unsafely keyswitches an LWE ciphertext vector using a private functional packing keyswitch key. Read more
Source§

impl LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine<LwePrivateFunctionalPackingKeyswitchKey64, LweCiphertextVector64, GlweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorGlweCiphertextDiscardingPrivateFunctionalPackingKeyswitchEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_private_functional_packing_keyswitch_lwe_ciphertext_vector_unchecked( &mut self, output: &mut GlweCiphertext64, input: &LweCiphertextVector64, pfpksk: &LwePrivateFunctionalPackingKeyswitchKey64, )

Unsafely keyswitches an LWE ciphertext vector using a private functional packing keyswitch key. Read more
Source§

impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector32, PlaintextVector32> for DefaultEngine

Source§

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));
Source§

unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked( &mut self, input: &LweCiphertextVector32, ) -> PlaintextVector32

Unsafely trivially decrypts an LWE ciphertext vector into a plaintext vector. Read more
Source§

impl LweCiphertextVectorTrivialDecryptionEngine<LweCiphertextVector64, PlaintextVector64> for DefaultEngine

Source§

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));
Source§

unsafe fn trivially_decrypt_lwe_ciphertext_vector_unchecked( &mut self, input: &LweCiphertextVector64, ) -> PlaintextVector64

Unsafely trivially decrypts an LWE ciphertext vector into a plaintext vector. Read more
Source§

impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector32, LweCiphertextVector32> for DefaultEngine

Source§

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
);
Source§

unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked( &mut self, lwe_size: LweSize, input: &PlaintextVector32, ) -> LweCiphertextVector32

Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
Source§

impl LweCiphertextVectorTrivialEncryptionEngine<PlaintextVector64, LweCiphertextVector64> for DefaultEngine

Source§

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
);
Source§

unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked( &mut self, lwe_size: LweSize, input: &PlaintextVector64, ) -> LweCiphertextVector64

Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
Source§

impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorZeroEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, noise: Variance, count: LweCiphertextCount, ) -> LweCiphertextVector32

Unsafely encrypts zeros in an LWE ciphertext vector. Read more
Source§

impl LweCiphertextVectorZeroEncryptionEngine<LweSecretKey64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweCiphertextVectorZeroEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, noise: Variance, count: LweCiphertextCount, ) -> LweCiphertextVector64

Unsafely encrypts zeros in an LWE ciphertext vector. Read more
Source§

impl LweCiphertextZeroEncryptionEngine<LweSecretKey32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweCiphertextZeroEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey32, noise: Variance, ) -> LweCiphertext32

Safely encrypts zero into an LWE ciphertext. Read more
Source§

impl LweCiphertextZeroEncryptionEngine<LweSecretKey64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweCiphertextZeroEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn zero_encrypt_lwe_ciphertext_unchecked( &mut self, key: &LweSecretKey64, noise: Variance, ) -> LweCiphertext64

Safely encrypts zero into an LWE ciphertext. Read more
Source§

impl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey32, GlweSecretKey32, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys32> for DefaultEngine

§Description:

Implementation of LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

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

Unsafely generate a new LWE CBSFPKSK. Read more
Source§

impl LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine<LweSecretKey64, GlweSecretKey64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for DefaultEngine

§Description:

Implementation of LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeysGenerationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

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

Unsafely generate a new LWE CBSFPKSK. Read more
Source§

impl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey32, Vec<u32>> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKey32, ) -> Vec<u32>

Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Source§

impl LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKey64, Vec<u64>> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKey64, ) -> Vec<u64>

Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Source§

impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView32<'data>, &'data mut [u32]> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKeyMutView32<'data>, ) -> &'data mut [u32]

Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Source§

impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine

Source§

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());
Source§

unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKeyMutView64<'data>, ) -> &'data mut [u64]

Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Source§

impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView32<'data>, &'data [u32]> for DefaultEngine

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKeyView32<'data>, ) -> &'data [u32]

Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Source§

impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView64<'data>, &'data [u64]> for DefaultEngine

Source§

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);
Source§

unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked( &mut self, keyswitch_key: LweKeyswitchKeyView64<'data>, ) -> &'data [u64]

Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in the process. Read more
Source§

impl<'data> LweKeyswitchKeyCreationEngine<&'data [u32], LweKeyswitchKeyView32<'data>> for DefaultEngine

Source§

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);
Source§

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>

Unsafely creates an LWE keyswitch key from an existing container. Read more
Source§

impl<'data> LweKeyswitchKeyCreationEngine<&'data [u64], LweKeyswitchKeyView64<'data>> for DefaultEngine

Source§

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);
Source§

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>

Unsafely creates an LWE keyswitch key from an existing container. Read more
Source§

impl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u32], LweKeyswitchKeyMutView32<'data>> for DefaultEngine

Source§

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);
Source§

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>

Unsafely creates an LWE keyswitch key from an existing container. Read more
Source§

impl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u64], LweKeyswitchKeyMutView64<'data>> for DefaultEngine

Source§

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);
Source§

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>

Unsafely creates an LWE keyswitch key from an existing container. Read more
Source§

impl LweKeyswitchKeyCreationEngine<Vec<u32>, LweKeyswitchKey32> for DefaultEngine

Source§

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);
Source§

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

Unsafely creates an LWE keyswitch key from an existing container. Read more
Source§

impl LweKeyswitchKeyCreationEngine<Vec<u64>, LweKeyswitchKey64> for DefaultEngine

Source§

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);
Source§

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

Unsafely creates an LWE keyswitch key from an existing container. Read more
Source§

impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey32, LweKeyswitchKeyMutView32<'_>> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_convert_lwe_keyswitch_key_unchecked( &mut self, output: &mut LweKeyswitchKeyMutView32<'_>, input: &LweKeyswitchKey32, )

Unsafely converts a LWE keyswitch key . Read more
Source§

impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey64, LweKeyswitchKeyMutView64<'_>> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_convert_lwe_keyswitch_key_unchecked( &mut self, output: &mut LweKeyswitchKeyMutView64<'_>, input: &LweKeyswitchKey64, )

Unsafely converts a LWE keyswitch key . Read more
Source§

impl LweKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweKeyswitchKey32> for DefaultEngine

§Description:

Implementation of LweKeyswitchKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

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

Unsafely generates a new LWE keyswitch key. Read more
Source§

impl LweKeyswitchKeyGenerationEngine<LweSecretKey64, LweSecretKey64, LweKeyswitchKey64> for DefaultEngine

§Description:

Implementation of LweKeyswitchKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

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

Unsafely generates a new LWE keyswitch key. Read more
Source§

impl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey32, GlweSecretKey32, LwePackingKeyswitchKey32> for DefaultEngine

§Description:

Implementation of LwePackingKeyswitchKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

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

Unsafely generates a new packing keyswitch key. Read more
Source§

impl LwePackingKeyswitchKeyGenerationEngine<LweSecretKey64, GlweSecretKey64, LwePackingKeyswitchKey64> for DefaultEngine

§Description:

Implementation of LwePackingKeyswitchKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

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

Unsafely generates a new packing keyswitch key. Read more
Source§

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.

Source§

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);
Source§

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

Unsafely generates a new private functional packing keyswitch key. Read more
Source§

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.

Source§

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);
Source§

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

Unsafely generates a new private functional packing keyswitch key. Read more
Source§

impl LwePublicKeyGenerationEngine<LweSecretKey32, LwePublicKey32> for DefaultEngine

§Description:

Implementation of LwePublicKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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
);
Source§

unsafe fn generate_new_lwe_public_key_unchecked( &mut self, lwe_secret_key: &LweSecretKey32, noise: Variance, lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount, ) -> LwePublicKey32

Unsafely generates a new LWE public key. Read more
Source§

impl LwePublicKeyGenerationEngine<LweSecretKey64, LwePublicKey64> for DefaultEngine

§Description:

Implementation of LwePublicKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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
);
Source§

unsafe fn generate_new_lwe_public_key_unchecked( &mut self, lwe_secret_key: &LweSecretKey64, noise: Variance, lwe_public_key_zero_encryption_count: LwePublicKeyZeroEncryptionCount, ) -> LwePublicKey64

Unsafely generates a new LWE public key. Read more
Source§

impl LweSecretKeyGenerationEngine<LweSecretKey32> for DefaultEngine

§Description:

Implementation of LweSecretKeyGenerationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn generate_new_lwe_secret_key_unchecked( &mut self, lwe_dimension: LweDimension, ) -> LweSecretKey32

Unsafely generates a new LWE secret key. Read more
Source§

impl LweSecretKeyGenerationEngine<LweSecretKey64> for DefaultEngine

§Description:

Implementation of LweSecretKeyGenerationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn generate_new_lwe_secret_key_unchecked( &mut self, lwe_dimension: LweDimension, ) -> LweSecretKey64

Unsafely generates a new LWE secret key. Read more
Source§

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.

Source§

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);
Source§

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

Unsafely generates a new seeded LWE bootstrap key. Read more
Source§

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.

Source§

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);
Source§

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

Unsafely generates a new seeded LWE bootstrap key. Read more
Source§

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.

Source§

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);
Source§

unsafe fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key_unchecked( &mut self, lwe_seeded_bootstrap_key: LweSeededBootstrapKey32, ) -> LweBootstrapKey32

Unsafely transforms an LWE seeded bootstrap key into an LWE bootstrap key Read more
Source§

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.

Source§

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);
Source§

unsafe fn transform_lwe_seeded_bootstrap_key_to_lwe_bootstrap_key_unchecked( &mut self, lwe_seeded_bootstrap_key: LweSeededBootstrapKey64, ) -> LweBootstrapKey64

Unsafely transforms an LWE seeded bootstrap key into an LWE bootstrap key Read more
Source§

impl LweSeededCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweSeededCiphertext32> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn encrypt_lwe_seeded_ciphertext_unchecked( &mut self, key: &LweSecretKey32, input: &Plaintext32, noise: Variance, ) -> LweSeededCiphertext32

Unsafely encrypts a seeded LWE ciphertext. Read more
Source§

impl LweSeededCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweSeededCiphertext64> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn encrypt_lwe_seeded_ciphertext_unchecked( &mut self, key: &LweSecretKey64, input: &Plaintext64, noise: Variance, ) -> LweSeededCiphertext64

Unsafely encrypts a seeded LWE ciphertext. Read more
Source§

impl LweSeededCiphertextToLweCiphertextTransformationEngine<LweSeededCiphertext32, LweCiphertext32> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextToLweCiphertextTransformationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext_unchecked( &mut self, lwe_seeded_ciphertext: LweSeededCiphertext32, ) -> LweCiphertext32

Unsafely transforms an LWE seeded ciphertext into an LWE ciphertext Read more
Source§

impl LweSeededCiphertextToLweCiphertextTransformationEngine<LweSeededCiphertext64, LweCiphertext64> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextToLweCiphertextTransformationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn transform_lwe_seeded_ciphertext_to_lwe_ciphertext_unchecked( &mut self, lwe_seeded_ciphertext: LweSeededCiphertext64, ) -> LweCiphertext64

Unsafely transforms an LWE seeded ciphertext into an LWE ciphertext Read more
Source§

impl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey32, PlaintextVector32, LweSeededCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 32 bits integers.

Source§

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!(
Source§

unsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey32, input: &PlaintextVector32, noise: Variance, ) -> LweSeededCiphertextVector32

Unsafely encrypts a seeded LWE ciphertext vector. Read more
Source§

impl LweSeededCiphertextVectorEncryptionEngine<LweSecretKey64, PlaintextVector64, LweSeededCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextVectorEncryptionEngine for DefaultEngine that operates on 64 bits integers.

Source§

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!(
Source§

unsafe fn encrypt_lwe_seeded_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, input: &PlaintextVector64, noise: Variance, ) -> LweSeededCiphertextVector64

Unsafely encrypts a seeded LWE ciphertext vector. Read more
Source§

impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector32, LweCiphertextVector32> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked( &mut self, lwe_seeded_ciphertext_vector: LweSeededCiphertextVector32, ) -> LweCiphertextVector32

Unsafely transforms an LWE seeded ciphertext vector into an LWE ciphertext vector Read more
Source§

impl LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine<LweSeededCiphertextVector64, LweCiphertextVector64> for DefaultEngine

§Description:

Implementation of LweSeededCiphertextVectorToLweCiphertextVectorTransformationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn transform_lwe_seeded_ciphertext_vector_to_lwe_ciphertext_vector_unchecked( &mut self, lwe_seeded_ciphertext_vector: LweSeededCiphertextVector64, ) -> LweCiphertextVector64

Unsafely transforms an LWE seeded ciphertext vector into an LWE ciphertext vector Read more
Source§

impl LweSeededKeyswitchKeyGenerationEngine<LweSecretKey32, LweSecretKey32, LweSeededKeyswitchKey32> for DefaultEngine

Source§

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);
Source§

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

Unsafely generates a new seeded LWE keyswitch key. Read more
Source§

impl LweSeededKeyswitchKeyGenerationEngine<LweSecretKey64, LweSecretKey64, LweSeededKeyswitchKey64> for DefaultEngine

Source§

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);
Source§

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

Unsafely generates a new seeded LWE keyswitch key. Read more
Source§

impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey32, LweKeyswitchKey32> for DefaultEngine

Source§

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);
Source§

unsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked( &mut self, lwe_seeded_keyswitch_key: LweSeededKeyswitchKey32, ) -> LweKeyswitchKey32

Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
Source§

impl LweSeededKeyswitchKeyToLweKeyswitchKeyTransformationEngine<LweSeededKeyswitchKey64, LweKeyswitchKey64> for DefaultEngine

Source§

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);
Source§

unsafe fn transform_lwe_seeded_keyswitch_key_to_lwe_keyswitch_key_unchecked( &mut self, lwe_seeded_keyswitch_key: LweSeededKeyswitchKey64, ) -> LweKeyswitchKey64

Unsafely transforms a seeded LWE keyswitch key into an LWE keyswitch key Read more
Source§

impl LweToGlweSecretKeyTransformationEngine<LweSecretKey32, GlweSecretKey32> for DefaultEngine

Source§

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);
Source§

unsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked( &mut self, lwe_secret_key: LweSecretKey32, polynomial_size: PolynomialSize, ) -> GlweSecretKey32

Unsafely transforms an LWE secret key into a GLWE secret key Read more
Source§

impl LweToGlweSecretKeyTransformationEngine<LweSecretKey64, GlweSecretKey64> for DefaultEngine

Source§

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);
Source§

unsafe fn transform_lwe_secret_key_to_glwe_secret_key_unchecked( &mut self, lwe_secret_key: LweSecretKey64, polynomial_size: PolynomialSize, ) -> GlweSecretKey64

Unsafely transforms an LWE secret key into a GLWE secret key Read more
Source§

impl PlaintextCreationEngine<u32, Plaintext32> for DefaultEngine

§Description:

Implementation of PlaintextCreationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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)?;
Source§

unsafe fn create_plaintext_from_unchecked(&mut self, input: &u32) -> Plaintext32

Unsafely creates a plaintext from an arbitrary value. Read more
Source§

impl PlaintextCreationEngine<u64, Plaintext64> for DefaultEngine

§Description:

Implementation of PlaintextCreationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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)?;
Source§

unsafe fn create_plaintext_from_unchecked(&mut self, input: &u64) -> Plaintext64

Unsafely creates a plaintext from an arbitrary value. Read more
Source§

impl PlaintextDecodingEngine<FloatEncoder, Plaintext32, CleartextF64> for DefaultEngine

§Description:

Implementation of PlaintextDecodingEngine for DefaultEngine that decodes 32 bits integers to 64 bits floating point numbers.

Source§

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)?;
Source§

unsafe fn decode_plaintext_unchecked( &mut self, input: &Plaintext32, encoder: &FloatEncoder, ) -> CleartextF64

Unsafely decodes a plaintext. Read more
Source§

impl PlaintextDecodingEngine<FloatEncoder, Plaintext64, CleartextF64> for DefaultEngine

§Description:

Implementation of PlaintextDecodingEngine for DefaultEngine that decodes 64 bits integers to 64 bits floating point numbers.

Source§

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)?;
Source§

unsafe fn decode_plaintext_unchecked( &mut self, input: &Plaintext64, encoder: &FloatEncoder, ) -> CleartextF64

Unsafely decodes a plaintext. Read more
Source§

impl PlaintextDiscardingRetrievalEngine<Plaintext32, u32> for DefaultEngine

§Description:

Implementation of PlaintextDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_plaintext_unchecked( &mut self, output: &mut u32, input: &Plaintext32, )

Unsafely retrieves an arbitrary value from a plaintext inplace. Read more
Source§

impl PlaintextDiscardingRetrievalEngine<Plaintext64, u64> for DefaultEngine

Source§

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);
Source§

unsafe fn discard_retrieve_plaintext_unchecked( &mut self, output: &mut u64, input: &Plaintext64, )

Unsafely retrieves an arbitrary value from a plaintext inplace. Read more
Source§

impl PlaintextRetrievalEngine<Plaintext32, u32> for DefaultEngine

§Description:

Implementation of PlaintextRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn retrieve_plaintext_unchecked( &mut self, plaintext: &Plaintext32, ) -> u32

Unsafely retrieves an arbitrary value from a plaintext. Read more
Source§

impl PlaintextRetrievalEngine<Plaintext64, u64> for DefaultEngine

§Description:

Implementation of PlaintextRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn retrieve_plaintext_unchecked( &mut self, plaintext: &Plaintext64, ) -> u64

Unsafely retrieves an arbitrary value from a plaintext. Read more
Source§

impl PlaintextVectorCreationEngine<u32, PlaintextVector32> for DefaultEngine

§Description:

Implementation of PlaintextVectorCreationEngine for DefaultEngine that operates on 32 bits integers.

Source§

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));
Source§

unsafe fn create_plaintext_vector_from_unchecked( &mut self, input: &[u32], ) -> PlaintextVector32

Unsafely creates a plaintext vector from a slice of arbitrary values. Read more
Source§

impl PlaintextVectorCreationEngine<u64, PlaintextVector64> for DefaultEngine

§Description:

Implementation of PlaintextVectorCreationEngine for DefaultEngine that operates on 64 bits integers.

Source§

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));
Source§

unsafe fn create_plaintext_vector_from_unchecked( &mut self, input: &[u64], ) -> PlaintextVector64

Unsafely creates a plaintext vector from a slice of arbitrary values. Read more
Source§

impl PlaintextVectorDecodingEngine<FloatEncoderVector, PlaintextVector32, CleartextVectorF64> for DefaultEngine

§Description:

Implementation of PlaintextVectorDecodingEngine for DefaultEngine that decodes 32 bits integers to 64 bits floating point numbers.

Source§

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
);
Source§

unsafe fn decode_plaintext_vector_unchecked( &mut self, encoder: &FloatEncoderVector, input: &PlaintextVector32, ) -> CleartextVectorF64

Unsafely decodes a plaintext vector. Read more
Source§

impl PlaintextVectorDecodingEngine<FloatEncoderVector, PlaintextVector64, CleartextVectorF64> for DefaultEngine

§Description:

Implementation of PlaintextVectorDecodingEngine for DefaultEngine that decodes 64 bits integers to 64 bits floating point numbers.

Source§

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
);
Source§

unsafe fn decode_plaintext_vector_unchecked( &mut self, encoder: &FloatEncoderVector, input: &PlaintextVector64, ) -> CleartextVectorF64

Unsafely decodes a plaintext vector. Read more
Source§

impl PlaintextVectorDiscardingRetrievalEngine<PlaintextVector32, u32> for DefaultEngine

§Description:

Implementation of PlaintextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_plaintext_vector_unchecked( &mut self, output: &mut [u32], input: &PlaintextVector32, )

Unsafely retrieves arbitrary values from a plaintext vector. Read more
Source§

impl PlaintextVectorDiscardingRetrievalEngine<PlaintextVector64, u64> for DefaultEngine

§Description:

Implementation of PlaintextVectorDiscardingRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn discard_retrieve_plaintext_vector_unchecked( &mut self, output: &mut [u64], input: &PlaintextVector64, )

Unsafely retrieves arbitrary values from a plaintext vector. Read more
Source§

impl PlaintextVectorRetrievalEngine<PlaintextVector32, u32> for DefaultEngine

§Description:

Implementation of PlaintextVectorRetrievalEngine for DefaultEngine that operates on 32 bits integers.

Source§

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);
Source§

unsafe fn retrieve_plaintext_vector_unchecked( &mut self, plaintext: &PlaintextVector32, ) -> Vec<u32>

Unsafely retrieves arbitrary values from a plaintext vector. Read more
Source§

impl PlaintextVectorRetrievalEngine<PlaintextVector64, u64> for DefaultEngine

§Description:

Implementation of PlaintextVectorRetrievalEngine for DefaultEngine that operates on 64 bits integers.

Source§

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);
Source§

unsafe fn retrieve_plaintext_vector_unchecked( &mut self, plaintext: &PlaintextVector64, ) -> Vec<u64>

Unsafely retrieves arbitrary values from a plaintext vector. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.