Struct concrete_core::backends::default::entities::LweBootstrapKeyMutView64
source · [−]pub struct LweBootstrapKeyMutView64<'a>(_);Expand description
A structure representing an LWE bootstrap 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 LweBootstrapKeyMutView64<'_>
impl AbstractEntity for LweBootstrapKeyMutView64<'_>
type Kind = LweBootstrapKeyKind
type Kind = LweBootstrapKeyKind
The kind of the entity.
sourceimpl<'a> Debug for LweBootstrapKeyMutView64<'a>
impl<'a> Debug for LweBootstrapKeyMutView64<'a>
sourceimpl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweBootstrapKeyConsumingRetrievalEngine<LweBootstrapKeyMutView64<'data>, &'data mut [u64]> for DefaultEngine
sourcefn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> Result<&'data mut [u64], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_bootstrap_key(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> Result<&'data mut [u64], LweBootstrapKeyConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let mut slice = owned_container.as_mut_slice();
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
let lwe_bootstrap_key: LweBootstrapKeyMutView64 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
let retrieved_slice = engine.consume_retrieve_lwe_bootstrap_key(lwe_bootstrap_key)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());sourceunsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_bootstrap_key_unchecked(
&mut self,
bootstrap_key: LweBootstrapKeyMutView64<'data>
) -> &'data mut [u64]
Unsafely retrieves the content of the container from an LWE bootstrap key, consuming it in
the process. Read more
sourceimpl<'data> LweBootstrapKeyCreationEngine<&'data mut [u64], LweBootstrapKeyMutView64<'data>> for DefaultEngine
impl<'data> LweBootstrapKeyCreationEngine<&'data mut [u64], LweBootstrapKeyMutView64<'data>> for DefaultEngine
sourcefn create_lwe_bootstrap_key_from(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyMutView64<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
fn create_lwe_bootstrap_key_from(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> Result<LweBootstrapKeyMutView64<'data>, LweBootstrapKeyCreationError<Self::EngineError>>
Example:
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
*,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let glwe_size = GlweSize(2);
let polynomial_size = PolynomialSize(256);
let level = DecompositionLevelCount(2);
let base_log = DecompositionBaseLog(1);
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut owned_container =
vec![0_u64; lwe_dimension.0 * level.0 * glwe_size.0 * glwe_size.0 * polynomial_size.0];
let mut slice = owned_container.as_mut_slice();
let lwe_bootstrap_key: LweBootstrapKeyMutView64 =
engine.create_lwe_bootstrap_key_from(slice, glwe_size, polynomial_size, base_log, level)?;
sourceunsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyMutView64<'data>
unsafe fn create_lwe_bootstrap_key_from_unchecked(
&mut self,
container: &'data mut [u64],
glwe_size: GlweSize,
poly_size: PolynomialSize,
decomposition_base_log: DecompositionBaseLog,
decomposition_level_count: DecompositionLevelCount
) -> LweBootstrapKeyMutView64<'data>
Unsafely creates an LWE bootstrap key from an existing container. Read more
sourceimpl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey64, LweBootstrapKeyMutView64<'_>> for DefaultEngine
impl LweBootstrapKeyDiscardingConversionEngine<LweBootstrapKey64, LweBootstrapKeyMutView64<'_>> for DefaultEngine
sourcefn discard_convert_lwe_bootstrap_key(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
) -> Result<(), LweBootstrapKeyDiscardingConversionError<Self::EngineError>>
fn discard_convert_lwe_bootstrap_key(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
) -> Result<(), LweBootstrapKeyDiscardingConversionError<Self::EngineError>>
Example
use concrete_core::prelude::{
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
Variance, *,
};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let (lwe_dim, glwe_dim, poly_size) = (LweDimension(4), GlweDimension(6), PolynomialSize(256));
let (dec_lc, dec_bl) = (DecompositionLevelCount(3), DecompositionBaseLog(5));
let noise = Variance(2_f64.powf(-25.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let lwe_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dim)?;
let glwe_sk: GlweSecretKey64 =
default_engine.generate_new_glwe_secret_key(glwe_dim, poly_size)?;
let bsk: LweBootstrapKey64 =
default_engine.generate_new_lwe_bootstrap_key(&lwe_sk, &glwe_sk, dec_bl, dec_lc, noise)?;
let mut owned_container = vec![
0_u64;
lwe_dim.0
* dec_lc.0
* glwe_dim.to_glwe_size().0
* glwe_dim.to_glwe_size().0
* poly_size.0
];
let mut out_bsk_mut_view: LweBootstrapKeyMutView64 = default_engine
.create_lwe_bootstrap_key_from(
owned_container.as_mut_slice(),
glwe_dim.to_glwe_size(),
poly_size,
dec_bl,
dec_lc,
)?;
default_engine.discard_convert_lwe_bootstrap_key(&mut out_bsk_mut_view, &bsk)?;
assert_eq!(out_bsk_mut_view.glwe_dimension(), glwe_dim);
assert_eq!(out_bsk_mut_view.polynomial_size(), poly_size);
assert_eq!(out_bsk_mut_view.input_lwe_dimension(), lwe_dim);
assert_eq!(out_bsk_mut_view.decomposition_base_log(), dec_bl);
assert_eq!(out_bsk_mut_view.decomposition_level_count(), dec_lc);
// Check content is the same
let original_bsk_container = default_engine.consume_retrieve_lwe_bootstrap_key(bsk)?;
let mut_view_bsk_container =
default_engine.consume_retrieve_lwe_bootstrap_key(out_bsk_mut_view)?;
assert_eq!(original_bsk_container, mut_view_bsk_container);
sourceunsafe fn discard_convert_lwe_bootstrap_key_unchecked(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
)
unsafe fn discard_convert_lwe_bootstrap_key_unchecked(
&mut self,
output: &mut LweBootstrapKeyMutView64<'_>,
input: &LweBootstrapKey64
)
Unsafely converts a LWE bootstrap key . Read more
sourceimpl LweBootstrapKeyEntity for LweBootstrapKeyMutView64<'_>
impl LweBootstrapKeyEntity for LweBootstrapKeyMutView64<'_>
sourcefn glwe_dimension(&self) -> GlweDimension
fn glwe_dimension(&self) -> GlweDimension
Returns the GLWE dimension of the key.
sourcefn polynomial_size(&self) -> PolynomialSize
fn polynomial_size(&self) -> PolynomialSize
Returns the polynomial size of the key.
sourcefn input_lwe_dimension(&self) -> LweDimension
fn input_lwe_dimension(&self) -> LweDimension
Returns the input LWE dimension of the key.
sourcefn decomposition_base_log(&self) -> DecompositionBaseLog
fn decomposition_base_log(&self) -> DecompositionBaseLog
Returns the number of decomposition levels of the key.
sourcefn decomposition_level_count(&self) -> DecompositionLevelCount
fn decomposition_level_count(&self) -> DecompositionLevelCount
Returns the logarithm of the base used in the key.
sourcefn output_lwe_dimension(&self) -> LweDimension
fn output_lwe_dimension(&self) -> LweDimension
Returns the output LWE dimension of the key.
sourceimpl<'a> PartialEq<LweBootstrapKeyMutView64<'a>> for LweBootstrapKeyMutView64<'a>
impl<'a> PartialEq<LweBootstrapKeyMutView64<'a>> for LweBootstrapKeyMutView64<'a>
sourcefn eq(&self, other: &LweBootstrapKeyMutView64<'a>) -> bool
fn eq(&self, other: &LweBootstrapKeyMutView64<'a>) -> bool
impl<'a> Eq for LweBootstrapKeyMutView64<'a>
impl<'a> StructuralEq for LweBootstrapKeyMutView64<'a>
impl<'a> StructuralPartialEq for LweBootstrapKeyMutView64<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for LweBootstrapKeyMutView64<'a>
impl<'a> Send for LweBootstrapKeyMutView64<'a>
impl<'a> Sync for LweBootstrapKeyMutView64<'a>
impl<'a> Unpin for LweBootstrapKeyMutView64<'a>
impl<'a> !UnwindSafe for LweBootstrapKeyMutView64<'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