Struct concrete_core::crypto::glwe::GlweList [−][src]
pub struct GlweList<Cont> { /* fields omitted */ }
Expand description
A list of ciphertexts encoded with the GLWE scheme.
Implementations
pub fn allocate(
value: Scalar,
poly_size: PolynomialSize,
glwe_dimension: GlweDimension,
ciphertext_number: CiphertextCount
) -> Self
pub fn allocate(
value: Scalar,
poly_size: PolynomialSize,
glwe_dimension: GlweDimension,
ciphertext_number: CiphertextCount
) -> Self
Allocates storage for an owned GlweList
.
Example
use concrete_core::crypto::glwe::GlweList; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; let list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); assert_eq!(list.ciphertext_count(), CiphertextCount(30)); assert_eq!(list.polynomial_size(), PolynomialSize(10)); assert_eq!(list.glwe_size(), GlweSize(21)); assert_eq!(list.glwe_dimension(), GlweDimension(20));
pub fn from_container(
cont: Cont,
rlwe_dimension: GlweDimension,
poly_size: PolynomialSize
) -> Self where
Cont: AsRefSlice,
pub fn from_container(
cont: Cont,
rlwe_dimension: GlweDimension,
poly_size: PolynomialSize
) -> Self where
Cont: AsRefSlice,
Creates a list from a container of values.
use concrete_core::crypto::glwe::GlweList; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; let list = GlweList::from_container( vec![0 as u8; 10 * 21 * 30], GlweDimension(20), PolynomialSize(10), ); assert_eq!(list.ciphertext_count(), CiphertextCount(30)); assert_eq!(list.polynomial_size(), PolynomialSize(10)); assert_eq!(list.glwe_size(), GlweSize(21)); assert_eq!(list.glwe_dimension(), GlweDimension(20));
Returns the number of ciphertexts in the list.
Example
use concrete_core::crypto::glwe::GlweList; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; let list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); assert_eq!(list.ciphertext_count(), CiphertextCount(30));
Returns the size of the glwe ciphertexts contained in the list.
Example
use concrete_core::crypto::glwe::GlweList; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweDimension, CiphertextCount, GlweSize}; let list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); assert_eq!(list.glwe_size(), GlweSize(21));
Returns the number of coefficients of the polynomials used for the list ciphertexts.
Example
use concrete_core::crypto::glwe::GlweList; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; let list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); assert_eq!(list.polynomial_size(), PolynomialSize(10));
Returns the number of masks of the ciphertexts in the list.
Example
use concrete_core::crypto::glwe::GlweList; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; let list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); assert_eq!(list.glwe_dimension(), GlweDimension(20));
pub fn ciphertext_iter(
&self
) -> impl Iterator<Item = GlweCiphertext<&[<Self as AsRefTensor>::Element]>> where
Self: AsRefTensor,
pub fn ciphertext_iter(
&self
) -> impl Iterator<Item = GlweCiphertext<&[<Self as AsRefTensor>::Element]>> where
Self: AsRefTensor,
Returns an iterator over ciphertexts borrowed from the list.
Example
use concrete_core::crypto::glwe::{GlweList, GlweBody}; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; use concrete_core::math::tensor::AsRefTensor; let list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); for ciphertext in list.ciphertext_iter(){ let (body, masks) = ciphertext.get_body_and_mask(); assert_eq!(body.as_polynomial().polynomial_size(), PolynomialSize(10)); } assert_eq!(list.ciphertext_iter().count(), 30);
pub fn ciphertext_iter_mut(
&mut self
) -> impl Iterator<Item = GlweCiphertext<&mut [<Self as AsMutTensor>::Element]>> where
Self: AsMutTensor,
pub fn ciphertext_iter_mut(
&mut self
) -> impl Iterator<Item = GlweCiphertext<&mut [<Self as AsMutTensor>::Element]>> where
Self: AsMutTensor,
Returns an iterator over ciphertexts borrowed from the list.
Example
use concrete_core::crypto::glwe::{GlweList, GlweBody}; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::crypto::{GlweSize, CiphertextCount, GlweDimension}; use concrete_core::math::tensor::{AsMutTensor, AsRefTensor}; let mut list = GlweList::allocate( 0 as u8, PolynomialSize(10), GlweDimension(20), CiphertextCount(30) ); for mut ciphertext in list.ciphertext_iter_mut(){ let mut body = ciphertext.get_mut_body(); body.as_mut_tensor().fill_with_element(9); } for ciphertext in list.ciphertext_iter(){ let body = ciphertext.get_body(); assert!(body.as_tensor().iter().all(|a| *a == 9)); } assert_eq!(list.ciphertext_iter_mut().count(), 30);
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.
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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 GlweList<Cont> where
Cont: RefUnwindSafe,
impl<Cont> UnwindSafe for GlweList<Cont> where
Cont: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self