Struct concrete_core::crypto::lwe::LweMask [−][src]
pub struct LweMask<Cont> { /* fields omitted */ }
Expand description
The mask of an LWE encrypted ciphertext.
Implementations
Creates a mask from a scalar container.
Example
use concrete_core::crypto::lwe::*; use concrete_core::crypto::LweDimension; let masks = LweMask::from_container(vec![0 as u8; 10]); assert_eq!(masks.mask_size(), LweDimension(10));
pub fn mask_element_iter(
&self
) -> impl Iterator<Item = &<Self as AsRefTensor>::Element> where
Self: AsRefTensor,
pub fn mask_element_iter(
&self
) -> impl Iterator<Item = &<Self as AsRefTensor>::Element> where
Self: AsRefTensor,
Returns an iterator over the mask elements.
Example
use concrete_core::crypto::lwe::*; let mut ciphertext = LweCiphertext::from_container(vec![0 as u8; 10]); let masks = ciphertext.get_mask(); for mask in masks.mask_element_iter(){ assert_eq!(mask, &0); } assert_eq!(masks.mask_element_iter().count(), 9);
pub fn mask_element_iter_mut(
&mut self
) -> impl Iterator<Item = &mut <Self as AsMutTensor>::Element> where
Self: AsMutTensor,
pub fn mask_element_iter_mut(
&mut self
) -> impl Iterator<Item = &mut <Self as AsMutTensor>::Element> where
Self: AsMutTensor,
Returns an iterator over mutable mask elements.
Example
use concrete_core::crypto::lwe::*; let mut ciphertext = LweCiphertext::from_container(vec![0 as u8; 10]); let mut masks = ciphertext.get_mut_mask(); for mask in masks.mask_element_iter_mut(){ *mask = 9; } for mask in masks.mask_element_iter(){ assert_eq!(mask, &9); } assert_eq!(masks.mask_element_iter_mut().count(), 9);
Returns the number of masks.
Example
use concrete_core::crypto::lwe::*; use concrete_core::crypto::LweDimension; let mut ciphertext = LweCiphertext::from_container(vec![0 as u8; 10]); assert_eq!(ciphertext.get_mask().mask_size(), LweDimension(9));
pub fn compute_binary_multisum<Scalar, KeyCont>(
&self,
key: &LweSecretKey<KeyCont>
) -> Scalar where
Self: AsRefTensor<Element = Scalar>,
LweSecretKey<KeyCont>: AsRefTensor<Element = bool>,
Scalar: UnsignedTorus,
pub fn compute_binary_multisum<Scalar, KeyCont>(
&self,
key: &LweSecretKey<KeyCont>
) -> Scalar where
Self: AsRefTensor<Element = Scalar>,
LweSecretKey<KeyCont>: AsRefTensor<Element = bool>,
Scalar: UnsignedTorus,
Computes sum of the mask elements wighted by the key bits.
Example
use concrete_core::crypto::lwe::LweCiphertext; use concrete_core::crypto::secret::LweSecretKey; let ciphertext = LweCiphertext::from_container(vec![1u32,2,3,4,5]); let mask = ciphertext.get_mask(); let key = LweSecretKey::from_container(vec![true, true, false, true]); let multisum = mask.compute_binary_multisum(&key); assert_eq!(multisum, 7);
Trait Implementations
type Element = Element
type Element = Element
The element type.
Returns a mutable reference to the enclosed tensor.
type Element = Element
type Element = Element
The element type.
Returns a mutable reference to the enclosed tensor.
type Element = Element
type Element = Element
The element type.
type Container = AlignedVec<Element>
type Container = AlignedVec<Element>
The container used by the tensor.
Returns a mutable reference to the enclosed tensor.
type Element = Element
type Element = Element
The element type.
type Container = &'a mut [Element]
type Container = &'a mut [Element]
The container used by the tensor.
Returns a mutable reference to the enclosed tensor.
type Element = Element
type Element = Element
The element type of the collection container.
type Container = AlignedVec<Element>
type Container = AlignedVec<Element>
The type of the collection container.
Consumes self
and returns an owned tensor.
type Element = Element
type Element = Element
The element type of the collection container.
type Container = &'a [Element]
type Container = &'a [Element]
The type of the collection container.
Consumes self
and returns an owned tensor.
type Element = Element
type Element = Element
The element type of the collection container.
type Container = &'a mut [Element]
type Container = &'a mut [Element]
The type of the collection container.
Consumes self
and returns an owned tensor.
Auto Trait Implementations
impl<Cont> RefUnwindSafe for LweMask<Cont> where
Cont: RefUnwindSafe,
impl<Cont> UnwindSafe for LweMask<Cont> where
Cont: UnwindSafe,