Struct concrete_core::crypto::ggsw::GgswCiphertext [−][src]
pub struct GgswCiphertext<Cont> { /* fields omitted */ }
Expand description
A GGSW ciphertext.
Implementations
pub fn allocate(
value: Scalar,
poly_size: PolynomialSize,
rlwe_size: GlweSize,
decomp_level: DecompositionLevelCount,
decomp_base_log: DecompositionBaseLog
) -> Self where
Scalar: Copy,
pub fn allocate(
value: Scalar,
poly_size: PolynomialSize,
rlwe_size: GlweSize,
decomp_level: DecompositionLevelCount,
decomp_base_log: DecompositionBaseLog
) -> Self where
Scalar: Copy,
Allocates a new GGSW ciphertext whose coefficients are all value
.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; use concrete_core::math::polynomial::PolynomialSize; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); assert_eq!(ggsw.glwe_size(), GlweSize(7)); assert_eq!(ggsw.decomposition_level_count(), DecompositionLevelCount(3)); assert_eq!(ggsw.decomposition_base_log(), DecompositionBaseLog(4));
pub fn from_container(
cont: Cont,
rlwe_size: GlweSize,
poly_size: PolynomialSize,
decomp_base_log: DecompositionBaseLog
) -> Self where
Cont: AsRefSlice,
pub fn from_container(
cont: Cont,
rlwe_size: GlweSize,
poly_size: PolynomialSize,
decomp_base_log: DecompositionBaseLog
) -> Self where
Cont: AsRefSlice,
Creates an Rgsw ciphertext from an existing container.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::math::decomposition::{DecompositionBaseLog, DecompositionLevelCount}; let ggsw = GgswCiphertext::from_container( vec![9 as u8; 7 * 7 * 10 * 3], GlweSize(7), PolynomialSize(10), DecompositionBaseLog(4), ); assert_eq!(ggsw.glwe_size(), GlweSize(7)); assert_eq!(ggsw.decomposition_level_count(), DecompositionLevelCount(3)); assert_eq!(ggsw.decomposition_base_log(), DecompositionBaseLog(4));
Returns the size of the glwe ciphertexts composing the ggsw ciphertext.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); assert_eq!(ggsw.glwe_size(), GlweSize(7));
Returns the number of decomposition levels used in the ciphertext.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; use concrete_core::math::polynomial::PolynomialSize; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); assert_eq!(ggsw.decomposition_level_count(), DecompositionLevelCount(3));
Returns the size of the polynomials used in the ciphertext.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; use concrete_core::math::polynomial::PolynomialSize; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); assert_eq!(ggsw.polynomial_size(), PolynomialSize(10));
pub fn as_glwe_list<Scalar>(&self) -> GlweList<&[Scalar]> where
Self: AsRefTensor<Element = Scalar>,
pub fn as_glwe_list<Scalar>(&self) -> GlweList<&[Scalar]> where
Self: AsRefTensor<Element = Scalar>,
Returns a borrowed list composed of all the GLWE ciphertext composing current ciphertext.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::{GlweSize, GlweDimension, CiphertextCount}; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; use concrete_core::math::polynomial::PolynomialSize; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); let list = ggsw.as_glwe_list(); assert_eq!(list.glwe_dimension(), GlweDimension(6)); assert_eq!(list.ciphertext_count(), CiphertextCount(3*7));
pub fn as_mut_glwe_list<Scalar>(&mut self) -> GlweList<&mut [Scalar]> where
Self: AsMutTensor<Element = Scalar>,
pub fn as_mut_glwe_list<Scalar>(&mut self) -> GlweList<&mut [Scalar]> where
Self: AsMutTensor<Element = Scalar>,
Returns a mutably borrowed GlweList
composed of all the GLWE ciphertext composing
current ciphertext.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::{GlweSize, GlweDimension, CiphertextCount}; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::math::tensor::{AsMutTensor, AsRefTensor}; let mut ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); let mut list = ggsw.as_mut_glwe_list(); list.as_mut_tensor().fill_with_element(0); assert_eq!(list.glwe_dimension(), GlweDimension(6)); assert_eq!(list.ciphertext_count(), CiphertextCount(3*7)); ggsw.as_tensor().iter().for_each(|a| assert_eq!(*a, 0));
Returns the logarithm of the base used for the gadget decomposition.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(10), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); assert_eq!(ggsw.decomposition_base_log(), DecompositionBaseLog(4));
pub fn level_matrix_iter(
&self
) -> impl Iterator<Item = GgswLevelMatrix<&[<Self as AsRefTensor>::Element]>> where
Self: AsRefTensor,
pub fn level_matrix_iter(
&self
) -> impl Iterator<Item = GgswLevelMatrix<&[<Self as AsRefTensor>::Element]>> where
Self: AsRefTensor,
Returns an iterator over borrowed level matrices.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::polynomial::PolynomialSize; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; let ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(9), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); for level_matrix in ggsw.level_matrix_iter() { assert_eq!(level_matrix.row_iter().count(), 7); assert_eq!(level_matrix.polynomial_size(), PolynomialSize(9)); for rlwe in level_matrix.row_iter() { assert_eq!(rlwe.glwe_size(), GlweSize(7)); assert_eq!(rlwe.polynomial_size(), PolynomialSize(9)); } } assert_eq!(ggsw.level_matrix_iter().count(), 3);
pub fn level_matrix_iter_mut(
&mut self
) -> impl Iterator<Item = GgswLevelMatrix<&mut [<Self as AsRefTensor>::Element]>> where
Self: AsMutTensor,
pub fn level_matrix_iter_mut(
&mut self
) -> impl Iterator<Item = GgswLevelMatrix<&mut [<Self as AsRefTensor>::Element]>> where
Self: AsMutTensor,
Returns an iterator over mutably borrowed level matrices.
Example
use concrete_core::crypto::ggsw::GgswCiphertext; use concrete_core::crypto::GlweSize; use concrete_core::math::tensor::{AsMutTensor, AsRefTensor}; use concrete_core::math::decomposition::{DecompositionLevelCount, DecompositionBaseLog}; use concrete_core::math::polynomial::PolynomialSize; let mut ggsw = GgswCiphertext::allocate( 9 as u8, PolynomialSize(9), GlweSize(7), DecompositionLevelCount(3), DecompositionBaseLog(4) ); for mut level_matrix in ggsw.level_matrix_iter_mut() { for mut rlwe in level_matrix.row_iter_mut() { rlwe.as_mut_tensor().fill_with_element(9); } } assert!(ggsw.as_tensor().iter().all(|a| *a ==9)); assert_eq!(ggsw.level_matrix_iter_mut().count(), 3);
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 GgswCiphertext<Cont> where
Cont: RefUnwindSafe,
impl<Cont> Send for GgswCiphertext<Cont> where
Cont: Send,
impl<Cont> Sync for GgswCiphertext<Cont> where
Cont: Sync,
impl<Cont> Unpin for GgswCiphertext<Cont> where
Cont: Unpin,
impl<Cont> UnwindSafe for GgswCiphertext<Cont> where
Cont: UnwindSafe,