LweKeyswitchKeyView64

Struct LweKeyswitchKeyView64 

Source
pub struct LweKeyswitchKeyView64<'a>(/* private fields */);
Expand description

A structure representing an LWE keyswitch key with 64 bits of precision.

By view here, we mean that the entity does not own the data, but immutably borrows it.

§Notes:

This view is not Clone as Clone for a slice is not defined. It is not Deserialize either, as Deserialize of a slice is not defined. Immutable variant.

Trait Implementations§

Source§

impl AbstractEntity for LweKeyswitchKeyView64<'_>

Source§

type Kind = LweKeyswitchKeyKind

The kind of the entity.
Source§

impl<'a> Debug for LweKeyswitchKeyView64<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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 [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 LweKeyswitchKeyEntity for LweKeyswitchKeyView64<'_>

Source§

fn input_lwe_dimension(&self) -> LweDimension

Returns the input LWE dimension of the key.
Source§

fn output_lwe_dimension(&self) -> LweDimension

Returns the output lew dimension of the key.
Source§

fn decomposition_level_count(&self) -> DecompositionLevelCount

Returns the number of decomposition levels of the key.
Source§

fn decomposition_base_log(&self) -> DecompositionBaseLog

Returns the logarithm of the base used in the key.
Source§

impl<'a> PartialEq for LweKeyswitchKeyView64<'a>

Source§

fn eq(&self, other: &LweKeyswitchKeyView64<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for LweKeyswitchKeyView64<'a>

Source§

impl<'a> StructuralPartialEq for LweKeyswitchKeyView64<'a>

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.