chore(tfhe): update wording to use imperative form in docstrings

This commit is contained in:
Arthur Meyre
2022-12-08 10:00:13 +01:00
committed by jborfila
parent ff062a33f9
commit 9d9c407f7f
60 changed files with 305 additions and 305 deletions

View File

@@ -46,7 +46,7 @@ impl Debug for ClientKey {
}
impl ClientKey {
/// Encrypts a Boolean message using the client key.
/// Encrypt a Boolean message using the client key.
///
/// # Example
///
@@ -69,7 +69,7 @@ impl ClientKey {
BooleanEngine::with_thread_local_mut(|engine| engine.encrypt(message, self))
}
/// Decrypts a ciphertext encrypting a Boolean message using the client key.
/// Decrypt a ciphertext encrypting a Boolean message using the client key.
///
/// # Example
///
@@ -92,7 +92,7 @@ impl ClientKey {
BooleanEngine::with_thread_local_mut(|engine| engine.decrypt(ct, self))
}
/// Allocates and generates a client key.
/// Allocate and generate a client key.
///
/// # Example
///

View File

@@ -19,7 +19,7 @@ struct Memory {
}
impl Memory {
/// Returns a tuple with buffers that matches the server key.
/// Return a tuple with buffers that matches the server key.
///
/// - The first element is the accumulator for bootstrap step.
/// - The second element is a lwe buffer where the result of the of the bootstrap should be
@@ -84,7 +84,7 @@ pub struct ServerKey {
pub(crate) key_switching_key: LweKeyswitchKeyOwned<u32>,
}
/// Performs ciphertext bootstraps on the CPU
/// Perform ciphertext bootstraps on the CPU
pub(crate) struct Bootstrapper {
memory: Memory,
/// A structure containing two CSPRNGs to generate material for encryption like public masks

View File

@@ -13,7 +13,7 @@ pub struct PublicKey {
}
impl PublicKey {
/// Encrypts a Boolean message using the client key.
/// Encrypt a Boolean message using the client key.
///
/// # Example
///
@@ -40,7 +40,7 @@ impl PublicKey {
BooleanEngine::with_thread_local_mut(|engine| engine.encrypt_with_public_key(message, self))
}
/// Allocates and generates a client key.
/// Allocate and generate a client key.
///
/// # Example
///

View File

@@ -21,7 +21,7 @@ pub fn convert_standard_lwe_bootstrap_key_to_fourier<Scalar, InputCont, OutputCo
.fill_with_forward_fourier(input_bsk.as_view(), fft, stack);
}
/// Returns the required memory for [`convert_standard_lwe_bootstrap_key_to_fourier`].
/// Return the required memory for [`convert_standard_lwe_bootstrap_key_to_fourier`].
pub fn convert_standard_lwe_bootstrap_key_to_fourier_scratch(
fft: FftView<'_>,
) -> Result<StackReq, SizeOverflow> {

View File

@@ -57,7 +57,7 @@ pub fn blind_rotate_assign_mem_optimized<Scalar, InputCont, OutputCont, KeyCont>
.blind_rotate_assign(lut.as_mut_view(), input.as_ref(), fft, stack);
}
/// Returns the required memory for [`blind_rotate_assign_mem_optimized`].
/// Return the required memory for [`blind_rotate_assign_mem_optimized`].
pub fn blind_rotate_assign_mem_optimized_scratch<Scalar>(
glwe_size: GlweSize,
polynomial_size: PolynomialSize,
@@ -136,7 +136,7 @@ pub fn programmable_bootstrap_lwe_ciphertext_mem_optimized<
);
}
/// Returns the required memory for [`programmable_bootstrap_lwe_ciphertext_mem_optimized`].
/// Return the required memory for [`programmable_bootstrap_lwe_ciphertext_mem_optimized`].
pub fn programmable_bootstrap_lwe_ciphertext_mem_optimized_scratch<Scalar>(
glwe_size: GlweSize,
polynomial_size: PolynomialSize,

View File

@@ -7,7 +7,7 @@ use crate::core_crypto::commons::parameters::MonomialDegree;
use crate::core_crypto::commons::traits::*;
use crate::core_crypto::entities::*;
/// Adds a polynomial to the output polynomial.
/// Add a polynomial to the output polynomial.
///
/// # Note
///
@@ -36,7 +36,7 @@ pub fn polynomial_wrapping_add_assign<Scalar, OutputCont, InputCont>(
slice_wrapping_add_assign(lhs.as_mut(), rhs.as_ref())
}
/// Adds the sum of the element-wise product between two lists of polynomials to the output
/// Add the sum of the element-wise product between two lists of polynomials to the output
/// polynomial.
///
/// I.e., if the output polynomial is $C(X)$, for a collection of polynomials $(P\_i(X)))\_i$
@@ -77,7 +77,7 @@ pub fn polynomial_wrapping_add_multisum_assign<Scalar, OutputCont, InputCont1, I
}
}
/// Adds the result of the product between two polynomials, reduced modulo $(X^{N}+1)$, to the
/// Add the result of the product between two polynomials, reduced modulo $(X^{N}+1)$, to the
/// output polynomial.
///
/// # Note
@@ -182,7 +182,7 @@ pub fn polynomial_wrapping_monic_monomial_div_assign<Scalar, OutputCont>(
.for_each(|a| *a = a.wrapping_neg());
}
/// Multiplies (mod $(X^{N}+1)$), the output polynomial with a monic monomial of a given degree i.e.
/// Multiply (mod $(X^{N}+1)$), the output polynomial with a monic monomial of a given degree i.e.
/// $X^{degree}$.
///
/// # Note
@@ -223,7 +223,7 @@ pub fn polynomial_wrapping_monic_monomial_mul_assign<Scalar, OutputCont>(
.for_each(|a| *a = a.wrapping_neg());
}
/// Subtracts the sum of the element-wise product between two lists of polynomials, to the output
/// Subtract the sum of the element-wise product between two lists of polynomials, to the output
/// polynomial.
///
/// I.e., if the output polynomial is $C(X)$, for two lists of polynomials $(P\_i(X)))\_i$ and
@@ -265,7 +265,7 @@ pub fn polynomial_wrapping_sub_multisum_assign<Scalar, OutputCont, InputCont1, I
}
}
/// Subtracts the result of the product between two polynomials, reduced modulo $(X^{N}+1)$, to the
/// Subtract the result of the product between two polynomials, reduced modulo $(X^{N}+1)$, to the
/// output polynomial.
///
/// # Note
@@ -328,7 +328,7 @@ pub fn polynomial_wrapping_sub_mul_assign<Scalar, OutputCont, InputCont1, InputC
}
}
/// Fills the ouptut polynomial, with the result of the product of two polynomials, reduced modulo
/// Fill the ouptut polynomial, with the result of the product of two polynomials, reduced modulo
/// $(X^{N} + 1)$ with the schoolbook algorithm Complexity: $O(N^{2})$
///
/// # Note
@@ -362,7 +362,7 @@ pub fn polynomial_wrapping_mul<Scalar, OutputCont, LhsCont, RhsCont>(
polynomial_wrapping_add_mul_assign(output, lhs, rhs);
}
/// Fills the output polynomial, with the result of the product of two polynomials, reduced modulo
/// Fill the output polynomial, with the result of the product of two polynomials, reduced modulo
/// $(X^{N} + 1)$ with the Karatsuba algorithm Complexity: $O(N^{1.58})$
///
/// # Note
@@ -502,7 +502,7 @@ mod test {
// settings
let polynomial_size = random_polynomial_size(2048);
// generates a random Torus polynomial
// generate a random Torus polynomial
let mut poly = Polynomial::new(T::ZERO, polynomial_size);
generator.fill_slice_with_random_uniform(poly.as_mut());
@@ -511,7 +511,7 @@ mod test {
// copy this polynomial
let ground_truth = poly.clone();
// generates a random r
// generate a random r
let mut r: usize = rng.gen();
r %= polynomial_size;
@@ -522,7 +522,7 @@ mod test {
// test
assert_eq!(&poly, &ground_truth);
// generates a random r_big
// generate a random r_big
let mut r_big: usize = rng.gen();
r_big = r_big % polynomial_size + 2048;
@@ -554,7 +554,7 @@ mod test {
let polynomial_size = PolynomialSize(1 << polynomial_log);
let mut generator = new_random_generator();
// generates two random Torus polynomials
// generate two random Torus polynomials
let mut poly_1 = Polynomial::new(T::ZERO, polynomial_size);
generator.fill_slice_with_random_uniform::<T>(poly_1.as_mut());
let poly_1 = poly_1;

View File

@@ -2,7 +2,7 @@
use crate::core_crypto::commons::numeric::UnsignedInteger;
/// Computes a dot product between two slices containing unsigned integers.
/// Compute a dot product between two slices containing unsigned integers.
///
/// # Note
///
@@ -36,7 +36,7 @@ where
})
}
/// Adds a slice containing unsigned integers to another one element-wise.
/// Add a slice containing unsigned integers to another one element-wise.
///
/// # Note
///
@@ -76,7 +76,7 @@ where
.for_each(|(out, (&lhs, &rhs))| *out = lhs.wrapping_add(rhs));
}
/// Adds a slice containing unsigned integers to another one element-wise and in place.
/// Add a slice containing unsigned integers to another one element-wise and in place.
///
/// # Note
///
@@ -108,7 +108,7 @@ where
.for_each(|(lhs, &rhs)| *lhs = (*lhs).wrapping_add(rhs));
}
/// Adds a slice containing unsigned integers to another one mutiplied by a scalar.
/// Add a slice containing unsigned integers to another one mutiplied by a scalar.
///
/// Let *a*,*b* be two slices, let *c* be a scalar, this computes: *a <- a+bc*
///
@@ -145,7 +145,7 @@ pub fn slice_wrapping_add_scalar_mul_assign<Scalar>(
.for_each(|(lhs, &rhs)| *lhs = (*lhs).wrapping_add(rhs.wrapping_mul(scalar)));
}
/// Subtracts a slice containing unsigned integers to another one element-wise.
/// Subtract a slice containing unsigned integers to another one element-wise.
///
/// # Note
///
@@ -185,7 +185,7 @@ where
.for_each(|(out, (&lhs, &rhs))| *out = lhs.wrapping_sub(rhs));
}
/// Subtracts a slice containing unsigned integers to another one, element-wise and in place.
/// Subtract a slice containing unsigned integers to another one, element-wise and in place.
///
/// # Note
///
@@ -217,7 +217,7 @@ where
.for_each(|(lhs, &rhs)| *lhs = (*lhs).wrapping_sub(rhs));
}
/// Subtracts a slice containing unsigned integers to another one mutiplied by a scalar,
/// Subtract a slice containing unsigned integers to another one mutiplied by a scalar,
/// element-wise and in place.
///
/// Let *a*,*b* be two slices, let *c* be a scalar, this computes: *a <- a-bc*
@@ -254,7 +254,7 @@ pub fn slice_wrapping_sub_scalar_mul_assign<Scalar>(
.for_each(|(lhs, &rhs)| *lhs = (*lhs).wrapping_sub(rhs.wrapping_mul(scalar)));
}
/// Computes the opposite of a slice containing unsigned integers, element-wise and in place.
/// Compute the opposite of a slice containing unsigned integers, element-wise and in place.
///
/// # Note
///
@@ -278,7 +278,7 @@ where
.for_each(|elt| *elt = (*elt).wrapping_neg());
}
/// Multiplies a slice containing unsigned integers by a scalar, element-wise and in place.
/// Multiply a slice containing unsigned integers by a scalar, element-wise and in place.
///
/// # Note
///

View File

@@ -21,11 +21,11 @@ use serde::{Deserialize, Serialize};
// As long as Variance wraps a native type (f64) it is ok to derive it from Copy instead of
// Clone because f64 is itself Copy and stored in register.
pub trait DispersionParameter: Copy {
/// Returns the standard deviation of the distribution, i.e. $\sigma = 2^p$.
/// Return the standard deviation of the distribution, i.e. $\sigma = 2^p$.
fn get_standard_dev(&self) -> f64;
/// Returns the variance of the distribution, i.e. $\sigma^2 = 2^{2p}$.
/// Return the variance of the distribution, i.e. $\sigma^2 = 2^{2p}$.
fn get_variance(&self) -> f64;
/// Returns base 2 logarithm of the standard deviation of the distribution, i.e.
/// Return base 2 logarithm of the standard deviation of the distribution, i.e.
/// $\log\_2(\sigma)=p$
fn get_log_standard_dev(&self) -> f64;
/// For a `Uint` type representing $\mathbb{Z}/2^q\mathbb{Z}$, we return $2^{q-p}$.

View File

@@ -21,7 +21,7 @@ pub struct EncryptionRandomGenerator<G: ByteRandomGenerator> {
}
impl<G: ByteRandomGenerator> EncryptionRandomGenerator<G> {
/// Creates a new [`EncryptionRandomGenerator`], using the provided [`Seed`] to seed the public
/// Create a new [`EncryptionRandomGenerator`], using the provided [`Seed`] to seed the public
/// mask generator and using the provided [`Seeder`] to privately seed the noise generator.
// S is ?Sized to allow Box<dyn Seeder> to be passed.
pub fn new<S: Seeder + ?Sized>(seed: Seed, seeder: &mut S) -> EncryptionRandomGenerator<G> {
@@ -38,7 +38,7 @@ impl<G: ByteRandomGenerator> EncryptionRandomGenerator<G> {
self.noise = RandomGenerator::new(seed);
}
/// Returns the number of remaining bytes for the mask generator, if the generator is bounded.
/// Return the number of remaining bytes for the mask generator, if the generator is bounded.
pub fn remaining_bytes(&self) -> Option<usize> {
self.mask.remaining_bytes()
}

View File

@@ -6,12 +6,12 @@ use crate::core_crypto::commons::math::random::{
pub struct SecretRandomGenerator<G: ByteRandomGenerator>(RandomGenerator<G>);
impl<G: ByteRandomGenerator> SecretRandomGenerator<G> {
/// Creates a new generator, optionally seeding it with the given value.
/// Create a new generator, optionally seeding it with the given value.
pub fn new(seed: Seed) -> SecretRandomGenerator<G> {
SecretRandomGenerator(RandomGenerator::new(seed))
}
/// Returns the number of remaining bytes, if the generator is bounded.
/// Return the number of remaining bytes, if the generator is bounded.
pub fn remaining_bytes(&self) -> Option<usize> {
self.0.remaining_bytes()
}

View File

@@ -20,7 +20,7 @@ impl<Scalar> SignedDecomposer<Scalar>
where
Scalar: UnsignedInteger,
{
/// Creates a new decomposer.
/// Create a new decomposer.
///
/// # Example
///
@@ -47,7 +47,7 @@ where
}
}
/// Returns the logarithm in base two of the base of this decomposer.
/// Return the logarithm in base two of the base of this decomposer.
///
/// If the decomposer uses a base $B=2^b$, this returns $b$.
///
@@ -64,7 +64,7 @@ where
DecompositionBaseLog(self.base_log)
}
/// Returns the number of levels of this decomposer.
/// Return the number of levels of this decomposer.
///
/// If the decomposer uses $l$ levels, this returns $l$.
///
@@ -81,7 +81,7 @@ where
DecompositionLevelCount(self.level_count)
}
/// Returns the closet value representable by the decomposition.
/// Return the closet value representable by the decomposition.
///
/// # Example
///
@@ -113,7 +113,7 @@ where
res << non_rep_bit_count
}
/// Generates an iterator over the terms of the decomposition of the input.
/// Generate an iterator over the terms of the decomposition of the input.
///
/// # Warning
///

View File

@@ -50,7 +50,7 @@ where
self.fresh
}
/// Returns the logarithm in base two of the base of this decomposition.
/// Return the logarithm in base two of the base of this decomposition.
///
/// If the decomposition uses a base $B=2^b$, this returns $b$.
///
@@ -69,7 +69,7 @@ where
DecompositionBaseLog(self.base_log)
}
/// Returns the number of levels of this decomposition.
/// Return the number of levels of this decomposition.
///
/// If the decomposition uses $l$ levels, this returns $l$.
///

View File

@@ -35,7 +35,7 @@ where
}
}
/// Turns this term into a summand.
/// Turn this term into a summand.
///
/// If our member represents one $\tilde{\theta}\_i$ of the decomposition, this method returns
/// $\tilde{\theta}\_i\frac{q}{B^i}$.
@@ -55,7 +55,7 @@ where
self.value << shift
}
/// Returns the value of the term.
/// Return the value of the term.
///
/// If our member represents one $\tilde{\theta}\_i$, this returns its actual value.
///
@@ -73,7 +73,7 @@ where
self.value
}
/// Returns the level of the term.
/// Return the level of the term.
///
/// If our member represents one $\tilde{\theta}\_i$, this returns the value of $i$.
///

View File

@@ -6,7 +6,7 @@ use crate::core_crypto::commons::parameters::{DecompositionBaseLog, Decompositio
use crate::core_crypto::commons::test_tools::{any_uint, any_usize, random_usize_between};
use std::fmt::Debug;
// Returns a random decomposition valid for the size of the T type.
// Return a random decomposition valid for the size of the T type.
fn random_decomp<T: UnsignedInteger>() -> SignedDecomposer<T> {
let mut base_log;
let mut level_count;

View File

@@ -78,7 +78,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
self.0.next_byte().unwrap()
}
/// Generates a new generator, optionally seeding it with the given value.
/// Generate a new generator, optionally seeding it with the given value.
///
/// # Example
///
@@ -92,7 +92,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
RandomGenerator(G::new(seed))
}
/// Returns the number of bytes that can still be generated, if the generator is bounded.
/// Return the number of bytes that can still be generated, if the generator is bounded.
///
/// # Example
///
@@ -132,7 +132,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
.map(|iter| iter.map(Self))
}
/// Generates a random uniform unsigned integer.
/// Generate a random uniform unsigned integer.
///
/// # Example
///
@@ -158,7 +158,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::generate_one(self, Uniform)
}
/// Fills a slice with random uniform values.
/// Fill a slice with random uniform values.
///
/// # Example
///
@@ -177,7 +177,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::fill_slice(self, Uniform, output);
}
/// Generates a random uniform binary value.
/// Generate a random uniform binary value.
///
/// # Example
///
@@ -192,7 +192,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::generate_one(self, UniformBinary)
}
/// Fills a slice with random uniform binary values.
/// Fill a slice with random uniform binary values.
///
/// # Example
///
@@ -211,7 +211,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::fill_slice(self, UniformBinary, output);
}
/// Generates a random uniform ternary value.
/// Generate a random uniform ternary value.
///
/// # Example
///
@@ -226,7 +226,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::generate_one(self, UniformTernary)
}
/// Generates an unsigned integer whose n least significant bits are uniformly random, and the
/// Generate an unsigned integer whose n least significant bits are uniformly random, and the
/// other bits are zero.
///
/// # Example
@@ -246,7 +246,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::generate_one(self, UniformLsb { n })
}
/// Generates an unsigned integer whose n most significant bits are uniformly random, and the
/// Generate an unsigned integer whose n most significant bits are uniformly random, and the
/// other bits are zero.
///
/// # Example
@@ -266,7 +266,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::generate_one(self, UniformMsb { n })
}
/// Generates a random uniform unsigned integer with probability `1-prob_zero`, and a zero value
/// Generate a random uniform unsigned integer with probability `1-prob_zero`, and a zero value
/// with probability `prob_zero`.
///
/// # Example
@@ -291,7 +291,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
Scalar::generate_one(self, UniformWithZeros { prob_zero })
}
/// Generates two floating point values drawn from a gaussian distribution with input mean and
/// Generate two floating point values drawn from a gaussian distribution with input mean and
/// standard deviation.
///
/// # Example
@@ -320,7 +320,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
<(Scalar, Scalar)>::generate_one(self, Gaussian { std, mean })
}
/// Fills a slice with random gaussian values.
/// Fill a slice with random gaussian values.
///
/// # Example
///
@@ -352,7 +352,7 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
});
}
/// Adds a random gaussian value to each element in a slice.
/// Add a random gaussian value to each element in a slice.
///
/// # Example
///

View File

@@ -11,7 +11,7 @@ fn test_normal_random<T: UnsignedTorus>() {
let k = 1_000_000;
let mut generator = new_random_generator();
// generates normal random
// generate normal random
let mut samples_int = vec![T::ZERO; k];
generator.fill_slice_with_random_gaussian(&mut samples_int, mean, std_dev);
@@ -66,7 +66,7 @@ fn test_distribution<T: UnsignedTorus>() {
let k = 10_000_000;
let mut generator = new_random_generator();
// generates normal random
// generate normal random
let first = vec![T::ZERO; k];
let mut second = vec![T::ZERO; k];
generator.fill_slice_with_random_gaussian(&mut second, mean, std_dev);

View File

@@ -26,7 +26,7 @@ where
F: FloatingPoint,
Self: UnsignedInteger,
{
/// Consumes `self` and returns its closest floating point representation.
/// Consume `self` and returns its closest floating point representation.
fn into_torus(self) -> F;
}
@@ -37,7 +37,7 @@ where
F: FloatingPoint,
Self: UnsignedInteger,
{
/// Consumes `input` and returns its closest unsigned integer representation.
/// Consume `input` and returns its closest unsigned integer representation.
fn from_torus(input: F) -> Self;
}

View File

@@ -186,43 +186,43 @@ pub mod test_tools {
);
}
/// Returns a random plaintext count in [1;max].
/// Return a random plaintext count in [1;max].
pub fn random_plaintext_count(max: usize) -> PlaintextCount {
let max = std::cmp::max(2, max);
PlaintextCount(random_usize_between(1..max + 1))
}
/// Returns a random ciphertext count in [1;max].
/// Return a random ciphertext count in [1;max].
pub fn random_ciphertext_count(max: usize) -> CiphertextCount {
let max = std::cmp::max(2, max);
CiphertextCount(random_usize_between(1..max + 1))
}
/// Returns a random LWE dimension in [1;max].
/// Return a random LWE dimension in [1;max].
pub fn random_lwe_dimension(max: usize) -> LweDimension {
let max = std::cmp::max(2, max);
LweDimension(random_usize_between(1..max + 1))
}
/// Returns a random GLWE dimension in [1;max].
/// Return a random GLWE dimension in [1;max].
pub fn random_glwe_dimension(max: usize) -> GlweDimension {
let max = std::cmp::max(2, max);
GlweDimension(random_usize_between(1..max + 1))
}
/// Returns a random polynomial size in [2;max].
/// Return a random polynomial size in [2;max].
pub fn random_polynomial_size(max: usize) -> PolynomialSize {
let max = std::cmp::max(3, max);
PolynomialSize(random_usize_between(2..max + 1))
}
/// Returns a random base log in [2;max].
/// Return a random base log in [2;max].
pub fn random_base_log(max: usize) -> DecompositionBaseLog {
let max = std::cmp::max(3, max);
DecompositionBaseLog(random_usize_between(2..max + 1))
}
/// Returns a random level count in [2;max].
/// Return a random level count in [2;max].
pub fn random_level_count(max: usize) -> DecompositionLevelCount {
let max = std::cmp::max(3, max);
DecompositionLevelCount(random_usize_between(2..max + 1))

View File

@@ -18,15 +18,15 @@ pub trait FloatingPoint:
+ Sub<Self, Output = Self>
+ SubAssign<Self>
{
/// Raises a float to an integer power.
/// Raise a float to an integer power.
#[must_use]
fn powi(self, power: i32) -> Self;
/// Rounds the float to the closest integer.
/// Round the float to the closest integer.
#[must_use]
fn round(self) -> Self;
/// Keeps the fractional part of the number.
/// Keep the fractional part of the number.
#[must_use]
fn fract(self) -> Self;
@@ -34,23 +34,23 @@ pub trait FloatingPoint:
#[must_use]
fn rem_euclid(self, rhs: Self) -> Self;
/// Returns the square root of the input float.
/// Return the square root of the input float.
#[must_use]
fn sqrt(self) -> Self;
/// Returns the natural logarithm of the input float.
/// Return the natural logarithm of the input float.
#[must_use]
fn ln(self) -> Self;
/// Returns the absolute value of the input float.
/// Return the absolute value of the input float.
#[must_use]
fn abs(self) -> Self;
/// Returns the floor value of the input float.
/// Return the floor value of the input float.
#[must_use]
fn floor(self) -> Self;
/// Returns a bit representation of the float, with the sign, exponent, and mantissa bits
/// Return a bit representation of the float, with the sign, exponent, and mantissa bits
/// separated by whitespaces for increased readability.
fn to_bit_string(&self) -> String;
}

View File

@@ -35,10 +35,10 @@ pub trait SignedInteger:
/// The unsigned type of the same precicion
type Unsigned: UnsignedInteger<Signed = Self> + CastFrom<Self>;
/// Returns the casting of the current value to the unsigned type of the same size.
/// Return the casting of the current value to the unsigned type of the same size.
fn into_unsigned(self) -> Self::Unsigned;
/// Returns a bit representation of the integer, where blocks of length `block_length` are
/// Return a bit representation of the integer, where blocks of length `block_length` are
/// separated by whitespaces to increase the readability.
fn to_bits_string(&self, block_length: usize) -> String;
}

View File

@@ -59,9 +59,9 @@ pub trait UnsignedInteger:
/// Panic free shift-right operation.
#[must_use]
fn wrapping_shr(self, rhs: u32) -> Self;
/// Returns the casting of the current value to the signed type of the same size.
/// Return the casting of the current value to the signed type of the same size.
fn into_signed(self) -> Self::Signed;
/// Returns a bit representation of the integer, where blocks of length `block_length` are
/// Return a bit representation of the integer, where blocks of length `block_length` are
/// separated by whitespaces to increase the readability.
fn to_bits_string(&self, block_length: usize) -> String;
}

View File

@@ -51,7 +51,7 @@ pub struct GgswCiphertextCount(pub usize);
pub struct LweSize(pub usize);
impl LweSize {
/// Returns the associated [`LweDimension`].
/// Return the associated [`LweDimension`].
pub fn to_lwe_dimension(&self) -> LweDimension {
LweDimension(self.0 - 1)
}
@@ -62,7 +62,7 @@ impl LweSize {
pub struct LweDimension(pub usize);
impl LweDimension {
/// Returns the associated [`LweSize`].
/// Return the associated [`LweSize`].
pub fn to_lwe_size(&self) -> LweSize {
LweSize(self.0 + 1)
}
@@ -78,7 +78,7 @@ pub struct LwePublicKeyZeroEncryptionCount(pub usize);
pub struct GlweSize(pub usize);
impl GlweSize {
/// Returns the associated [`GlweDimension`].
/// Return the associated [`GlweDimension`].
pub fn to_glwe_dimension(&self) -> GlweDimension {
GlweDimension(self.0 - 1)
}
@@ -89,7 +89,7 @@ impl GlweSize {
pub struct GlweDimension(pub usize);
impl GlweDimension {
/// Returns the associated [`GlweSize`].
/// Return the associated [`GlweSize`].
pub fn to_glwe_size(&self) -> GlweSize {
GlweSize(self.0 + 1)
}
@@ -102,7 +102,7 @@ impl GlweDimension {
pub struct PolynomialSize(pub usize);
impl PolynomialSize {
/// Returns the associated [`PolynomialSizeLog`].
/// Return the associated [`PolynomialSizeLog`].
pub fn log2(&self) -> PolynomialSizeLog {
PolynomialSizeLog((self.0 as f64).log2().ceil() as usize)
}
@@ -115,7 +115,7 @@ impl PolynomialSize {
pub struct PolynomialSizeLog(pub usize);
impl PolynomialSizeLog {
/// Returns the associated [`PolynomialSizeLog`].
/// Return the associated [`PolynomialSizeLog`].
pub fn to_polynomial_size(&self) -> PolynomialSize {
PolynomialSize(1 << self.0)
}

View File

@@ -7,7 +7,7 @@ fn assert_same_len(a: (usize, Option<usize>), b: (usize, Option<usize>)) {
debug_assert_eq!(a.0, b.0);
}
/// Returns a Zip iterator, but checks that the two components have the same length.
/// Return a Zip iterator, but checks that the two components have the same length.
pub trait ZipChecked: IntoIterator + Sized {
#[inline]
fn zip_checked<B: IntoIterator>(

View File

@@ -174,7 +174,7 @@ impl<T, C: ContainerMut<Element = T>> AsMut<[T]> for GgswCiphertext<C> {
}
}
/// Returns the number of elements in a [`GgswCiphertext`] given a [`GlweSize`], [`PolynomialSize`]
/// Return the number of elements in a [`GgswCiphertext`] given a [`GlweSize`], [`PolynomialSize`]
/// and [`DecompositionLevelCount`].
pub fn ggsw_ciphertext_size(
glwe_size: GlweSize,
@@ -184,7 +184,7 @@ pub fn ggsw_ciphertext_size(
decomp_level_count.0 * ggsw_level_matrix_size(glwe_size, polynomial_size)
}
/// Returns the number of elements in a [`GgswLevelMatrix`] given a [`GlweSize`] and
/// Return the number of elements in a [`GgswLevelMatrix`] given a [`GlweSize`] and
/// [`PolynomialSize`].
pub fn ggsw_level_matrix_size(glwe_size: GlweSize, polynomial_size: PolynomialSize) -> usize {
glwe_size.0 * glwe_size.0 * polynomial_size.0
@@ -272,35 +272,35 @@ impl<Scalar, C: Container<Element = Scalar>> GgswCiphertext<C> {
}
}
/// Returns the [`PolynomialSize`] of the [`GgswCiphertext`].
/// Return the [`PolynomialSize`] of the [`GgswCiphertext`].
///
/// See [`GgswCiphertext::from_container`] for usage.
pub fn polynomial_size(&self) -> PolynomialSize {
self.polynomial_size
}
/// Returns the [`GlweSize`] of the [`GgswCiphertext`].
/// Return the [`GlweSize`] of the [`GgswCiphertext`].
///
/// See [`GgswCiphertext::from_container`] for usage.
pub fn glwe_size(&self) -> GlweSize {
self.glwe_size
}
/// Returns the [`DecompositionBaseLog`] of the [`GgswCiphertext`].
/// Return the [`DecompositionBaseLog`] of the [`GgswCiphertext`].
///
/// See [`GgswCiphertext::from_container`] for usage.
pub fn decomposition_base_log(&self) -> DecompositionBaseLog {
self.decomp_base_log
}
/// Returns the [`DecompositionLevelCount`] of the [`GgswCiphertext`].
/// Return the [`DecompositionLevelCount`] of the [`GgswCiphertext`].
///
/// See [`GgswCiphertext::from_container`] for usage.
pub fn decomposition_level_count(&self) -> DecompositionLevelCount {
DecompositionLevelCount(self.data.container_len() / self.ggsw_level_matrix_size())
}
/// Returns the size in number of elements of a single [`GgswLevelMatrix`] of the current
/// Return the size in number of elements of a single [`GgswLevelMatrix`] of the current
/// [`GgswCiphertext`].
///
/// See [`GgswCiphertext::from_container`] for usage.
@@ -309,17 +309,17 @@ impl<Scalar, C: Container<Element = Scalar>> GgswCiphertext<C> {
ggsw_level_matrix_size(self.glwe_size, self.polynomial_size)
}
/// Interprets the [`GgswCiphertext`] as a [`PolynomialList`].
/// Interpret the [`GgswCiphertext`] as a [`PolynomialList`].
pub fn as_polynomial_list(&self) -> PolynomialListView<'_, Scalar> {
PolynomialListView::from_container(self.as_ref(), self.polynomial_size)
}
/// Interprets the [`GgswCiphertext`] as a [`GlweCiphertextList`].
/// Interpret the [`GgswCiphertext`] as a [`GlweCiphertextList`].
pub fn as_glwe_list(&self) -> GlweCiphertextListView<'_, Scalar> {
GlweCiphertextListView::from_container(self.as_ref(), self.glwe_size, self.polynomial_size)
}
/// Returns a view of the [`GgswCiphertext`]. This is useful if an algorithm takes a view by
/// Return a view of the [`GgswCiphertext`]. This is useful if an algorithm takes a view by
/// value.
pub fn as_view(&self) -> GgswCiphertextView<'_, Scalar> {
GgswCiphertextView::from_container(
@@ -330,7 +330,7 @@ impl<Scalar, C: Container<Element = Scalar>> GgswCiphertext<C> {
)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
///
/// See [`GgswCiphertext::from_container`] for usage.
pub fn into_container(self) -> C {
@@ -474,7 +474,7 @@ impl<C: Container> GgswLevelMatrix<C> {
self.polynomial_size
}
/// Interprets the [`GgswLevelMatrix`] as a [`GlweCiphertextList`].
/// Interpret the [`GgswLevelMatrix`] as a [`GlweCiphertextList`].
pub fn as_glwe_list(&self) -> GlweCiphertextListView<'_, C::Element> {
GlweCiphertextListView::from_container(
self.data.as_ref(),

View File

@@ -104,35 +104,35 @@ impl<Scalar, C: Container<Element = Scalar>> GgswCiphertextList<C> {
}
}
/// Returns the [`GlweSize`] of the [`GgswCiphertext`] stored in the list.
/// Return the [`GlweSize`] of the [`GgswCiphertext`] stored in the list.
///
/// See [`GgswCiphertextList::from_container`] for usage.
pub fn glwe_size(&self) -> GlweSize {
self.glwe_size
}
/// Returns the [`PolynomialSize`] of the [`GgswCiphertext`] in the list.
/// Return the [`PolynomialSize`] of the [`GgswCiphertext`] in the list.
///
/// See [`GgswCiphertextList::from_container`] for usage.
pub fn polynomial_size(&self) -> PolynomialSize {
self.polynomial_size
}
/// Returns the [`DecompositionBaseLog`] of the [`GgswCiphertext`] in the list.
/// Return the [`DecompositionBaseLog`] of the [`GgswCiphertext`] in the list.
///
/// See [`GgswCiphertextList::from_container`] for usage.
pub fn decomposition_base_log(&self) -> DecompositionBaseLog {
self.decomp_base_log
}
/// Returns the [`DecompositionLevelCount`] of the [`GgswCiphertext`] in the list.
/// Return the [`DecompositionLevelCount`] of the [`GgswCiphertext`] in the list.
///
/// See [`GgswCiphertextList::from_container`] for usage.
pub fn decomposition_level_count(&self) -> DecompositionLevelCount {
self.decomp_level_count
}
/// Returns the [`GgswCiphertextCount`] of the [`GgswCiphertextList`].
/// Return the [`GgswCiphertextCount`] of the [`GgswCiphertextList`].
///
/// See [`GgswCiphertextList::from_container`] for usage.
pub fn ggsw_ciphertext_count(&self) -> GgswCiphertextCount {
@@ -146,7 +146,7 @@ impl<Scalar, C: Container<Element = Scalar>> GgswCiphertextList<C> {
)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
///
/// See [`GgswCiphertextList::from_container`] for usage.
pub fn into_container(self) -> C {

View File

@@ -33,14 +33,14 @@ impl<C: Container> GlweBody<C> {
GlweBody { data: container }
}
/// Returns the [`PolynomialSize`] of the [`GlweBody`].
/// Return the [`PolynomialSize`] of the [`GlweBody`].
///
/// See [`GlweBody::from_container`] for usage.
pub fn polynomial_size(&self) -> PolynomialSize {
PolynomialSize(self.data.container_len())
}
/// Interprets the [`GlweBody`] as a [`Polynomial`].
/// Interpret the [`GlweBody`] as a [`Polynomial`].
pub fn as_polynomial(&self) -> PolynomialView<'_, C::Element> {
PolynomialView::from_container(self.as_ref())
}
@@ -93,21 +93,21 @@ impl<C: Container> GlweMask<C> {
}
}
/// Returns the [`GlweDimension`] of the [`GlweMask`].
/// Return the [`GlweDimension`] of the [`GlweMask`].
///
/// See [`GlweMask::from_container`] for usage.
pub fn glwe_dimension(&self) -> GlweDimension {
GlweDimension(self.data.container_len() / self.polynomial_size.0)
}
/// Returns the [`PolynomialSize`] of the [`GlweMask`].
/// Return the [`PolynomialSize`] of the [`GlweMask`].
///
/// See [`GlweMask::from_container`] for usage.
pub fn polynomial_size(&self) -> PolynomialSize {
self.polynomial_size
}
/// Interprets the [`GlweMask`] as a [`PolynomialList`].
/// Interpret the [`GlweMask`] as a [`PolynomialList`].
pub fn as_polynomial_list(&self) -> PolynomialListView<'_, C::Element> {
PolynomialListView::from_container(self.as_ref(), self.polynomial_size)
}
@@ -145,13 +145,13 @@ impl<T, C: ContainerMut<Element = T>> AsMut<[T]> for GlweBody<C> {
}
}
/// Returns the number of elements in a [`GlweCiphertext`] given a [`GlweSize`] and
/// Return the number of elements in a [`GlweCiphertext`] given a [`GlweSize`] and
/// [`PolynomialSize`].
pub fn glwe_ciphertext_size(glwe_size: GlweSize, polynomial_size: PolynomialSize) -> usize {
glwe_size.0 * polynomial_size.0
}
/// Returns the number of elements in a [`GlweMask`] given a [`GlweDimension`] and
/// Return the number of elements in a [`GlweMask`] given a [`GlweDimension`] and
/// [`PolynomialSize`].
pub fn glwe_ciphertext_mask_size(
glwe_dimension: GlweDimension,
@@ -252,21 +252,21 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertext<C> {
}
}
/// Returns the [`GlweSize`] of the [`GlweCiphertext`].
/// Return the [`GlweSize`] of the [`GlweCiphertext`].
///
/// See [`GlweCiphertext::from_container`] for usage.
pub fn glwe_size(&self) -> GlweSize {
GlweSize(self.as_ref().container_len() / self.polynomial_size.0)
}
/// Returns the [`PolynomialSize`] of the [`GlweCiphertext`].
/// Return the [`PolynomialSize`] of the [`GlweCiphertext`].
///
/// See [`GlweCiphertext::from_container`] for usage.
pub fn polynomial_size(&self) -> PolynomialSize {
self.polynomial_size
}
/// Returns immutable views to the [`GlweMask`] and [`GlweBody`] of a [`GlweCiphertext`].
/// Return immutable views to the [`GlweMask`] and [`GlweBody`] of a [`GlweCiphertext`].
pub fn get_mask_and_body(&self) -> (GlweMask<&[Scalar]>, GlweBody<&[Scalar]>) {
let (mask, body) = self.data.as_ref().split_at(glwe_ciphertext_mask_size(
self.glwe_size().to_glwe_dimension(),
@@ -279,7 +279,7 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertext<C> {
)
}
/// Returns an immutable view to the [`GlweBody`] of a [`GlweCiphertext`].
/// Return an immutable view to the [`GlweBody`] of a [`GlweCiphertext`].
pub fn get_body(&self) -> GlweBody<&[Scalar]> {
let body = &self.data.as_ref()[glwe_ciphertext_mask_size(
self.glwe_size().to_glwe_dimension(),
@@ -289,7 +289,7 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertext<C> {
GlweBody::from_container(body)
}
/// Returns an immutable view to the [`GlweMask`] of a [`GlweCiphertext`].
/// Return an immutable view to the [`GlweMask`] of a [`GlweCiphertext`].
pub fn get_mask(&self) -> GlweMask<&[Scalar]> {
GlweMask::from_container(
&self.as_ref()[0..glwe_ciphertext_mask_size(
@@ -300,12 +300,12 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertext<C> {
)
}
/// Interprets the [`GlweCiphertext`] as a [`PolynomialList`].
/// Interpret the [`GlweCiphertext`] as a [`PolynomialList`].
pub fn as_polynomial_list(&self) -> PolynomialList<&'_ [Scalar]> {
PolynomialList::from_container(self.as_ref(), self.polynomial_size)
}
/// Returns a view of the [`GlweCiphertext`]. This is useful if an algorithm takes a view by
/// Return a view of the [`GlweCiphertext`]. This is useful if an algorithm takes a view by
/// value.
pub fn as_view(&self) -> GlweCiphertext<&'_ [Scalar]> {
GlweCiphertext {
@@ -314,7 +314,7 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertext<C> {
}
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -75,21 +75,21 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertextList<C> {
}
}
/// Returns the [`GlweSize`] of the [`GlweCiphertext`] stored in the list.
/// Return the [`GlweSize`] of the [`GlweCiphertext`] stored in the list.
///
/// See [`GlweCiphertextList::from_container`] for usage.
pub fn glwe_size(&self) -> GlweSize {
self.glwe_size
}
/// Returns the [`PolynomialSize`] of the [`GlweCiphertext`] stored in the list.
/// Return the [`PolynomialSize`] of the [`GlweCiphertext`] stored in the list.
///
/// See [`GlweCiphertextList::from_container`] for usage.
pub fn polynomial_size(&self) -> PolynomialSize {
self.polynomial_size
}
/// Returns the [`GlweCiphertextCount`] of the [`GlweCiphertextList`].
/// Return the [`GlweCiphertextCount`] of the [`GlweCiphertextList`].
///
/// See [`GlweCiphertextList::from_container`] for usage.
pub fn glwe_ciphertext_count(&self) -> GlweCiphertextCount {
@@ -98,7 +98,7 @@ impl<Scalar, C: Container<Element = Scalar>> GlweCiphertextList<C> {
)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
///
/// See [`GlweCiphertextList::from_container`] for usage.
pub fn into_container(self) -> C {

View File

@@ -55,7 +55,7 @@ impl<Scalar, C: Container<Element = Scalar>> GlweSecretKey<C> {
PolynomialListView::from_container(self.as_ref(), self.polynomial_size)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -50,7 +50,7 @@ impl<Scalar, C: Container<Element = Scalar>> LweBootstrapKey<C> {
LweDimension(self.glwe_size().to_glwe_dimension().0 * self.polynomial_size().0)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.ggsw_list.into_container()
}

View File

@@ -80,7 +80,7 @@ impl<Scalar, C: Container<Element = Scalar>> LweCiphertext<C> {
LweCiphertextView::from_container(self.as_ref())
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -47,7 +47,7 @@ impl<Scalar, C: Container<Element = Scalar>> LweCiphertextList<C> {
LweCiphertextListView::from_container(self.as_ref(), self.lwe_size)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -95,7 +95,7 @@ impl<Scalar, C: Container<Element = Scalar>> LweKeyswitchKey<C> {
)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -116,7 +116,7 @@ impl<Scalar, C: Container<Element = Scalar>> LwePrivateFunctionalPackingKeyswitc
)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -134,7 +134,7 @@ impl<Scalar, C: Container<Element = Scalar>> LwePrivateFunctionalPackingKeyswitc
)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -38,7 +38,7 @@ impl<Scalar, C: Container<Element = Scalar>> LwePublicKey<C> {
LwePublicKeyZeroEncryptionCount(self.lwe_ciphertext_count().0)
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.lwe_list.into_container()
}

View File

@@ -31,7 +31,7 @@ impl<Scalar, C: Container<Element = Scalar>> LweSecretKey<C> {
LweDimension(self.data.container_len())
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -32,7 +32,7 @@ impl<Scalar, C: Container<Element = Scalar>> PlaintextList<C> {
PolynomialView::from_container(self.as_ref())
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -36,7 +36,7 @@ impl<Scalar, C: Container<Element = Scalar>> Polynomial<C> {
self.polynomial_size().0 - 1
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -47,7 +47,7 @@ impl<Scalar, C: Container<Element = Scalar>> PolynomialList<C> {
PolynomialListView::from_container(self.as_ref(), self.polynomial_size())
}
/// Consumes the entity and return its underlying container.
/// Consume the entity and return its underlying container.
pub fn into_container(self) -> C {
self.data
}

View File

@@ -59,7 +59,7 @@ impl<C: Container<Element = c64>> FourierLweBootstrapKey<C> {
}
}
/// Returns an iterator over the GGSW ciphertexts composing the key.
/// Return an iterator over the GGSW ciphertexts composing the key.
pub fn into_ggsw_iter(self) -> impl DoubleEndedIterator<Item = FourierGgswCiphertext<C>>
where
C: Split,
@@ -168,13 +168,13 @@ impl FourierLweBootstrapKey<ABox<[c64]>> {
}
}
/// Returns the required memory for [`FourierLweBootstrapKeyMutView::fill_with_forward_fourier`].
/// Return the required memory for [`FourierLweBootstrapKeyMutView::fill_with_forward_fourier`].
pub fn fill_with_forward_fourier_scratch(fft: FftView<'_>) -> Result<StackReq, SizeOverflow> {
fft.forward_scratch()
}
impl<'a> FourierLweBootstrapKeyMutView<'a> {
/// Fills a bootstrapping key with the Fourier transform of a bootstrapping key in the standard
/// Fill a bootstrapping key with the Fourier transform of a bootstrapping key in the standard
/// domain.
pub fn fill_with_forward_fourier<Scalar: UnsignedTorus>(
mut self,
@@ -190,7 +190,7 @@ impl<'a> FourierLweBootstrapKeyMutView<'a> {
}
}
/// Returns the required memory for [`FourierLweBootstrapKeyView::blind_rotate_assign`].
/// Return the required memory for [`FourierLweBootstrapKeyView::blind_rotate_assign`].
pub fn blind_rotate_scratch<Scalar>(
glwe_size: GlweSize,
polynomial_size: PolynomialSize,
@@ -200,7 +200,7 @@ pub fn blind_rotate_scratch<Scalar>(
.try_and(cmux_scratch::<Scalar>(glwe_size, polynomial_size, fft)?)
}
/// Returns the required memory for [`FourierLweBootstrapKeyView::bootstrap`].
/// Return the required memory for [`FourierLweBootstrapKeyView::bootstrap`].
pub fn bootstrap_scratch<Scalar>(
glwe_size: GlweSize,
polynomial_size: PolynomialSize,

View File

@@ -157,7 +157,7 @@ impl<C: Container<Element = c64>> FourierGgswLevelMatrix<C> {
}
}
/// Returns an iterator over the rows of the level matrices.
/// Return an iterator over the rows of the level matrices.
pub fn into_rows(self) -> impl DoubleEndedIterator<Item = FourierGgswLevelRow<C>>
where
C: Split,
@@ -228,7 +228,7 @@ impl<C: Container<Element = c64>> FourierGgswLevelRow<C> {
}
impl<'a> FourierGgswCiphertextView<'a> {
/// Returns an iterator over the level matrices.
/// Return an iterator over the level matrices.
pub fn into_levels(self) -> impl DoubleEndedIterator<Item = FourierGgswLevelMatrixView<'a>> {
self.fourier
.data
@@ -246,13 +246,13 @@ impl<'a> FourierGgswCiphertextView<'a> {
}
}
/// Returns the required memory for [`FourierGgswCiphertextMutView::fill_with_forward_fourier`].
/// Return the required memory for [`FourierGgswCiphertextMutView::fill_with_forward_fourier`].
pub fn fill_with_forward_fourier_scratch(fft: FftView<'_>) -> Result<StackReq, SizeOverflow> {
fft.forward_scratch()
}
impl<'a> FourierGgswCiphertextMutView<'a> {
/// Fills a GGSW ciphertext with the Fourier transform of a GGSW ciphertext in the standard
/// Fill a GGSW ciphertext with the Fourier transform of a GGSW ciphertext in the standard
/// domain.
pub fn fill_with_forward_fourier<Scalar: UnsignedTorus>(
self,
@@ -279,7 +279,7 @@ impl<'a> FourierGgswCiphertextMutView<'a> {
}
}
/// Returns the required memory for [`add_external_product_assign`].
/// Return the required memory for [`add_external_product_assign`].
pub fn add_external_product_assign_scratch<Scalar>(
glwe_size: GlweSize,
polynomial_size: PolynomialSize,
@@ -302,7 +302,7 @@ pub fn add_external_product_assign_scratch<Scalar>(
substack0.try_and(fourier_scratch)
}
/// Performs the external product of `ggsw` and `glwe`, and adds the result to `out`.
/// Perform the external product of `ggsw` and `glwe`, and adds the result to `out`.
#[cfg_attr(__profiling, inline(never))]
pub fn add_external_product_assign<Scalar, InputGlweCont>(
mut out: GlweCiphertextMutView<'_, Scalar>,
@@ -639,7 +639,7 @@ unsafe fn update_with_fmadd(
});
}
/// Returns the required memory for [`cmux`].
/// Return the required memory for [`cmux`].
pub fn cmux_scratch<Scalar>(
glwe_size: GlweSize,
polynomial_size: PolynomialSize,

View File

@@ -631,7 +631,7 @@ pub fn cmux_tree_memory_optimized_scratch<Scalar>(
])
}
/// Performs a tree of cmux in a way that limits the total allocated memory to avoid issues for
/// Perform a tree of cmux in a way that limits the total allocated memory to avoid issues for
/// bigger trees.
pub fn cmux_tree_memory_optimized<Scalar: UnsignedTorus + CastInto<usize>>(
mut output_glwe: GlweCiphertext<&mut [Scalar]>,

View File

@@ -53,7 +53,7 @@ impl Twisties {
}
impl Twisties {
/// Creates a new [`Twisties`] containing the `2N`-th roots of unity with `n = N/2`.
/// Create a new [`Twisties`] containing the `2N`-th roots of unity with `n = N/2`.
///
/// # Panics
///
@@ -104,7 +104,7 @@ fn plans() -> &'static PlanMap {
PLANS.get_or_init(|| RwLock::new(HashMap::new()))
}
/// Returns the input slice, cast to the same type.
/// Return the input slice, cast to the same type.
///
/// This is useful when the fact that `From` and `To` are the same type cannot be proven in the
/// type system, but is known to be true at runtime.
@@ -124,7 +124,7 @@ fn id_mut<From: 'static, To: 'static>(slice: &mut [From]) -> &mut [To] {
unsafe { core::slice::from_raw_parts_mut(ptr as *mut To, len) }
}
/// Returns the input slice, cast to the same type.
/// Return the input slice, cast to the same type.
///
/// This is useful when the fact that `From` and `To` are the same type cannot be proven in the
/// type system, but is known to be true at runtime.
@@ -337,7 +337,7 @@ fn convert_add_backward_torus<Scalar: UnsignedTorus>(
}
impl<'a> FftView<'a> {
/// Returns the polynomial size that this FFT was made for.
/// Return the polynomial size that this FFT was made for.
pub fn polynomial_size(self) -> PolynomialSize {
PolynomialSize(2 * self.plan.fft_size())
}
@@ -360,12 +360,12 @@ impl<'a> FftView<'a> {
self.plan.deserialize_fourier_buffer(deserializer, buf)
}
/// Returns the memory required for a forward negacyclic FFT.
/// Return the memory required for a forward negacyclic FFT.
pub fn forward_scratch(self) -> Result<StackReq, SizeOverflow> {
self.plan.fft_scratch()
}
/// Returns the memory required for a backward negacyclic FFT.
/// Return the memory required for a backward negacyclic FFT.
pub fn backward_scratch(self) -> Result<StackReq, SizeOverflow> {
self.plan
.fft_scratch()?
@@ -375,7 +375,7 @@ impl<'a> FftView<'a> {
)?)
}
/// Performs a negacyclic real FFT of `standard`, viewed as torus elements, and stores the
/// Perform a negacyclic real FFT of `standard`, viewed as torus elements, and stores the
/// result in `fourier`.
///
/// # Note
@@ -396,7 +396,7 @@ impl<'a> FftView<'a> {
unsafe { self.forward_with_conv(fourier, standard, convert_forward_torus, stack) }
}
/// Performs a negacyclic real FFT of `standard`, viewed as integers, and stores the result in
/// Perform a negacyclic real FFT of `standard`, viewed as integers, and stores the result in
/// `fourier`.
///
/// # Note
@@ -417,7 +417,7 @@ impl<'a> FftView<'a> {
unsafe { self.forward_with_conv(fourier, standard, convert_forward_integer, stack) }
}
/// Performs an inverse negacyclic real FFT of `fourier` and stores the result in `standard`,
/// Perform an inverse negacyclic real FFT of `fourier` and stores the result in `standard`,
/// viewed as torus elements.
///
/// # Note
@@ -437,7 +437,7 @@ impl<'a> FftView<'a> {
unsafe { self.backward_with_conv(standard, fourier, convert_backward_torus, stack) }
}
/// Performs an inverse negacyclic real FFT of `fourier` and adds the result to `standard`,
/// Perform an inverse negacyclic real FFT of `fourier` and adds the result to `standard`,
/// viewed as torus elements.
///
/// # Note

View File

@@ -18,7 +18,7 @@ use super::super::super::c64;
use super::TwistiesView;
use std::mem::MaybeUninit;
/// Converts a vector of f64 values to a vector of i64 values.
/// Convert a vector of f64 values to a vector of i64 values.
/// See `f64_to_i64_bit_twiddles` in `fft/tests.rs` for the scalar version.
///
/// # Safety
@@ -79,7 +79,7 @@ pub unsafe fn mm256_cvtpd_epi64(x: __m256d) -> __m256i {
_mm256_blendv_epi8(value_if_non_subnormal, value_if_subnormal, is_subnormal)
}
/// Converts a vector of f64 values to a vector of i64 values.
/// Convert a vector of f64 values to a vector of i64 values.
/// See `f64_to_i64_bit_twiddles` in `fft/tests.rs` for the scalar version.
///
/// # Safety
@@ -141,7 +141,7 @@ pub unsafe fn mm512_cvtpd_epi64(x: __m512d) -> __m512i {
_mm512_mask_blend_epi64(is_subnormal, value_if_non_subnormal, value_if_subnormal)
}
/// Converts a vector of i64 values to a vector of f64 values. Not sure how it works.
/// Convert a vector of i64 values to a vector of f64 values. Not sure how it works.
/// Ported from <https://stackoverflow.com/a/41148578>.
///
/// # Safety
@@ -166,7 +166,7 @@ pub unsafe fn mm256_cvtepi64_pd(x: __m256i) -> __m256d {
_mm256_add_pd(f, _mm256_castsi256_pd(x_lo))
}
/// Converts a vector of i64 values to a vector of f64 values.
/// Convert a vector of i64 values to a vector of f64 values.
///
/// # Safety
///
@@ -460,7 +460,7 @@ pub unsafe fn convert_forward_integer_u64_avx2_fma(
}
}
/// Performs common work for `u32` and `u64`, used by the backward torus transformation.
/// Perform common work for `u32` and `u64`, used by the backward torus transformation.
///
/// This deinterleaves two vectors of c64 values into two vectors of real part and imaginary part,
/// then rounds to the nearest integer.
@@ -627,7 +627,7 @@ pub unsafe fn convert_add_backward_torus_u64_avx512f(
}
}
/// Performs common work for `u32` and `u64`, used by the backward torus transformation.
/// Perform common work for `u32` and `u64`, used by the backward torus transformation.
///
/// This deinterleaves two vectors of c64 values into two vectors of real part and imaginary part,
/// then rounds to the nearest integer.

View File

@@ -26,7 +26,7 @@ pub struct ClientKey {
}
impl ClientKey {
/// Generates a client key.
/// Generate a client key.
///
/// # Example
///
@@ -41,7 +41,7 @@ impl ClientKey {
ShortintEngine::with_thread_local_mut(|engine| engine.new_client_key(parameters).unwrap())
}
/// Encrypts a small integer message using the client key.
/// Encrypt a small integer message using the client key.
///
/// The input message is reduced to the encrypted message space modulus
///
@@ -72,7 +72,7 @@ impl ClientKey {
ShortintEngine::with_thread_local_mut(|engine| engine.encrypt(self, message).unwrap())
}
/// Encrypts a small integer message using the client key with a specific message modulus
/// Encrypt a small integer message using the client key with a specific message modulus
///
/// # Example
///
@@ -104,7 +104,7 @@ impl ClientKey {
})
}
/// Encrypts an integer without reducing the input message modulus the message space
/// Encrypt an integer without reducing the input message modulus the message space
///
/// # Example
///
@@ -130,7 +130,7 @@ impl ClientKey {
})
}
/// Decrypts a ciphertext encrypting an integer message and carries using the client key.
/// Decrypt a ciphertext encrypting an integer message and carries using the client key.
///
/// # Example
///
@@ -155,7 +155,7 @@ impl ClientKey {
})
}
/// Decrypts a ciphertext encrypting a message using the client key.
/// Decrypt a ciphertext encrypting a message using the client key.
///
/// # Example
///
@@ -178,7 +178,7 @@ impl ClientKey {
ShortintEngine::with_thread_local_mut(|engine| engine.decrypt(self, ct).unwrap())
}
/// Encrypts a small integer message using the client key without padding bit.
/// Encrypt a small integer message using the client key without padding bit.
///
/// The input message is reduced to the encrypted message space modulus
///
@@ -203,7 +203,7 @@ impl ClientKey {
})
}
/// Decrypts a ciphertext encrypting an integer message and carries using the client key,
/// Decrypt a ciphertext encrypting an integer message and carries using the client key,
/// where the ciphertext is assumed to not have any padding bit.
///
/// # Example
@@ -232,7 +232,7 @@ impl ClientKey {
})
}
/// Decrypts a ciphertext encrypting an integer message using the client key,
/// Decrypt a ciphertext encrypting an integer message using the client key,
/// where the ciphertext is assumed to not have any padding bit.
///
/// # Example
@@ -259,7 +259,7 @@ impl ClientKey {
})
}
/// Encrypts a small integer message using the client key without padding bit with some modulus.
/// Encrypt a small integer message using the client key without padding bit with some modulus.
///
/// The input message is reduced to the encrypted message space modulus
///
@@ -289,7 +289,7 @@ impl ClientKey {
})
}
/// Decrypts a ciphertext encrypting an integer message using the client key,
/// Decrypt a ciphertext encrypting an integer message using the client key,
/// where the ciphertext is assumed to not have any padding bit and is related to some modulus.
///
/// # Example

View File

@@ -101,7 +101,7 @@ impl ShortintEngine {
LOCAL_ENGINE.with(|engine_cell| func(&mut engine_cell.borrow_mut()))
}
/// Creates a new shortint engine
/// Create a new shortint engine
///
/// Creating a `ShortintEngine` should not be needed, as each
/// rust thread gets its own `thread_local` engine created automatically,
@@ -200,7 +200,7 @@ impl ShortintEngine {
ShortintEngine::generate_accumulator_with_engine(server_key, wrapped_f)
}
/// Returns the `Buffers` for the given `ServerKey`
/// Return the `Buffers` for the given `ServerKey`
///
/// Takes care creating the buffers if they do not exists for the given key
///

View File

@@ -15,7 +15,7 @@ pub struct PublicKey {
}
impl PublicKey {
/// Generates a public key.
/// Generate a public key.
///
/// # Example
///
@@ -33,7 +33,7 @@ impl PublicKey {
ShortintEngine::with_thread_local_mut(|engine| engine.new_public_key(client_key).unwrap())
}
/// Encrypts a small integer message using the client key.
/// Encrypt a small integer message using the client key.
///
/// The input message is reduced to the encrypted message space modulus
///
@@ -73,7 +73,7 @@ impl PublicKey {
})
}
/// Encrypts a small integer message using the client key with a specific message modulus
/// Encrypt a small integer message using the client key with a specific message modulus
///
/// # Example
///
@@ -107,7 +107,7 @@ impl PublicKey {
})
}
/// Encrypts an integer without reducing the input message modulus the message space
/// Encrypt an integer without reducing the input message modulus the message space
///
/// # Example
///
@@ -137,7 +137,7 @@ impl PublicKey {
})
}
/// Encrypts a small integer message using the client key without padding bit.
/// Encrypt a small integer message using the client key without padding bit.
///
/// The input message is reduced to the encrypted message space modulus
///
@@ -167,7 +167,7 @@ impl PublicKey {
})
}
/// Encrypts a small integer message using the client key without padding bit with some modulus.
/// Encrypt a small integer message using the client key without padding bit with some modulus.
///
/// The input message is reduced to the encrypted message space modulus
///

View File

@@ -5,7 +5,7 @@ use crate::shortint::server_key::CheckError::CarryFull;
use crate::shortint::Ciphertext;
impl ServerKey {
/// Computes homomorphically an addition between two ciphertexts encrypting integer values.
/// Compute homomorphically an addition between two ciphertexts encrypting integer values.
///
/// The result is returned in a _new_ ciphertext.
///
@@ -39,7 +39,7 @@ impl ServerKey {
})
}
/// Computes homomorphically an addition between two ciphertexts encrypting integer values.
/// Compute homomorphically an addition between two ciphertexts encrypting integer values.
///
/// The result is _stored_ in the `ct_left` ciphertext.
///
@@ -73,7 +73,7 @@ impl ServerKey {
})
}
/// Verifies if ct_left and ct_right can be added together.
/// Verify if ct_left and ct_right can be added together.
///
/// This checks that the sum of their degree is
/// smaller than the maximum degree.
@@ -103,7 +103,7 @@ impl ServerKey {
final_operation_count <= self.max_degree.0
}
/// Computes homomorphically an addition between two ciphertexts encrypting integer values.
/// Compute homomorphically an addition between two ciphertexts encrypting integer values.
///
/// If the operation can be performed, the result is returned a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -145,7 +145,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an addition between two ciphertexts encrypting integer values.
/// Compute homomorphically an addition between two ciphertexts encrypting integer values.
///
/// If the operation can be performed, the result is stored in the `ct_left` ciphertext.
/// Otherwise [CheckError::CarryFull] is returned, and `ct_left` is not modified.
@@ -186,7 +186,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an addition between two ciphertexts encrypting integer values.
/// Compute homomorphically an addition between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -218,7 +218,7 @@ impl ServerKey {
})
}
/// Computes homomorphically an addition between two ciphertexts
/// Compute homomorphically an addition between two ciphertexts
///
/// The result is stored in the `ct_left` cipher text.
///

View File

@@ -147,7 +147,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an AND between two ciphertexts encrypting integer values.
/// Compute homomorphically an AND between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -179,7 +179,7 @@ impl ServerKey {
})
}
/// Computes homomorphically an AND between two ciphertexts encrypting integer values.
/// Compute homomorphically an AND between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -362,7 +362,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an XOR between two ciphertexts encrypting integer values.
/// Compute homomorphically an XOR between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -394,7 +394,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a XOR between two ciphertexts encrypting integer values.
/// Compute homomorphically a XOR between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -579,7 +579,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an OR between two ciphertexts encrypting integer values.
/// Compute homomorphically an OR between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -611,7 +611,7 @@ impl ServerKey {
})
}
/// Computes homomorphically an OR between two ciphertexts encrypting integer values.
/// Compute homomorphically an OR between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.

View File

@@ -11,7 +11,7 @@ use crate::shortint::Ciphertext;
// ">=" is greater of equal, not greater_assign.
impl ServerKey {
/// Implements the "greater" (`>`) operator between two ciphertexts without checks.
/// Implement the "greater" (`>`) operator between two ciphertexts without checks.
///
/// # Example
///
@@ -40,7 +40,7 @@ impl ServerKey {
})
}
/// Implements the "greater" (`>`) operator between two ciphertexts with checks.
/// Implement the "greater" (`>`) operator between two ciphertexts with checks.
///
/// If the operation can be performed, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -80,7 +80,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a `>` between two ciphertexts encrypting integer values.
/// Compute homomorphically a `>` between two ciphertexts encrypting integer values.
///
/// This checks that the operation is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -112,7 +112,7 @@ impl ServerKey {
})
}
/// Implements the "greater or equal" (`>=`) operator between two ciphertexts without checks.
/// Implement the "greater or equal" (`>=`) operator between two ciphertexts without checks.
///
/// # Example
///
@@ -147,7 +147,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a `>=` between two ciphertexts encrypting integer values.
/// Compute homomorphically a `>=` between two ciphertexts encrypting integer values.
///
/// This checks that the operation is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -185,7 +185,7 @@ impl ServerKey {
})
}
/// Implements the "greater or equal" (`>=`) operator between two ciphertexts with checks.
/// Implement the "greater or equal" (`>=`) operator between two ciphertexts with checks.
///
/// If the operation can be performed, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -225,7 +225,7 @@ impl ServerKey {
}
}
/// Implements the "less" (`<`) operator between two ciphertexts without checks.
/// Implement the "less" (`<`) operator between two ciphertexts without checks.
///
/// # Example
///
@@ -255,7 +255,7 @@ impl ServerKey {
})
}
/// Implements the "less" (`<`) operator between two ciphertexts with checks.
/// Implement the "less" (`<`) operator between two ciphertexts with checks.
///
/// If the operation can be performed, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -295,7 +295,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a `<` between two ciphertexts encrypting integer values.
/// Compute homomorphically a `<` between two ciphertexts encrypting integer values.
///
/// This checks that the operation is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -327,7 +327,7 @@ impl ServerKey {
})
}
/// Implements the "less or equal" (`<=`) between two ciphertexts operator without checks.
/// Implement the "less or equal" (`<=`) between two ciphertexts operator without checks.
///
/// # Example
///
@@ -362,7 +362,7 @@ impl ServerKey {
})
}
/// Implements the "less or equal" (`<=`) operator between two ciphertexts with checks.
/// Implement the "less or equal" (`<=`) operator between two ciphertexts with checks.
///
/// If the operation can be performed, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -402,7 +402,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a `<=` between two ciphertexts encrypting integer values.
/// Compute homomorphically a `<=` between two ciphertexts encrypting integer values.
///
/// This checks that the operation is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -438,7 +438,7 @@ impl ServerKey {
})
}
/// Implements the "equal" operator (`==`) between two ciphertexts without checks.
/// Implement the "equal" operator (`==`) between two ciphertexts without checks.
///
/// # Example
///
@@ -467,7 +467,7 @@ impl ServerKey {
})
}
/// Implements the "equal" (`==`) operator between two ciphertexts with checks.
/// Implement the "equal" (`==`) operator between two ciphertexts with checks.
///
/// If the operation can be performed, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -507,7 +507,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a `==` between two ciphertexts encrypting integer values.
/// Compute homomorphically a `==` between two ciphertexts encrypting integer values.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -539,7 +539,7 @@ impl ServerKey {
})
}
/// Implements the "not equal" operator (`!=`) between two ciphertexts without checks.
/// Implement the "not equal" operator (`!=`) between two ciphertexts without checks.
///
/// # Example
///
@@ -568,7 +568,7 @@ impl ServerKey {
})
}
/// Implements the "not equal" (`!=`) operator between two ciphertexts with checks.
/// Implement the "not equal" (`!=`) operator between two ciphertexts with checks.
///
/// If the operation can be performed, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -608,7 +608,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a `!=` between two ciphertexts encrypting integer values.
/// Compute homomorphically a `!=` between two ciphertexts encrypting integer values.
///
/// This checks that the operation is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -644,7 +644,7 @@ impl ServerKey {
})
}
/// Implements the "equal" operator (`==`) between a ciphertext and a scalar without checks.
/// Implement the "equal" operator (`==`) between a ciphertext and a scalar without checks.
///
/// # Example
///
@@ -672,7 +672,7 @@ impl ServerKey {
})
}
/// Implements the "not equal" operator (`!=`) between a ciphertext and a scalar without checks.
/// Implement the "not equal" operator (`!=`) between a ciphertext and a scalar without checks.
///
/// # Example
///
@@ -702,7 +702,7 @@ impl ServerKey {
})
}
/// Implements the "greater or equal" operator (`>=`) between a ciphertext and a scalar without
/// Implement the "greater or equal" operator (`>=`) between a ciphertext and a scalar without
/// checks.
///
/// # Example
@@ -733,7 +733,7 @@ impl ServerKey {
})
}
/// Implements the "less or equal" operator (`<=`) between a ciphertext and a scalar without
/// Implement the "less or equal" operator (`<=`) between a ciphertext and a scalar without
/// checks.
///
/// # Example
@@ -764,7 +764,7 @@ impl ServerKey {
})
}
/// Implements the "greater" operator (`>`) between a ciphertext and a scalar without checks.
/// Implement the "greater" operator (`>`) between a ciphertext and a scalar without checks.
///
/// # Example
///
@@ -792,7 +792,7 @@ impl ServerKey {
})
}
/// Implements the "less" operator (`<`) between a ciphertext and a scalar without checks.
/// Implement the "less" operator (`<`) between a ciphertext and a scalar without checks.
///
/// # Example
///

View File

@@ -195,7 +195,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a modular reduction without checks.
/// Compute homomorphically a modular reduction without checks.
///
/// # Panics
///

View File

@@ -65,7 +65,7 @@ pub struct ServerKey {
}
impl ServerKey {
/// Generates a server key.
/// Generate a server key.
///
/// # Example
///
@@ -83,7 +83,7 @@ impl ServerKey {
ShortintEngine::with_thread_local_mut(|engine| engine.new_server_key(cks).unwrap())
}
/// Generates a server key with a chosen maximum degree
/// Generate a server key with a chosen maximum degree
pub fn new_with_max_degree(cks: &ClientKey, max_degree: MaxDegree) -> ServerKey {
ShortintEngine::with_thread_local_mut(|engine| {
engine
@@ -160,7 +160,7 @@ impl ServerKey {
})
}
/// Computes a keyswitch and a bootstrap, returning a new ciphertext with empty
/// Compute a keyswitch and a bootstrap, returning a new ciphertext with empty
/// carry bits.
///
/// # Example
@@ -216,7 +216,7 @@ impl ServerKey {
})
}
/// Computes a keyswitch and programmable bootstrap.
/// Compute a keyswitch and programmable bootstrap.
///
/// # Example
///
@@ -266,7 +266,7 @@ impl ServerKey {
})
}
/// Computes a keyswitch and programmable bootstrap.
/// Compute a keyswitch and programmable bootstrap.
///
/// # Example
///
@@ -347,7 +347,7 @@ impl ServerKey {
})
}
/// Verifies if a bivariate functional pbs can be applied on ct_left and ct_right.
/// Verify if a bivariate functional pbs can be applied on ct_left and ct_right.
pub fn is_functional_bivariate_pbs_possible(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> bool {
//product of the degree
let final_degree = ct1.degree.0 * (ct2.degree.0 + 1) + ct2.degree.0;
@@ -393,7 +393,7 @@ impl ServerKey {
})
}
/// Extracts a new ciphertext encrypting the input carry buffer.
/// Extract a new ciphertext encrypting the input carry buffer.
///
/// # Example
///
@@ -469,7 +469,7 @@ impl ServerKey {
})
}
/// Extracts a new ciphertext containing only the message i.e., with a cleared carry buffer.
/// Extract a new ciphertext containing only the message i.e., with a cleared carry buffer.
///
/// # Example
///
@@ -506,7 +506,7 @@ impl ServerKey {
ShortintEngine::with_thread_local_mut(|engine| engine.message_extract(self, ct).unwrap())
}
/// Computes a trivial shortint from a given value.
/// Compute a trivial shortint from a given value.
///
/// # Example
///

View File

@@ -6,9 +6,9 @@ use crate::shortint::server_key::CheckError::CarryFull;
use crate::shortint::Ciphertext;
impl ServerKey {
/// Multiplies two ciphertexts together without checks.
/// Multiply two ciphertexts together without checks.
///
/// Returns the "least significant bits" of the multiplication, i.e., the result modulus the
/// Return the "least significant bits" of the multiplication, i.e., the result modulus the
/// message_modulus.
///
/// The result is returned in a _new_ ciphertext.
@@ -49,9 +49,9 @@ impl ServerKey {
})
}
/// Multiplies two ciphertexts together without checks.
/// Multiply two ciphertexts together without checks.
///
/// Returns the "least significant bits" of the multiplication, i.e., the result modulus the
/// Return the "least significant bits" of the multiplication, i.e., the result modulus the
/// message_modulus.
///
/// The result is _assigned_ in the first ciphertext
@@ -88,9 +88,9 @@ impl ServerKey {
})
}
/// Multiplies two ciphertexts together without checks.
/// Multiply two ciphertexts together without checks.
///
/// Returns the "most significant bits" of the multiplication, i.e., the part in the carry
/// Return the "most significant bits" of the multiplication, i.e., the part in the carry
/// buffer.
///
/// The result is returned in a _new_ ciphertext.
@@ -140,7 +140,7 @@ impl ServerKey {
})
}
/// Verifies if two ciphertexts can be multiplied together.
/// Verify if two ciphertexts can be multiplied together.
///
/// # Example
///
@@ -165,9 +165,9 @@ impl ServerKey {
self.is_functional_bivariate_pbs_possible(ct1, ct2)
}
/// Multiplies two ciphertexts together with checks.
/// Multiply two ciphertexts together with checks.
///
/// Returns the "least significant bits" of the multiplication, i.e., the result modulus the
/// Return the "least significant bits" of the multiplication, i.e., the result modulus the
/// message_modulus.
///
/// If the operation can be performed, a _new_ ciphertext with the result is returned.
@@ -208,9 +208,9 @@ impl ServerKey {
}
}
/// Multiplies two ciphertexts together with checks.
/// Multiply two ciphertexts together with checks.
///
/// Returns the "least significant bits" of the multiplication, i.e., the result modulus the
/// Return the "least significant bits" of the multiplication, i.e., the result modulus the
/// message_modulus.
///
/// If the operation can be performed, the result is assigned to the first ciphertext given
@@ -251,9 +251,9 @@ impl ServerKey {
}
}
/// Multiplies two ciphertexts together without checks.
/// Multiply two ciphertexts together without checks.
///
/// Returns the "most significant bits" of the multiplication, i.e., the part in the carry
/// Return the "most significant bits" of the multiplication, i.e., the part in the carry
/// buffer.
///
/// If the operation can be performed, a _new_ ciphertext with the result is returned.
@@ -363,7 +363,7 @@ impl ServerKey {
})
}
/// Verifies if two ciphertexts can be multiplied together in the case where the carry
/// Verify if two ciphertexts can be multiplied together in the case where the carry
/// modulus is smaller than the message modulus.
///
/// # Example
@@ -402,7 +402,7 @@ impl ServerKey {
b1 & b2
}
/// Computes homomorphically a multiplication between two ciphertexts encrypting integer values.
/// Compute homomorphically a multiplication between two ciphertexts encrypting integer values.
///
/// The operation is done using a small carry buffer.
///
@@ -449,9 +449,9 @@ impl ServerKey {
}
}
/// Multiplies two ciphertexts.
/// Multiply two ciphertexts.
///
/// Returns the "least significant bits" of the multiplication, i.e., the result modulus the
/// Return the "least significant bits" of the multiplication, i.e., the result modulus the
/// message_modulus.
///
/// The result is _assigned_ in the first ciphertext
@@ -497,7 +497,7 @@ impl ServerKey {
/// Multiply two ciphertexts together
///
/// Returns the "least significant bits" of the multiplication, i.e., the result modulus the
/// Return the "least significant bits" of the multiplication, i.e., the result modulus the
/// message_modulus.
///
/// # Example
@@ -542,7 +542,7 @@ impl ServerKey {
/// Multiply two ciphertexts together
///
/// Returns the "most significant bits" of the multiplication, i.e., the part in the carry
/// Return the "most significant bits" of the multiplication, i.e., the part in the carry
/// buffer.
///
/// # Example

View File

@@ -78,7 +78,7 @@ impl ServerKey {
})
}
/// Verifies if a ciphertext can be negated.
/// Verify if a ciphertext can be negated.
///
/// # Example
///
@@ -109,7 +109,7 @@ impl ServerKey {
counter <= self.max_degree.0
}
/// Computes homomorphically a negation of a ciphertext.
/// Compute homomorphically a negation of a ciphertext.
///
/// If the operation can be performed, the result is returned a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -145,7 +145,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a negation of a ciphertext.
/// Compute homomorphically a negation of a ciphertext.
///
/// If the operation is possible, the result is stored _in_ the input ciphertext.
/// Otherwise [CheckError::CarryFull] is returned and the ciphertext is not .
@@ -182,7 +182,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a negation of a ciphertext.
/// Compute homomorphically a negation of a ciphertext.
///
/// This checks that the negation is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.
@@ -211,7 +211,7 @@ impl ServerKey {
ShortintEngine::with_thread_local_mut(|engine| engine.smart_neg(self, ct).unwrap())
}
/// Computes homomorphically a negation of a ciphertext.
/// Compute homomorphically a negation of a ciphertext.
///
/// This checks that the addition is possible. In the case where the carry buffers are full,
/// then it is automatically cleared to allow the operation.

View File

@@ -5,7 +5,7 @@ use crate::shortint::server_key::CheckError::CarryFull;
use crate::shortint::Ciphertext;
impl ServerKey {
/// Computes homomorphically an addition between a ciphertext and a scalar.
/// Compute homomorphically an addition between a ciphertext and a scalar.
///
/// The result is returned in a _new_ ciphertext.
///
@@ -34,7 +34,7 @@ impl ServerKey {
})
}
/// Computes homomorphically an addition between a ciphertext and a scalar.
/// Compute homomorphically an addition between a ciphertext and a scalar.
///
/// The result it stored in the given ciphertext.
///
@@ -71,7 +71,7 @@ impl ServerKey {
})
}
/// Verifies if a scalar can be added to the ciphertext.
/// Verify if a scalar can be added to the ciphertext.
///
/// # Example
///
@@ -95,7 +95,7 @@ impl ServerKey {
final_degree <= self.max_degree.0
}
/// Computes homomorphically an addition between a ciphertext and a scalar.
/// Compute homomorphically an addition between a ciphertext and a scalar.
///
/// If the operation is possible, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -135,7 +135,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an addition between a ciphertext and a scalar.
/// Compute homomorphically an addition between a ciphertext and a scalar.
///
/// If the operation is possible, the result is stored _in_ the input ciphertext.
/// Otherwise [CheckError::CarryFull] is returned and the ciphertext is not modified.
@@ -173,7 +173,7 @@ impl ServerKey {
}
}
/// Computes homomorphically an addition between a ciphertext and a scalar.
/// Compute homomorphically an addition between a ciphertext and a scalar.
///
/// The result is returned in a _new_ ciphertext.
///
@@ -211,7 +211,7 @@ impl ServerKey {
})
}
/// Computes homomorphically an addition of a ciphertext by a scalar.
/// Compute homomorphically an addition of a ciphertext by a scalar.
///
/// The result is _stored_ in the `ct` ciphertext.
///

View File

@@ -5,7 +5,7 @@ use crate::shortint::server_key::CheckError::CarryFull;
use crate::shortint::Ciphertext;
impl ServerKey {
/// Computes homomorphically a multiplication of a ciphertext by a scalar.
/// Compute homomorphically a multiplication of a ciphertext by a scalar.
///
/// The result is returned in a _new_ ciphertext.
///
@@ -36,7 +36,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a multiplication of a ciphertext by a scalar.
/// Compute homomorphically a multiplication of a ciphertext by a scalar.
///
/// The result it stored in the given ciphertext.
///
@@ -67,7 +67,7 @@ impl ServerKey {
})
}
/// Verifies if the ciphertext can be multiplied by a scalar.
/// Verify if the ciphertext can be multiplied by a scalar.
///
/// # Example
///
@@ -92,7 +92,7 @@ impl ServerKey {
final_degree <= self.max_degree.0
}
/// Computes homomorphically a multiplication of a ciphertext by a scalar.
/// Compute homomorphically a multiplication of a ciphertext by a scalar.
///
/// If the operation is possible, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -135,7 +135,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a multiplication of a ciphertext by a scalar.
/// Compute homomorphically a multiplication of a ciphertext by a scalar.
///
/// If the operation is possible, the result is stored _in_ the input ciphertext.
/// Otherwise [CheckError::CarryFull] is returned and the ciphertext is not .
@@ -175,7 +175,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a multiplication of a ciphertext by a scalar.
/// Compute homomorphically a multiplication of a ciphertext by a scalar.
///
/// This checks that the multiplication is possible. In the case where the carry buffers are
/// full, then it is automatically cleared to allow the operation.
@@ -211,7 +211,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a multiplication of a ciphertext by a scalar.
/// Compute homomorphically a multiplication of a ciphertext by a scalar.
///
/// This checks that the multiplication is possible. In the case where the carry buffers are
/// full, then it is automatically cleared to allow the operation.

View File

@@ -5,7 +5,7 @@ use crate::shortint::server_key::CheckError::CarryFull;
use crate::shortint::Ciphertext;
impl ServerKey {
/// Computes homomorphically a subtraction of a ciphertext by a scalar.
/// Compute homomorphically a subtraction of a ciphertext by a scalar.
///
/// The result is returned in a _new_ ciphertext.
///
@@ -35,7 +35,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a subtraction of a ciphertext by a scalar.
/// Compute homomorphically a subtraction of a ciphertext by a scalar.
///
/// The result it stored in the given ciphertext.
///
@@ -64,7 +64,7 @@ impl ServerKey {
})
}
/// Verifies if a scalar can be subtracted to the ciphertext.
/// Verify if a scalar can be subtracted to the ciphertext.
///
/// # Example
///
@@ -88,7 +88,7 @@ impl ServerKey {
final_degree <= self.max_degree.0
}
/// Computes homomorphically a subtraction of a ciphertext by a scalar.
/// Compute homomorphically a subtraction of a ciphertext by a scalar.
///
/// If the operation is possible, the result is returned in a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -128,7 +128,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a subtraction of a ciphertext by a scalar.
/// Compute homomorphically a subtraction of a ciphertext by a scalar.
///
/// If the operation is possible, the result is stored _in_ the input ciphertext.
/// Otherwise [CheckError::CarryFull] is returned and the ciphertext is not modified.
@@ -166,7 +166,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a subtraction of a ciphertext by a scalar.
/// Compute homomorphically a subtraction of a ciphertext by a scalar.
///
/// The result is returned in a _new_ ciphertext.
///
@@ -203,7 +203,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a subtraction of a ciphertext by a scalar.
/// Compute homomorphically a subtraction of a ciphertext by a scalar.
///
/// The result is _stored_ in the `ct` ciphertext.
///

View File

@@ -5,7 +5,7 @@ use crate::shortint::server_key::CheckError::CarryFull;
use crate::shortint::Ciphertext;
impl ServerKey {
/// Computes homomorphically a right shift of the bits without checks.
/// Compute homomorphically a right shift of the bits without checks.
///
/// # Example
///
@@ -44,7 +44,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a right shift of the bits without checks.
/// Compute homomorphically a right shift of the bits without checks.
///
/// # Example
///
@@ -81,7 +81,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a left shift of the bits without checks.
/// Compute homomorphically a left shift of the bits without checks.
///
/// # Example
///
@@ -122,7 +122,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a left shift of the bits without checks
/// Compute homomorphically a left shift of the bits without checks
///
/// # Example
///
@@ -186,7 +186,7 @@ impl ServerKey {
final_operation_count <= self.max_degree.0
}
/// Computes homomorphically a left shift of the bits.
/// Compute homomorphically a left shift of the bits.
///
/// If the operation can be performed, a new ciphertext with the result is returned.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -256,7 +256,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a left shift of the bits
/// Compute homomorphically a left shift of the bits
///
/// This checks that the operation is possible. In the case where the carry buffers are
/// full, then it is automatically cleared to allow the operation.

View File

@@ -73,7 +73,7 @@ impl ServerKey {
})
}
/// Verifies if ct_right can be subtracted to ct_left.
/// Verify if ct_right can be subtracted to ct_left.
///
/// # Example
///
@@ -106,7 +106,7 @@ impl ServerKey {
final_operation_count <= self.max_degree.0
}
/// Computes homomorphically a subtraction between two ciphertexts encrypting integer values.
/// Compute homomorphically a subtraction between two ciphertexts encrypting integer values.
///
/// If the operation can be performed, the result is returned a _new_ ciphertext.
/// Otherwise [CheckError::CarryFull] is returned.
@@ -146,7 +146,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a subtraction between two ciphertexts.
/// Compute homomorphically a subtraction between two ciphertexts.
///
/// If the operation can be performed, the result is stored in the `ct_left` ciphertext.
/// Otherwise [CheckError::CarryFull] is returned, and `ct_left` is not modified.
@@ -186,7 +186,7 @@ impl ServerKey {
}
}
/// Computes homomorphically a subtraction between two ciphertexts.
/// Compute homomorphically a subtraction between two ciphertexts.
///
/// This checks that the subtraction is possible. In the case where the carry buffers are
/// full, then it is automatically cleared to allow the operation.
@@ -217,7 +217,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a subtraction between two ciphertexts.
/// Compute homomorphically a subtraction between two ciphertexts.
///
/// This checks that the subtraction is possible. In the case where the carry buffers are
/// full, then it is automatically cleared to allow the operation.
@@ -246,7 +246,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a subtraction between two ciphertexts without checks, and returns
/// Compute homomorphically a subtraction between two ciphertexts without checks, and returns
/// a correcting term.
///
/// This checks that the subtraction is possible. In the case where the carry buffers are
@@ -267,7 +267,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a subtraction between two ciphertexts without checks, and returns
/// Compute homomorphically a subtraction between two ciphertexts without checks, and returns
/// a correcting term.
///
/// # Warning
@@ -285,7 +285,7 @@ impl ServerKey {
})
}
/// Computes homomorphically a subtraction between two ciphertexts without checks, and returns
/// Compute homomorphically a subtraction between two ciphertexts without checks, and returns
/// a correcting term.
///
/// # Warning

View File

@@ -28,7 +28,7 @@ pub struct WopbsKey {
}
impl WopbsKey {
/// Generates the server key required to compute a WoPBS from the client and the server keys.
/// Generate the server key required to compute a WoPBS from the client and the server keys.
///
/// #Warning
/// Only when the classical PBS is not used in the circuit
@@ -51,7 +51,7 @@ impl WopbsKey {
})
}
/// Generates the server key required to compute a WoPBS from the client and the server keys.
/// Generate the server key required to compute a WoPBS from the client and the server keys.
/// # Example
///
/// ```rust
@@ -70,7 +70,7 @@ impl WopbsKey {
})
}
/// Generates the Look-Up Table homomorphically using the WoPBS approach.
/// Generate the Look-Up Table homomorphically using the WoPBS approach.
///
/// # Warning: this assumes one bit of padding.
///
@@ -110,7 +110,7 @@ impl WopbsKey {
vec_lut
}
/// Generates the Look-Up Table homomorphically using the WoPBS approach.
/// Generate the Look-Up Table homomorphically using the WoPBS approach.
///
/// # Warning: this assumes no bit of padding.
///
@@ -149,7 +149,7 @@ impl WopbsKey {
vec_lut
}
/// Generates the Look-Up Table homomorphically using the WoPBS approach.
/// Generate the Look-Up Table homomorphically using the WoPBS approach.
///
///
/// # Example
@@ -189,7 +189,7 @@ impl WopbsKey {
vec_lut
}
/// Applies the Look-Up Table homomorphically using the WoPBS approach.
/// Apply the Look-Up Table homomorphically using the WoPBS approach.
///
/// #Warning: this assumes one bit of padding.
///
@@ -227,7 +227,7 @@ impl WopbsKey {
})
}
/// Applies the Look-Up Table homomorphically using the WoPBS approach.
/// Apply the Look-Up Table homomorphically using the WoPBS approach.
///
/// #Warning: this assumes one bit of padding.
/// #Warning: to use in a WoPBS context ONLY (i.e., non compliant with classical PBS)
@@ -256,7 +256,7 @@ impl WopbsKey {
ShortintEngine::with_thread_local_mut(|engine| engine.wopbs(self, ct_in, lut).unwrap())
}
/// Applies the Look-Up Table homomorphically using the WoPBS approach.
/// Apply the Look-Up Table homomorphically using the WoPBS approach.
///
/// # Example
///
@@ -288,7 +288,7 @@ impl WopbsKey {
})
}
/// Applies the Look-Up Table homomorphically using the WoPBS approach.
/// Apply the Look-Up Table homomorphically using the WoPBS approach.
///
/// # Example
///
@@ -320,7 +320,7 @@ impl WopbsKey {
})
}
/// Extracts the given number of bits from a ciphertext.
/// Extract the given number of bits from a ciphertext.
///
/// # Warning Experimental
pub fn extract_bits(