PALISADE Lattice Crypto Library
1.11.9
A lattice crypto library for software engineers by software engineers.
|
The class for representing vectors of big binary integers. More...
#include <mubintvecfxd.h>
Public Member Functions | |
BigVectorImpl () | |
BigVectorImpl (usint length, const IntegerType &modulus=0) | |
BigVectorImpl (const BigVectorImpl &bigVector) | |
BigVectorImpl (BigVectorImpl &&bigVector) | |
BigVectorImpl (usint length, const IntegerType &modulus, std::initializer_list< std::string > rhs) | |
BigVectorImpl (usint length, const IntegerType &modulus, std::initializer_list< uint64_t > rhs) | |
virtual | ~BigVectorImpl () |
const BigVectorImpl & | operator= (const BigVectorImpl &rhs) |
const BigVectorImpl & | operator= (BigVectorImpl &&rhs) |
const BigVectorImpl & | operator= (std::initializer_list< std::string > rhs) |
const BigVectorImpl & | operator= (std::initializer_list< uint64_t > rhs) |
const BigVectorImpl & | operator= (uint64_t val) |
IntegerType & | at (size_t i) |
const IntegerType & | at (size_t i) const |
IntegerType & | operator[] (size_t idx) |
const IntegerType & | operator[] (size_t idx) const |
void | SetModulus (const IntegerType &value) |
void | SwitchModulus (const IntegerType &value) |
const IntegerType & | GetModulus () const |
size_t | GetLength () const |
BigVectorImpl | Mod (const IntegerType &modulus) const |
const BigVectorImpl & | ModEq (const IntegerType &modulus) |
BigVectorImpl | ModAdd (const IntegerType &b) const |
const BigVectorImpl & | ModAddEq (const IntegerType &b) |
BigVectorImpl | ModAddAtIndex (usint i, const IntegerType &b) const |
const BigVectorImpl & | ModAddAtIndexEq (usint i, const IntegerType &b) |
BigVectorImpl | ModAdd (const BigVectorImpl &b) const |
const BigVectorImpl & | ModAddEq (const BigVectorImpl &b) |
BigVectorImpl | ModSub (const IntegerType &b) const |
const BigVectorImpl & | ModSubEq (const IntegerType &b) |
BigVectorImpl | ModSub (const BigVectorImpl &b) const |
const BigVectorImpl & | ModSubEq (const BigVectorImpl &b) |
BigVectorImpl | ModMul (const IntegerType &b) const |
const BigVectorImpl & | ModMulEq (const IntegerType &b) |
BigVectorImpl | ModMul (const BigVectorImpl &b) const |
const BigVectorImpl & | ModMulEq (const BigVectorImpl &b) |
BigVectorImpl | ModExp (const IntegerType &b) const |
const BigVectorImpl & | ModExpEq (const IntegerType &b) |
BigVectorImpl | ModInverse () const |
const BigVectorImpl & | ModInverseEq () |
BigVectorImpl | ModByTwo () const |
const BigVectorImpl & | ModByTwoEq () |
BigVectorImpl | MultWithOutMod (const BigVectorImpl &b) const |
const BigVectorImpl & | MultWithOutModEq (const BigVectorImpl &b) |
BigVectorImpl | MultiplyAndRound (const IntegerType &p, const IntegerType &q) const |
const BigVectorImpl & | MultiplyAndRoundEq (const IntegerType &p, const IntegerType &q) |
BigVectorImpl | DivideAndRound (const IntegerType &q) const |
const BigVectorImpl & | DivideAndRoundEq (const IntegerType &q) |
BigVectorImpl | GetDigitAtIndexForBase (usint index, usint base) const |
template<class Archive > | |
std::enable_if<!cereal::traits::is_text_archive< Archive >::value, void >::type | save (Archive &ar, std::uint32_t const version) const |
template<class Archive > | |
std::enable_if< cereal::traits::is_text_archive< Archive >::value, void >::type | save (Archive &ar, std::uint32_t const version) const |
template<class Archive > | |
std::enable_if<!cereal::traits::is_text_archive< Archive >::value, void >::type | load (Archive &ar, std::uint32_t const version) |
template<class Archive > | |
std::enable_if< cereal::traits::is_text_archive< Archive >::value, void >::type | load (Archive &ar, std::uint32_t const version) |
std::string | SerializedObjectName () const |
Public Member Functions inherited from lbcrypto::BigVectorInterface< BigVectorImpl< IntegerType >, IntegerType > | |
const BigVectorImpl< IntegerType > & | operator= (const BigVectorImpl< IntegerType > &vec) |
const BigVectorImpl< IntegerType > & | operator= (BigVectorImpl< IntegerType > &&vec) |
const BigVectorImpl< IntegerType > & | operator= (std::initializer_list< std::string > strvec) |
const BigVectorImpl< IntegerType > & | operator= (std::initializer_list< uint64_t > vec) |
const BigVectorImpl< IntegerType > & | operator= (uint64_t val) |
IntegerType & | at (size_t idx) |
const IntegerType & | at (size_t idx) const |
IntegerType & | operator[] (size_t idx) |
const IntegerType & | operator[] (size_t idx) const |
void | SetModulus (const IntegerType &value) |
void | SwitchModulus (const IntegerType &value) |
const IntegerType & | GetModulus () const |
size_t | GetLength () const |
BigVectorImpl< IntegerType > | Mod (const IntegerType &modulus) const |
const BigVectorImpl< IntegerType > & | ModEq (const IntegerType &modulus) |
BigVectorImpl< IntegerType > | ModAdd (const IntegerType &b) const |
BigVectorImpl< IntegerType > | ModAdd (const BigVectorImpl< IntegerType > &b) const |
const BigVectorImpl< IntegerType > & | ModAddEq (const IntegerType &b) |
const BigVectorImpl< IntegerType > & | ModAddEq (const BigVectorImpl< IntegerType > &b) |
BigVectorImpl< IntegerType > | ModAddAtIndex (usint i, const IntegerType &b) const |
const BigVectorImpl< IntegerType > & | ModAddAtIndexEq (usint i, const IntegerType &b) |
BigVectorImpl< IntegerType > | ModSub (const IntegerType &b) const |
BigVectorImpl< IntegerType > | ModSub (const BigVectorImpl< IntegerType > &b) const |
const BigVectorImpl< IntegerType > & | ModSubEq (const IntegerType &b) |
const BigVectorImpl< IntegerType > & | ModSubEq (const BigVectorImpl< IntegerType > &b) |
BigVectorImpl< IntegerType > | ModMul (const IntegerType &b) const |
BigVectorImpl< IntegerType > | ModMul (const BigVectorImpl< IntegerType > &b) const |
const BigVectorImpl< IntegerType > & | ModMulEq (const IntegerType &b) |
const BigVectorImpl< IntegerType > & | ModMulEq (const BigVectorImpl< IntegerType > &b) |
BigVectorImpl< IntegerType > | ModExp (const IntegerType &b) const |
const BigVectorImpl< IntegerType > & | ModExpEq (const IntegerType &b) |
BigVectorImpl< IntegerType > | ModInverse () const |
const BigVectorImpl< IntegerType > & | ModInverseEq () |
BigVectorImpl< IntegerType > | ModByTwo () const |
const BigVectorImpl< IntegerType > & | ModByTwoEq () |
BigVectorImpl< IntegerType > | MultiplyAndRound (const IntegerType &p, const IntegerType &q) const |
const BigVectorImpl< IntegerType > & | MultiplyAndRoundEq (const IntegerType &p, const IntegerType &q) |
BigVectorImpl< IntegerType > | DivideAndRound (const IntegerType &q) const |
const BigVectorImpl< IntegerType > & | DivideAndRoundEq (const IntegerType &q) |
BigVectorImpl< IntegerType > | GetDigitAtIndexForBase (usint index, usint base) const |
Static Public Member Functions | |
static BigVectorImpl | Single (const IntegerType &val, const IntegerType &modulus) |
static uint32_t | SerializedVersion () |
Friends | |
template<class IntegerType_c > | |
std::ostream & | operator<< (std::ostream &os, const BigVectorImpl< IntegerType_c > &ptr_obj) |
Additional Inherited Members | |
Public Types inherited from lbcrypto::BigVectorInterface< BigVectorImpl< IntegerType >, IntegerType > | |
typedef IntegerType | Integer |
The class for representing vectors of big binary integers.
bigintfxd::BigVectorImpl< IntegerType >::BigVectorImpl | ( | ) |
Basic constructor.
|
explicit |
Basic constructor for specifying the length of the vector and the modulus.
length | is the length of the big binary vector, in terms of the number of entries. |
modulus | is the modulus of the ring. |
bigintfxd::BigVectorImpl< IntegerType >::BigVectorImpl | ( | const BigVectorImpl< IntegerType > & | bigVector | ) |
Basic constructor for copying a vector
bigVector | is the big binary vector to be copied. |
bigintfxd::BigVectorImpl< IntegerType >::BigVectorImpl | ( | BigVectorImpl< IntegerType > && | bigVector | ) |
Basic move constructor for moving a vector
&&bigVector | is the big binary vector to be moved. |
bigintfxd::BigVectorImpl< IntegerType >::BigVectorImpl | ( | usint | length, |
const IntegerType & | modulus, | ||
std::initializer_list< std::string > | rhs | ||
) |
Basic constructor for specifying the length of the vector the modulus and an initializer list.
length | is the length of the big binary vector, in terms of the number of entries. |
modulus | is the modulus of the ring. |
rhs | is an initializer list of strings |
bigintfxd::BigVectorImpl< IntegerType >::BigVectorImpl | ( | usint | length, |
const IntegerType & | modulus, | ||
std::initializer_list< uint64_t > | rhs | ||
) |
Basic constructor for specifying the length of the vector the modulus and an initializer list.
length | is the length of the big binary vector, in terms of the number of entries. |
modulus | is the modulus of the ring. |
rhs | is an initializer list of usint |
|
virtual |
Destructor.
|
inline |
Sets/gets a value at an index. This method is slower than operator[] as it checks if index out of range
index | is the index to set a value at. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::DivideAndRound | ( | const IntegerType & | q | ) | const |
Divide and Rounding operation. Returns [x/q] where [] is the rounding operation.
&q | is the denominator to be divided. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::DivideAndRoundEq | ( | const IntegerType & | q | ) |
Divide and Rounding operation. Returns [x/q] where [] is the rounding operation. In-place variant.
&q | is the denominator to be divided. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::GetDigitAtIndexForBase | ( | usint | index, |
usint | base | ||
) | const |
Digit vector at a specific index for all entries for a given number base. Warning: only power-of-2 bases are currently supported. Example: for vector (83, 1, 45), index 2 and base 4 we have:
index:0,1,2,3
|83| |3,0,1,1| |1| |1 | –base 4 decomposition–> |1,0,0,0| –at index 2–> |0| |45| |1,3,2,0| |2|
The return vector is (1,0,2)
index | is the index to return the digit from in all entries. |
base | is the base to use for the operation. |
|
inline |
Gets the vector length.
|
inline |
Gets the vector modulus.
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::Mod | ( | const IntegerType & | modulus | ) | const |
Vector modulus operator.
&modulus | is the modulus to perform on the current vector entries. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModAdd | ( | const IntegerType & | b | ) | const |
Scalar-to-vector modulus addition operation.
&b | is the scalar to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModAdd | ( | const BigVectorImpl< IntegerType > & | b | ) | const |
Vector component wise modulus addition.
&b | is the vector to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModAddAtIndex | ( | usint | i, |
const IntegerType & | b | ||
) | const |
Scalar modulus addition at a particular index.
i | is the index of the entry to add. |
&b | is the scalar to add. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModAddAtIndexEq | ( | usint | i, |
const IntegerType & | b | ||
) |
Scalar modulus addition at a particular index. In-place variant.
i | is the index of the entry to add. |
&b | is the scalar to add. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModAddEq | ( | const IntegerType & | b | ) |
Scalar-to-vector modulus addition operation. In-place variant.
&b | is the scalar to perform operation with. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModAddEq | ( | const BigVectorImpl< IntegerType > & | b | ) |
Vector component wise modulus addition. In-place variant.
&b | is the vector to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModByTwo | ( | ) | const |
Modulus 2 operation, also a least significant bit.
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModByTwoEq | ( | ) |
Modulus 2 operation, also a least significant bit. In-place variant.
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModEq | ( | const IntegerType & | modulus | ) |
Vector modulus operator. In-place variant.
&modulus | is the modulus to perform on the current vector entries. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModExp | ( | const IntegerType & | b | ) | const |
Scalar modulus exponentiation operation.
&b | is the scalar to perform operation with. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModExpEq | ( | const IntegerType & | b | ) |
Scalar modulus exponentiation operation. In-place variant.
&b | is the scalar to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModInverse | ( | ) | const |
Modulus inverse operation.
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModInverseEq | ( | ) |
Modulus inverse operation. In-place variant.
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModMul | ( | const IntegerType & | b | ) | const |
Scalar-to-vector modulus multiplication operation. Generalized Barrett modulo reduction algorithm.
&b | is the scalar to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModMul | ( | const BigVectorImpl< IntegerType > & | b | ) | const |
Vector component wise modulus multiplication.
&b | is the vector to perform operation with. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModMulEq | ( | const IntegerType & | b | ) |
Scalar-to-vector modulus multiplication operation. In-place variant. Generalized Barrett modulo reduction algorithm.
&b | is the scalar to perform operation with. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModMulEq | ( | const BigVectorImpl< IntegerType > & | b | ) |
Vector component wise modulus multiplication. In-place variant.
&b | is the vector to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModSub | ( | const IntegerType & | b | ) | const |
Scalar-from-vector modulus subtraction operation.
&b | is the scalar to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::ModSub | ( | const BigVectorImpl< IntegerType > & | b | ) | const |
Vector component wise modulus subtraction.
&b | is the vector to perform operation with. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModSubEq | ( | const IntegerType & | b | ) |
Scalar-from-vector modulus subtraction operation. In-place variant.
&b | is the scalar to perform operation with. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::ModSubEq | ( | const BigVectorImpl< IntegerType > & | b | ) |
Vector component wise modulus subtraction. In-place variant.
&b | is the vector to perform operation with. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::MultiplyAndRound | ( | const IntegerType & | p, |
const IntegerType & | q | ||
) | const |
Multiply and Rounding operation. Returns [x*p/q] where [] is the rounding operation.
&p | is the numerator to be multiplied. |
&q | is the denominator to be divided. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::MultiplyAndRoundEq | ( | const IntegerType & | p, |
const IntegerType & | q | ||
) |
Multiply and Rounding operation. Returns [x*p/q] where [] is the rounding operation. In-place variant.
&p | is the numerator to be multiplied. |
&q | is the denominator to be divided. |
BigVectorImpl< IntegerType > bigintfxd::BigVectorImpl< IntegerType >::MultWithOutMod | ( | const BigVectorImpl< IntegerType > & | b | ) | const |
Vector multiplication without applying the modulus operation.
&b | is the vector to multiply. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::MultWithOutModEq | ( | const BigVectorImpl< IntegerType > & | b | ) |
Vector multiplication without applying the modulus operation. In-place variant.
&b | is the vector to multiply. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::operator= | ( | const BigVectorImpl< IntegerType > & | rhs | ) |
Assignment operator to assign value from rhs
&rhs | is the big binary vector to be assigned from. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::operator= | ( | BigVectorImpl< IntegerType > && | rhs | ) |
Move assignment operator
&&rhs | is the big binary vector to be moved. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::operator= | ( | std::initializer_list< std::string > | rhs | ) |
Initializer list for BigVectorImpl.
&&rhs | is the list of strings containing integers to be assigned to the BBV. |
const BigVectorImpl< IntegerType > & bigintfxd::BigVectorImpl< IntegerType >::operator= | ( | std::initializer_list< uint64_t > | rhs | ) |
Initializer list for BigVectorImpl.
&&rhs | is the list of integers to be assigned to the BBV. |
|
inline |
Assignment operator to assign value val to first entry, 0 for the rest of entries.
val | is the value to be assigned at the first entry. |
|
inline |
operators to get a value at an index.
idx | is the index to get a value at. |
void bigintfxd::BigVectorImpl< IntegerType >::SetModulus | ( | const IntegerType & | value | ) |
Sets the vector modulus.
value | is the value to set. |
value | is the modulus value to set. |
void bigintfxd::BigVectorImpl< IntegerType >::SwitchModulus | ( | const IntegerType & | newModulus | ) |
Sets the vector modulus and changes the values to match the new modulus.
value | is the value to set. |
Switches the integers in the vector to values corresponding to the new modulus Algorithm: Integer i, Old Modulus om, New Modulus nm, delta = abs(om-nm): Case 1: om < nm if i > i > om/2 i' = i + delta Case 2: om > nm i
om/2 i' = i-delta
|
friend |
ostream operator to output vector values to console
os | is the std ostream object. |
&ptr_obj | is the BigVectorImpl object to be printed. |