From 9d9c407f7fcff12941e086c839930e82b2c5a58a Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Thu, 8 Dec 2022 10:00:13 +0100 Subject: [PATCH] chore(tfhe): update wording to use imperative form in docstrings --- tfhe/src/boolean/client_key/mod.rs | 6 +-- tfhe/src/boolean/engine/bootstrapping.rs | 4 +- tfhe/src/boolean/public_key/mod.rs | 4 +- .../lwe_bootstrap_key_conversion.rs | 2 +- .../lwe_programmable_bootstrapping.rs | 4 +- .../algorithms/polynomial_algorithms.rs | 24 +++++----- .../algorithms/slice_algorithms.rs | 18 +++---- tfhe/src/core_crypto/commons/dispersion.rs | 6 +-- .../commons/generators/encryption.rs | 4 +- .../core_crypto/commons/generators/secret.rs | 4 +- .../commons/math/decomposition/decomposer.rs | 10 ++-- .../commons/math/decomposition/iter.rs | 4 +- .../commons/math/decomposition/term.rs | 6 +-- .../commons/math/decomposition/tests.rs | 2 +- .../commons/math/random/generator.rs | 26 +++++----- .../core_crypto/commons/math/random/tests.rs | 4 +- .../src/core_crypto/commons/math/torus/mod.rs | 4 +- tfhe/src/core_crypto/commons/mod.rs | 14 +++--- tfhe/src/core_crypto/commons/numeric/float.rs | 16 +++---- .../src/core_crypto/commons/numeric/signed.rs | 4 +- .../core_crypto/commons/numeric/unsigned.rs | 4 +- tfhe/src/core_crypto/commons/parameters.rs | 12 ++--- tfhe/src/core_crypto/commons/utils.rs | 2 +- .../core_crypto/entities/ggsw_ciphertext.rs | 24 +++++----- .../entities/ggsw_ciphertext_list.rs | 12 ++--- .../core_crypto/entities/glwe_ciphertext.rs | 30 ++++++------ .../entities/glwe_ciphertext_list.rs | 8 ++-- .../core_crypto/entities/glwe_secret_key.rs | 2 +- .../core_crypto/entities/lwe_bootstrap_key.rs | 2 +- .../core_crypto/entities/lwe_ciphertext.rs | 2 +- .../entities/lwe_ciphertext_list.rs | 2 +- .../core_crypto/entities/lwe_keyswitch_key.rs | 2 +- ...rivate_functional_packing_keyswitch_key.rs | 2 +- ...e_functional_packing_keyswitch_key_list.rs | 2 +- .../core_crypto/entities/lwe_public_key.rs | 2 +- .../core_crypto/entities/lwe_secret_key.rs | 2 +- .../core_crypto/entities/plaintext_list.rs | 2 +- tfhe/src/core_crypto/entities/polynomial.rs | 2 +- .../core_crypto/entities/polynomial_list.rs | 2 +- .../core_crypto/fft_impl/crypto/bootstrap.rs | 10 ++-- tfhe/src/core_crypto/fft_impl/crypto/ggsw.rs | 14 +++--- .../fft_impl/crypto/wop_pbs/mod.rs | 2 +- tfhe/src/core_crypto/fft_impl/math/fft/mod.rs | 20 ++++---- tfhe/src/core_crypto/fft_impl/math/fft/x86.rs | 12 ++--- tfhe/src/shortint/client_key/mod.rs | 22 ++++----- tfhe/src/shortint/engine/mod.rs | 4 +- tfhe/src/shortint/public_key/mod.rs | 12 ++--- tfhe/src/shortint/server_key/add.rs | 14 +++--- tfhe/src/shortint/server_key/bitwise_op.rs | 12 ++--- tfhe/src/shortint/server_key/comp_op.rs | 48 +++++++++---------- tfhe/src/shortint/server_key/div_mod.rs | 2 +- tfhe/src/shortint/server_key/mod.rs | 18 +++---- tfhe/src/shortint/server_key/mul.rs | 38 +++++++-------- tfhe/src/shortint/server_key/neg.rs | 10 ++-- tfhe/src/shortint/server_key/scalar_add.rs | 14 +++--- tfhe/src/shortint/server_key/scalar_mul.rs | 14 +++--- tfhe/src/shortint/server_key/scalar_sub.rs | 14 +++--- tfhe/src/shortint/server_key/shift.rs | 12 ++--- tfhe/src/shortint/server_key/sub.rs | 16 +++---- tfhe/src/shortint/wopbs/mod.rs | 20 ++++---- 60 files changed, 305 insertions(+), 305 deletions(-) diff --git a/tfhe/src/boolean/client_key/mod.rs b/tfhe/src/boolean/client_key/mod.rs index 183ec56d4..32daee3d8 100644 --- a/tfhe/src/boolean/client_key/mod.rs +++ b/tfhe/src/boolean/client_key/mod.rs @@ -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 /// diff --git a/tfhe/src/boolean/engine/bootstrapping.rs b/tfhe/src/boolean/engine/bootstrapping.rs index b217e679f..3090cf5e8 100644 --- a/tfhe/src/boolean/engine/bootstrapping.rs +++ b/tfhe/src/boolean/engine/bootstrapping.rs @@ -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, } -/// 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 diff --git a/tfhe/src/boolean/public_key/mod.rs b/tfhe/src/boolean/public_key/mod.rs index 1049c69b4..5f5a2ffb0 100644 --- a/tfhe/src/boolean/public_key/mod.rs +++ b/tfhe/src/boolean/public_key/mod.rs @@ -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 /// diff --git a/tfhe/src/core_crypto/algorithms/lwe_bootstrap_key_conversion.rs b/tfhe/src/core_crypto/algorithms/lwe_bootstrap_key_conversion.rs index 4f4d2a92f..fc988258b 100644 --- a/tfhe/src/core_crypto/algorithms/lwe_bootstrap_key_conversion.rs +++ b/tfhe/src/core_crypto/algorithms/lwe_bootstrap_key_conversion.rs @@ -21,7 +21,7 @@ pub fn convert_standard_lwe_bootstrap_key_to_fourier, ) -> Result { diff --git a/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping.rs b/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping.rs index ffcbdcb61..304b6ae38 100644 --- a/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping.rs +++ b/tfhe/src/core_crypto/algorithms/lwe_programmable_bootstrapping.rs @@ -57,7 +57,7 @@ pub fn blind_rotate_assign_mem_optimized .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( 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( glwe_size: GlweSize, polynomial_size: PolynomialSize, diff --git a/tfhe/src/core_crypto/algorithms/polynomial_algorithms.rs b/tfhe/src/core_crypto/algorithms/polynomial_algorithms.rs index 10b2da83e..088099441 100644 --- a/tfhe/src/core_crypto/algorithms/polynomial_algorithms.rs +++ b/tfhe/src/core_crypto/algorithms/polynomial_algorithms.rs @@ -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( 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( .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( .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( 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::(poly_1.as_mut()); let poly_1 = poly_1; diff --git a/tfhe/src/core_crypto/algorithms/slice_algorithms.rs b/tfhe/src/core_crypto/algorithms/slice_algorithms.rs index 6d664f96f..eddbede29 100644 --- a/tfhe/src/core_crypto/algorithms/slice_algorithms.rs +++ b/tfhe/src/core_crypto/algorithms/slice_algorithms.rs @@ -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( .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( .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 /// diff --git a/tfhe/src/core_crypto/commons/dispersion.rs b/tfhe/src/core_crypto/commons/dispersion.rs index 6768fccb2..2c017fa0f 100644 --- a/tfhe/src/core_crypto/commons/dispersion.rs +++ b/tfhe/src/core_crypto/commons/dispersion.rs @@ -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}$. diff --git a/tfhe/src/core_crypto/commons/generators/encryption.rs b/tfhe/src/core_crypto/commons/generators/encryption.rs index 8a753cf8c..8af0c73a3 100644 --- a/tfhe/src/core_crypto/commons/generators/encryption.rs +++ b/tfhe/src/core_crypto/commons/generators/encryption.rs @@ -21,7 +21,7 @@ pub struct EncryptionRandomGenerator { } impl EncryptionRandomGenerator { - /// 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 to be passed. pub fn new(seed: Seed, seeder: &mut S) -> EncryptionRandomGenerator { @@ -38,7 +38,7 @@ impl EncryptionRandomGenerator { 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 { self.mask.remaining_bytes() } diff --git a/tfhe/src/core_crypto/commons/generators/secret.rs b/tfhe/src/core_crypto/commons/generators/secret.rs index c31331c5d..3b3c46dfd 100644 --- a/tfhe/src/core_crypto/commons/generators/secret.rs +++ b/tfhe/src/core_crypto/commons/generators/secret.rs @@ -6,12 +6,12 @@ use crate::core_crypto::commons::math::random::{ pub struct SecretRandomGenerator(RandomGenerator); impl SecretRandomGenerator { - /// 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 { 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 { self.0.remaining_bytes() } diff --git a/tfhe/src/core_crypto/commons/math/decomposition/decomposer.rs b/tfhe/src/core_crypto/commons/math/decomposition/decomposer.rs index 8ae73ecae..16f9b4b30 100644 --- a/tfhe/src/core_crypto/commons/math/decomposition/decomposer.rs +++ b/tfhe/src/core_crypto/commons/math/decomposition/decomposer.rs @@ -20,7 +20,7 @@ impl SignedDecomposer 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 /// diff --git a/tfhe/src/core_crypto/commons/math/decomposition/iter.rs b/tfhe/src/core_crypto/commons/math/decomposition/iter.rs index e9dd93c10..e5d91fa23 100644 --- a/tfhe/src/core_crypto/commons/math/decomposition/iter.rs +++ b/tfhe/src/core_crypto/commons/math/decomposition/iter.rs @@ -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$. /// diff --git a/tfhe/src/core_crypto/commons/math/decomposition/term.rs b/tfhe/src/core_crypto/commons/math/decomposition/term.rs index fca6a662d..d031f2047 100644 --- a/tfhe/src/core_crypto/commons/math/decomposition/term.rs +++ b/tfhe/src/core_crypto/commons/math/decomposition/term.rs @@ -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$. /// diff --git a/tfhe/src/core_crypto/commons/math/decomposition/tests.rs b/tfhe/src/core_crypto/commons/math/decomposition/tests.rs index 4aa63a930..20aa8722b 100644 --- a/tfhe/src/core_crypto/commons/math/decomposition/tests.rs +++ b/tfhe/src/core_crypto/commons/math/decomposition/tests.rs @@ -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() -> SignedDecomposer { let mut base_log; let mut level_count; diff --git a/tfhe/src/core_crypto/commons/math/random/generator.rs b/tfhe/src/core_crypto/commons/math/random/generator.rs index 8a4e62463..9ca6def58 100644 --- a/tfhe/src/core_crypto/commons/math/random/generator.rs +++ b/tfhe/src/core_crypto/commons/math/random/generator.rs @@ -78,7 +78,7 @@ impl RandomGenerator { 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 RandomGenerator { 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 RandomGenerator { .map(|iter| iter.map(Self)) } - /// Generates a random uniform unsigned integer. + /// Generate a random uniform unsigned integer. /// /// # Example /// @@ -158,7 +158,7 @@ impl RandomGenerator { 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 RandomGenerator { Scalar::fill_slice(self, Uniform, output); } - /// Generates a random uniform binary value. + /// Generate a random uniform binary value. /// /// # Example /// @@ -192,7 +192,7 @@ impl RandomGenerator { 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 RandomGenerator { Scalar::fill_slice(self, UniformBinary, output); } - /// Generates a random uniform ternary value. + /// Generate a random uniform ternary value. /// /// # Example /// @@ -226,7 +226,7 @@ impl RandomGenerator { 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 RandomGenerator { 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 RandomGenerator { 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 RandomGenerator { 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 RandomGenerator { <(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 RandomGenerator { }); } - /// Adds a random gaussian value to each element in a slice. + /// Add a random gaussian value to each element in a slice. /// /// # Example /// diff --git a/tfhe/src/core_crypto/commons/math/random/tests.rs b/tfhe/src/core_crypto/commons/math/random/tests.rs index 25ead9fd4..5929bc3d1 100644 --- a/tfhe/src/core_crypto/commons/math/random/tests.rs +++ b/tfhe/src/core_crypto/commons/math/random/tests.rs @@ -11,7 +11,7 @@ fn test_normal_random() { 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() { 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); diff --git a/tfhe/src/core_crypto/commons/math/torus/mod.rs b/tfhe/src/core_crypto/commons/math/torus/mod.rs index 04057369f..2dc6f0e57 100644 --- a/tfhe/src/core_crypto/commons/math/torus/mod.rs +++ b/tfhe/src/core_crypto/commons/math/torus/mod.rs @@ -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; } diff --git a/tfhe/src/core_crypto/commons/mod.rs b/tfhe/src/core_crypto/commons/mod.rs index 3b7f8910d..ab1849823 100644 --- a/tfhe/src/core_crypto/commons/mod.rs +++ b/tfhe/src/core_crypto/commons/mod.rs @@ -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)) diff --git a/tfhe/src/core_crypto/commons/numeric/float.rs b/tfhe/src/core_crypto/commons/numeric/float.rs index 743cd77ac..9f2659129 100644 --- a/tfhe/src/core_crypto/commons/numeric/float.rs +++ b/tfhe/src/core_crypto/commons/numeric/float.rs @@ -18,15 +18,15 @@ pub trait FloatingPoint: + Sub + SubAssign { - /// 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; } diff --git a/tfhe/src/core_crypto/commons/numeric/signed.rs b/tfhe/src/core_crypto/commons/numeric/signed.rs index e134724ca..72ec4b29f 100644 --- a/tfhe/src/core_crypto/commons/numeric/signed.rs +++ b/tfhe/src/core_crypto/commons/numeric/signed.rs @@ -35,10 +35,10 @@ pub trait SignedInteger: /// The unsigned type of the same precicion type Unsigned: UnsignedInteger + CastFrom; - /// 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; } diff --git a/tfhe/src/core_crypto/commons/numeric/unsigned.rs b/tfhe/src/core_crypto/commons/numeric/unsigned.rs index 1b78fa65a..5da9d2a23 100644 --- a/tfhe/src/core_crypto/commons/numeric/unsigned.rs +++ b/tfhe/src/core_crypto/commons/numeric/unsigned.rs @@ -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; } diff --git a/tfhe/src/core_crypto/commons/parameters.rs b/tfhe/src/core_crypto/commons/parameters.rs index 91e852c99..fcc56dd89 100644 --- a/tfhe/src/core_crypto/commons/parameters.rs +++ b/tfhe/src/core_crypto/commons/parameters.rs @@ -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) } diff --git a/tfhe/src/core_crypto/commons/utils.rs b/tfhe/src/core_crypto/commons/utils.rs index f7104bfd9..028a3c60f 100644 --- a/tfhe/src/core_crypto/commons/utils.rs +++ b/tfhe/src/core_crypto/commons/utils.rs @@ -7,7 +7,7 @@ fn assert_same_len(a: (usize, Option), b: (usize, Option)) { 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( diff --git a/tfhe/src/core_crypto/entities/ggsw_ciphertext.rs b/tfhe/src/core_crypto/entities/ggsw_ciphertext.rs index 7c99b58e9..7738408c2 100644 --- a/tfhe/src/core_crypto/entities/ggsw_ciphertext.rs +++ b/tfhe/src/core_crypto/entities/ggsw_ciphertext.rs @@ -174,7 +174,7 @@ impl> AsMut<[T]> for GgswCiphertext { } } -/// 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> GgswCiphertext { } } - /// 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> GgswCiphertext { 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> GgswCiphertext { ) } - /// 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 GgswLevelMatrix { 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(), diff --git a/tfhe/src/core_crypto/entities/ggsw_ciphertext_list.rs b/tfhe/src/core_crypto/entities/ggsw_ciphertext_list.rs index 8f6849aa4..d379f2580 100644 --- a/tfhe/src/core_crypto/entities/ggsw_ciphertext_list.rs +++ b/tfhe/src/core_crypto/entities/ggsw_ciphertext_list.rs @@ -104,35 +104,35 @@ impl> GgswCiphertextList { } } - /// 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> GgswCiphertextList { ) } - /// 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 { diff --git a/tfhe/src/core_crypto/entities/glwe_ciphertext.rs b/tfhe/src/core_crypto/entities/glwe_ciphertext.rs index a1c837b4d..f34c6b12d 100644 --- a/tfhe/src/core_crypto/entities/glwe_ciphertext.rs +++ b/tfhe/src/core_crypto/entities/glwe_ciphertext.rs @@ -33,14 +33,14 @@ impl GlweBody { 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 GlweMask { } } - /// 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> AsMut<[T]> for GlweBody { } } -/// 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> GlweCiphertext { } } - /// 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> GlweCiphertext { ) } - /// 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> GlweCiphertext { 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> GlweCiphertext { ) } - /// 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> GlweCiphertext { } } - /// Consumes the entity and return its underlying container. + /// Consume the entity and return its underlying container. pub fn into_container(self) -> C { self.data } diff --git a/tfhe/src/core_crypto/entities/glwe_ciphertext_list.rs b/tfhe/src/core_crypto/entities/glwe_ciphertext_list.rs index 65e92964a..6024b6f69 100644 --- a/tfhe/src/core_crypto/entities/glwe_ciphertext_list.rs +++ b/tfhe/src/core_crypto/entities/glwe_ciphertext_list.rs @@ -75,21 +75,21 @@ impl> GlweCiphertextList { } } - /// 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> GlweCiphertextList { ) } - /// 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 { diff --git a/tfhe/src/core_crypto/entities/glwe_secret_key.rs b/tfhe/src/core_crypto/entities/glwe_secret_key.rs index 9e56abca5..6eee86188 100644 --- a/tfhe/src/core_crypto/entities/glwe_secret_key.rs +++ b/tfhe/src/core_crypto/entities/glwe_secret_key.rs @@ -55,7 +55,7 @@ impl> GlweSecretKey { 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 } diff --git a/tfhe/src/core_crypto/entities/lwe_bootstrap_key.rs b/tfhe/src/core_crypto/entities/lwe_bootstrap_key.rs index 1f2a5b781..62a8e5397 100644 --- a/tfhe/src/core_crypto/entities/lwe_bootstrap_key.rs +++ b/tfhe/src/core_crypto/entities/lwe_bootstrap_key.rs @@ -50,7 +50,7 @@ impl> LweBootstrapKey { 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() } diff --git a/tfhe/src/core_crypto/entities/lwe_ciphertext.rs b/tfhe/src/core_crypto/entities/lwe_ciphertext.rs index 459427eeb..6d2f78b85 100644 --- a/tfhe/src/core_crypto/entities/lwe_ciphertext.rs +++ b/tfhe/src/core_crypto/entities/lwe_ciphertext.rs @@ -80,7 +80,7 @@ impl> LweCiphertext { 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 } diff --git a/tfhe/src/core_crypto/entities/lwe_ciphertext_list.rs b/tfhe/src/core_crypto/entities/lwe_ciphertext_list.rs index 1c08b7f3a..89b0ec07b 100644 --- a/tfhe/src/core_crypto/entities/lwe_ciphertext_list.rs +++ b/tfhe/src/core_crypto/entities/lwe_ciphertext_list.rs @@ -47,7 +47,7 @@ impl> LweCiphertextList { 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 } diff --git a/tfhe/src/core_crypto/entities/lwe_keyswitch_key.rs b/tfhe/src/core_crypto/entities/lwe_keyswitch_key.rs index be25c6806..f01b435fd 100644 --- a/tfhe/src/core_crypto/entities/lwe_keyswitch_key.rs +++ b/tfhe/src/core_crypto/entities/lwe_keyswitch_key.rs @@ -95,7 +95,7 @@ impl> LweKeyswitchKey { ) } - /// Consumes the entity and return its underlying container. + /// Consume the entity and return its underlying container. pub fn into_container(self) -> C { self.data } diff --git a/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key.rs b/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key.rs index 1f07adc99..4f5c89bbf 100644 --- a/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key.rs +++ b/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key.rs @@ -116,7 +116,7 @@ impl> 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 } diff --git a/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key_list.rs b/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key_list.rs index bfea65eeb..026028fb3 100644 --- a/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key_list.rs +++ b/tfhe/src/core_crypto/entities/lwe_private_functional_packing_keyswitch_key_list.rs @@ -134,7 +134,7 @@ impl> 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 } diff --git a/tfhe/src/core_crypto/entities/lwe_public_key.rs b/tfhe/src/core_crypto/entities/lwe_public_key.rs index d2ec29cb6..e57a0d2d9 100644 --- a/tfhe/src/core_crypto/entities/lwe_public_key.rs +++ b/tfhe/src/core_crypto/entities/lwe_public_key.rs @@ -38,7 +38,7 @@ impl> LwePublicKey { 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() } diff --git a/tfhe/src/core_crypto/entities/lwe_secret_key.rs b/tfhe/src/core_crypto/entities/lwe_secret_key.rs index d7f27f568..7f4a98661 100644 --- a/tfhe/src/core_crypto/entities/lwe_secret_key.rs +++ b/tfhe/src/core_crypto/entities/lwe_secret_key.rs @@ -31,7 +31,7 @@ impl> LweSecretKey { 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 } diff --git a/tfhe/src/core_crypto/entities/plaintext_list.rs b/tfhe/src/core_crypto/entities/plaintext_list.rs index 71548b72e..f095e0e94 100644 --- a/tfhe/src/core_crypto/entities/plaintext_list.rs +++ b/tfhe/src/core_crypto/entities/plaintext_list.rs @@ -32,7 +32,7 @@ impl> PlaintextList { 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 } diff --git a/tfhe/src/core_crypto/entities/polynomial.rs b/tfhe/src/core_crypto/entities/polynomial.rs index 1edced3f0..ce6ec747b 100644 --- a/tfhe/src/core_crypto/entities/polynomial.rs +++ b/tfhe/src/core_crypto/entities/polynomial.rs @@ -36,7 +36,7 @@ impl> Polynomial { 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 } diff --git a/tfhe/src/core_crypto/entities/polynomial_list.rs b/tfhe/src/core_crypto/entities/polynomial_list.rs index b20bc8775..166f16410 100644 --- a/tfhe/src/core_crypto/entities/polynomial_list.rs +++ b/tfhe/src/core_crypto/entities/polynomial_list.rs @@ -47,7 +47,7 @@ impl> PolynomialList { 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 } diff --git a/tfhe/src/core_crypto/fft_impl/crypto/bootstrap.rs b/tfhe/src/core_crypto/fft_impl/crypto/bootstrap.rs index 90a869a82..e769a1c22 100644 --- a/tfhe/src/core_crypto/fft_impl/crypto/bootstrap.rs +++ b/tfhe/src/core_crypto/fft_impl/crypto/bootstrap.rs @@ -59,7 +59,7 @@ impl> FourierLweBootstrapKey { } } - /// 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> where C: Split, @@ -168,13 +168,13 @@ impl FourierLweBootstrapKey> { } } -/// 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 { 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( 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( glwe_size: GlweSize, polynomial_size: PolynomialSize, @@ -200,7 +200,7 @@ pub fn blind_rotate_scratch( .try_and(cmux_scratch::(glwe_size, polynomial_size, fft)?) } -/// Returns the required memory for [`FourierLweBootstrapKeyView::bootstrap`]. +/// Return the required memory for [`FourierLweBootstrapKeyView::bootstrap`]. pub fn bootstrap_scratch( glwe_size: GlweSize, polynomial_size: PolynomialSize, diff --git a/tfhe/src/core_crypto/fft_impl/crypto/ggsw.rs b/tfhe/src/core_crypto/fft_impl/crypto/ggsw.rs index 06762cbfe..781eed899 100644 --- a/tfhe/src/core_crypto/fft_impl/crypto/ggsw.rs +++ b/tfhe/src/core_crypto/fft_impl/crypto/ggsw.rs @@ -157,7 +157,7 @@ impl> FourierGgswLevelMatrix { } } - /// 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> where C: Split, @@ -228,7 +228,7 @@ impl> FourierGgswLevelRow { } 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> { 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 { 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( 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( glwe_size: GlweSize, polynomial_size: PolynomialSize, @@ -302,7 +302,7 @@ pub fn add_external_product_assign_scratch( 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( 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( glwe_size: GlweSize, polynomial_size: PolynomialSize, diff --git a/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/mod.rs b/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/mod.rs index 601d8bc73..9cff35dfc 100644 --- a/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/mod.rs @@ -631,7 +631,7 @@ pub fn cmux_tree_memory_optimized_scratch( ]) } -/// 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>( mut output_glwe: GlweCiphertext<&mut [Scalar]>, diff --git a/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs index 93cc53a63..e086e4e91 100644 --- a/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs @@ -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(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( } 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 { 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 { 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 diff --git a/tfhe/src/core_crypto/fft_impl/math/fft/x86.rs b/tfhe/src/core_crypto/fft_impl/math/fft/x86.rs index 10aca687d..823e10282 100644 --- a/tfhe/src/core_crypto/fft_impl/math/fft/x86.rs +++ b/tfhe/src/core_crypto/fft_impl/math/fft/x86.rs @@ -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 . /// /// # 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. diff --git a/tfhe/src/shortint/client_key/mod.rs b/tfhe/src/shortint/client_key/mod.rs index 22ad2b1b4..de7af3eeb 100644 --- a/tfhe/src/shortint/client_key/mod.rs +++ b/tfhe/src/shortint/client_key/mod.rs @@ -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 diff --git a/tfhe/src/shortint/engine/mod.rs b/tfhe/src/shortint/engine/mod.rs index 89fbdfe2c..f5df11e01 100644 --- a/tfhe/src/shortint/engine/mod.rs +++ b/tfhe/src/shortint/engine/mod.rs @@ -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 /// diff --git a/tfhe/src/shortint/public_key/mod.rs b/tfhe/src/shortint/public_key/mod.rs index cfe7b59db..7da900319 100644 --- a/tfhe/src/shortint/public_key/mod.rs +++ b/tfhe/src/shortint/public_key/mod.rs @@ -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 /// diff --git a/tfhe/src/shortint/server_key/add.rs b/tfhe/src/shortint/server_key/add.rs index baab867f7..286890dbf 100644 --- a/tfhe/src/shortint/server_key/add.rs +++ b/tfhe/src/shortint/server_key/add.rs @@ -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. /// diff --git a/tfhe/src/shortint/server_key/bitwise_op.rs b/tfhe/src/shortint/server_key/bitwise_op.rs index d1e5a8ee2..20adcd77b 100644 --- a/tfhe/src/shortint/server_key/bitwise_op.rs +++ b/tfhe/src/shortint/server_key/bitwise_op.rs @@ -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. diff --git a/tfhe/src/shortint/server_key/comp_op.rs b/tfhe/src/shortint/server_key/comp_op.rs index 7e47d7880..36da4d969 100644 --- a/tfhe/src/shortint/server_key/comp_op.rs +++ b/tfhe/src/shortint/server_key/comp_op.rs @@ -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 /// diff --git a/tfhe/src/shortint/server_key/div_mod.rs b/tfhe/src/shortint/server_key/div_mod.rs index 2067d635d..fa0bc6706 100644 --- a/tfhe/src/shortint/server_key/div_mod.rs +++ b/tfhe/src/shortint/server_key/div_mod.rs @@ -195,7 +195,7 @@ impl ServerKey { }) } - /// Computes homomorphically a modular reduction without checks. + /// Compute homomorphically a modular reduction without checks. /// /// # Panics /// diff --git a/tfhe/src/shortint/server_key/mod.rs b/tfhe/src/shortint/server_key/mod.rs index dbf287c32..4fb9ed435 100644 --- a/tfhe/src/shortint/server_key/mod.rs +++ b/tfhe/src/shortint/server_key/mod.rs @@ -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 /// diff --git a/tfhe/src/shortint/server_key/mul.rs b/tfhe/src/shortint/server_key/mul.rs index 5de52d6f2..f5442e396 100644 --- a/tfhe/src/shortint/server_key/mul.rs +++ b/tfhe/src/shortint/server_key/mul.rs @@ -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 diff --git a/tfhe/src/shortint/server_key/neg.rs b/tfhe/src/shortint/server_key/neg.rs index 660a4dc90..dfb925c33 100644 --- a/tfhe/src/shortint/server_key/neg.rs +++ b/tfhe/src/shortint/server_key/neg.rs @@ -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. diff --git a/tfhe/src/shortint/server_key/scalar_add.rs b/tfhe/src/shortint/server_key/scalar_add.rs index 011a309b5..e04ae722d 100644 --- a/tfhe/src/shortint/server_key/scalar_add.rs +++ b/tfhe/src/shortint/server_key/scalar_add.rs @@ -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. /// diff --git a/tfhe/src/shortint/server_key/scalar_mul.rs b/tfhe/src/shortint/server_key/scalar_mul.rs index 23fe420fe..88d4c6460 100644 --- a/tfhe/src/shortint/server_key/scalar_mul.rs +++ b/tfhe/src/shortint/server_key/scalar_mul.rs @@ -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. diff --git a/tfhe/src/shortint/server_key/scalar_sub.rs b/tfhe/src/shortint/server_key/scalar_sub.rs index 0e278604a..b7e87838b 100644 --- a/tfhe/src/shortint/server_key/scalar_sub.rs +++ b/tfhe/src/shortint/server_key/scalar_sub.rs @@ -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. /// diff --git a/tfhe/src/shortint/server_key/shift.rs b/tfhe/src/shortint/server_key/shift.rs index 1c2751766..01dffa5d6 100644 --- a/tfhe/src/shortint/server_key/shift.rs +++ b/tfhe/src/shortint/server_key/shift.rs @@ -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. diff --git a/tfhe/src/shortint/server_key/sub.rs b/tfhe/src/shortint/server_key/sub.rs index aaab8420b..8b9467618 100644 --- a/tfhe/src/shortint/server_key/sub.rs +++ b/tfhe/src/shortint/server_key/sub.rs @@ -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 diff --git a/tfhe/src/shortint/wopbs/mod.rs b/tfhe/src/shortint/wopbs/mod.rs index 91aaef5b0..b4e353a01 100644 --- a/tfhe/src/shortint/wopbs/mod.rs +++ b/tfhe/src/shortint/wopbs/mod.rs @@ -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(