Struct concrete_core::backends::default::entities::LweKeyswitchKeyMutView64
source · [−]pub struct LweKeyswitchKeyMutView64<'a>(_);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 mutably 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. Mutable variant.
Trait Implementations
sourceimpl AbstractEntity for LweKeyswitchKeyMutView64<'_>
impl AbstractEntity for LweKeyswitchKeyMutView64<'_>
type Kind = LweKeyswitchKeyKind
type Kind = LweKeyswitchKeyKind
The kind of the entity.
sourceimpl<'a> Debug for LweKeyswitchKeyMutView64<'a>
impl<'a> Debug for LweKeyswitchKeyMutView64<'a>
sourceimpl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweKeyswitchKeyConsumingRetrievalEngine<LweKeyswitchKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
sourcefn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> Result<&'data mut [u64], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_keyswitch_key(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> Result<&'data mut [u64], LweKeyswitchKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let slice = owned_container.as_mut_slice();
let underlying_ptr = slice.as_ptr();
let keyswitch_key: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
slice,
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
let retrieved_slice = engine.consume_retrieve_lwe_keyswitch_key(keyswitch_key)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_keyswitch_key_unchecked(
&mut self,
keyswitch_key: LweKeyswitchKeyMutView64<'data>
) -> &'data mut [u64]
Unsafely retrieves the content of the container from an LWE keyswitch key, consuming it in
the process. Read more
sourceimpl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u64], LweKeyswitchKeyMutView64<'data>> for DefaultEngine
impl<'data> LweKeyswitchKeyCreationEngine<&'data mut [u64], LweKeyswitchKeyMutView64<'data>> for DefaultEngine
sourcefn create_lwe_keyswitch_key_from(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyMutView64<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
fn create_lwe_keyswitch_key_from(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweKeyswitchKeyMutView64<'data>, LweKeyswitchKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container = vec![
0u64;
input_lwe_dimension.0
* output_lwe_dimension.to_lwe_size().0
* decomposition_level_count.0
];
let keyswitch_key: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
keyswitch_key.decomposition_level_count(),
decomposition_level_count
);
assert_eq!(
keyswitch_key.decomposition_base_log(),
decomposition_base_log
);
assert_eq!(keyswitch_key.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(keyswitch_key.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyMutView64<'data>
unsafe fn create_lwe_keyswitch_key_from_unchecked(
&mut self,
container: &'data mut [u64],
output_lwe_dimension: LweDimension,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweKeyswitchKeyMutView64<'data>
Unsafely creates an LWE keyswitch key from an existing container. Read more
sourceimpl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey64, LweKeyswitchKeyMutView64<'_>> for DefaultEngine
impl LweKeyswitchKeyDiscardingConversionEngine<LweKeyswitchKey64, LweKeyswitchKeyMutView64<'_>> for DefaultEngine
sourcefn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_keyswitch_key(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
) -> Result<(), LweKeyswitchKeyDiscardingConversionError<Self::EngineError>>
Example:
use concrete_core::prelude::Variance;
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let input_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.generate_new_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.generate_new_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let mut owned_container = vec![
0_u64;
decomposition_level_count.0 * output_lwe_dimension.to_lwe_size().0 * input_lwe_dimension.0
];
let mut out_ksk_mut_view: LweKeyswitchKeyMutView64 = engine.create_lwe_keyswitch_key_from(
owned_container.as_mut_slice(),
output_lwe_dimension,
decomposition_base_log,
decomposition_level_count,
)?;
assert_eq!(
assert_eq!(
assert_eq!(out_ksk_mut_view.input_lwe_dimension(), input_lwe_dimension);
assert_eq!(out_ksk_mut_view.output_lwe_dimension(), output_lwe_dimension);
sourceunsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
)
unsafe fn discard_convert_lwe_keyswitch_key_unchecked(
&mut self,
output: &mut LweKeyswitchKeyMutView64<'_>,
input: &LweKeyswitchKey64
)
Unsafely converts a LWE keyswitch key . Read more
sourceimpl LweKeyswitchKeyEntity for LweKeyswitchKeyMutView64<'_>
impl LweKeyswitchKeyEntity for LweKeyswitchKeyMutView64<'_>
sourcefn input_lwe_dimension(&self) -> LweDimension
fn input_lwe_dimension(&self) -> LweDimension
Returns the input LWE dimension of the key.
sourcefn output_lwe_dimension(&self) -> LweDimension
fn output_lwe_dimension(&self) -> LweDimension
Returns the output lew dimension of the key.
sourcefn decomposition_level_count(&self) -> DecompositionLevelCount
fn decomposition_level_count(&self) -> DecompositionLevelCount
Returns the number of decomposition levels of the key.
sourcefn decomposition_base_log(&self) -> DecompositionBaseLog
fn decomposition_base_log(&self) -> DecompositionBaseLog
Returns the logarithm of the base used in the key.
sourceimpl<'a> PartialEq<LweKeyswitchKeyMutView64<'a>> for LweKeyswitchKeyMutView64<'a>
impl<'a> PartialEq<LweKeyswitchKeyMutView64<'a>> for LweKeyswitchKeyMutView64<'a>
sourcefn eq(&self, other: &LweKeyswitchKeyMutView64<'a>) -> bool
fn eq(&self, other: &LweKeyswitchKeyMutView64<'a>) -> bool
impl<'a> Eq for LweKeyswitchKeyMutView64<'a>
impl<'a> StructuralEq for LweKeyswitchKeyMutView64<'a>
impl<'a> StructuralPartialEq for LweKeyswitchKeyMutView64<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for LweKeyswitchKeyMutView64<'a>
impl<'a> Send for LweKeyswitchKeyMutView64<'a>
impl<'a> Sync for LweKeyswitchKeyMutView64<'a>
impl<'a> Unpin for LweKeyswitchKeyMutView64<'a>
impl<'a> !UnwindSafe for LweKeyswitchKeyMutView64<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more