Struct concrete_core::crypto::ggsw::GgswCiphertext[][src]

pub struct GgswCiphertext<Cont> { /* fields omitted */ }
Expand description

A GGSW ciphertext.

Implementations

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));

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));

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));

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));

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);

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

The element type.

The container used by the tensor.

Returns a mutable reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a mutable reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a mutable reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a mutable reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a reference to the enclosed tensor.

The element type of the collection container.

The type of the collection container.

Consumes self and returns an owned tensor.

The element type of the collection container.

The type of the collection container.

Consumes self and returns an owned tensor.

The element type of the collection container.

The type of the collection container.

Consumes self and returns an owned tensor.

The element type of the collection container.

The type of the collection container.

Consumes self and returns an owned tensor.

The element type of the collection container.

The type of the collection container.

Consumes self and returns an owned tensor.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.