pub struct LweKeyswitchKeyView32<'a>(/* private fields */);Expand description
A structure representing an LWE keyswitch key with 32 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 LweKeyswitchKeyView32<'_>
impl AbstractEntity for LweKeyswitchKeyView32<'_>
Source§type Kind = LweKeyswitchKeyKind
type Kind = LweKeyswitchKeyKind
The kind of the entity.
Source§impl<'a> Debug for LweKeyswitchKeyView32<'a>
impl<'a> Debug for LweKeyswitchKeyView32<'a>
Source§impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyView32<'data>, &'data [u32]> for DefaultEngine
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>>
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]
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> LweKeyswitchKeyCreationEngine<&'data [u32], LweKeyswitchKeyView32<'data>> for DefaultEngine
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>>
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>
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 LweKeyswitchKeyEntity for LweKeyswitchKeyView32<'_>
impl LweKeyswitchKeyEntity for LweKeyswitchKeyView32<'_>
Source§fn input_lwe_dimension(&self) -> LweDimension
fn input_lwe_dimension(&self) -> LweDimension
Returns the input LWE dimension of the key.
Source§fn output_lwe_dimension(&self) -> LweDimension
fn output_lwe_dimension(&self) -> LweDimension
Returns the output lew dimension of the key.
Source§fn decomposition_level_count(&self) -> DecompositionLevelCount
fn decomposition_level_count(&self) -> DecompositionLevelCount
Returns the number of decomposition levels of the key.
Source§fn decomposition_base_log(&self) -> DecompositionBaseLog
fn decomposition_base_log(&self) -> DecompositionBaseLog
Returns the logarithm of the base used in the key.
Source§impl<'a> PartialEq for LweKeyswitchKeyView32<'a>
impl<'a> PartialEq for LweKeyswitchKeyView32<'a>
impl<'a> Eq for LweKeyswitchKeyView32<'a>
impl<'a> StructuralPartialEq for LweKeyswitchKeyView32<'a>
Auto Trait Implementations§
impl<'a> Freeze for LweKeyswitchKeyView32<'a>
impl<'a> RefUnwindSafe for LweKeyswitchKeyView32<'a>
impl<'a> Send for LweKeyswitchKeyView32<'a>
impl<'a> Sync for LweKeyswitchKeyView32<'a>
impl<'a> Unpin for LweKeyswitchKeyView32<'a>
impl<'a> UnwindSafe for LweKeyswitchKeyView32<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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