PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
Public Member Functions | Friends | List of all members
lbcrypto::BigIntegerInterface< T > Class Template Reference

Public Member Functions

void SetValue (const std::string &str)
 
Add (const T &b) const
 
const T & AddEq (const T &b)
 
Sub (const T &b) const
 
const T & SubEq (const T &b)
 
Mul (const T &b) const
 
const T & MulEq (const T &b)
 
DividedBy (const T &b) const
 
const T & DividedByEq (const T &b)
 
MultiplyAndRound (const T &p, const T &q) const
 
const T & MultiplyAndRoundEq (const T &p, const T &q)
 
DivideAndRound (const T &q) const
 
const T & DivideAndRoundEq (const T &q)
 
Mod (const T &modulus) const
 
const T & ModEq (const T &modulus)
 
ComputeMu () const
 
Mod (const T &modulus, const T &mu) const
 
const T & ModEq (const T &modulus, const T &mu)
 
ModAdd (const T &b, const T &modulus) const
 
const T & ModAddEq (const T &b, const T &modulus)
 
ModAddFast (const T &b, const T &modulus) const
 
const T & ModAddFastEq (const T &b, const T &modulus)
 
ModAdd (const T &b, const T &modulus, const T &mu) const
 
const T & ModAddEq (const T &b, const T &modulus, const T &mu)
 
ModSub (const T &b, const T &modulus) const
 
const T & ModSubEq (const T &b, const T &modulus)
 
ModSubFast (const T &b, const T &modulus) const
 
const T & ModSubFastEq (const T &b, const T &modulus)
 
ModSub (const T &b, const T &modulus, const T &mu) const
 
const T & ModSubEq (const T &b, const T &modulus, const T &mu)
 
ModMul (const T &b, const T &modulus) const
 
const T & ModMulEq (const T &b, const T &modulus)
 
ModMul (const T &b, const T &modulus, const T &mu) const
 
const T & ModMulEq (const T &b, const T &modulus, const T &mu)
 
ModMulFast (const T &b, const T &modulus) const
 
const T & ModMulFastEq (const T &b, const T &modulus)
 
ModMulFast (const T &b, const T &modulus, const T &mu) const
 
const T & ModMulFastEq (const T &b, const T &modulus, const T &mu)
 
ModMulFastConst (const T &b, const T &modulus, const T &bInv) const
 
const T & ModMulFastConstEq (const T &b, const T &modulus, const T &bInv)
 
ModExp (const T &b, const T &modulus) const
 
const T & ModExpEq (const T &b, const T &modulus)
 
ModInverse (const T &modulus) const
 
const T & ModInverseEq (const T &modulus)
 
LShift (usshort shift) const
 
const T & LShiftEq (usshort shift)
 
RShift (usshort shift) const
 
const T & RShiftEq (usshort shift)
 
int Compare (const T &a) const
 
uint64_t ConvertToInt () const
 
usint GetMSB () const
 
usint GetLengthForBase (usint base) const
 
usint GetDigitAtIndexForBase (usint index, usint base) const
 
const std::string ToString () const
 

Friends

operator+ (const T &a, const T &b)
 inline operators for the addition operation.
 
const T & operator+= (T &a, const T &b)
 
operator- (const T &a, const T &b)
 inline operators for the subtraction operation.
 
const T & operator-= (T &a, const T &b)
 
operator* (const T &a, const T &b)
 inline operators for the multiplication operation.
 
const T & operator*= (T &a, const T &b)
 
operator/ (const T &a, const T &b)
 inline operators for the division operation.
 
const T & operator/= (T &a, const T &b)
 
operator% (const T &a, const T &b)
 
const T & operator%= (T &a, const T &b)
 
operator<< (const T &a, usshort shift)
 inline operators for the left shift operations.
 
const T & operator<<= (T &a, usshort shift)
 
operator>> (const T &a, usshort shift)
 inline operators for the right shift operations.
 
const T & operator>>= (T &a, usshort shift)
 
bool operator== (const T &a, const T &b)
 
bool operator!= (const T &a, const T &b)
 
bool operator> (const T &a, const T &b)
 
bool operator>= (const T &a, const T &b)
 
bool operator< (const T &a, const T &b)
 
bool operator<= (const T &a, const T &b)
 

Member Function Documentation

◆ Add()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::Add ( const T &  b) const

Addition operation.

Parameters
&bis the value to add.
Returns
result of the addition operation.

◆ Compare()

template<typename T>
int lbcrypto::BigIntegerInterface< T >::Compare ( const T &  a) const

Compares the current BigInteger to BigInteger a.

Parameters
ais the BigInteger to be compared with.
Returns
-1 for strictly less than, 0 for equal to and 1 for strictly greater than conditons.

◆ ComputeMu()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ComputeMu ( ) const

Precomputes a parameter mu for Barrett modular reduction.

Returns
the precomputed parameter mu.

◆ ConvertToInt()

template<typename T>
uint64_t lbcrypto::BigIntegerInterface< T >::ConvertToInt ( ) const

Convert the value to an int.

Returns
the int representation of the value.

◆ DivideAndRound()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::DivideAndRound ( const T &  q) const

Divide and Rounding operation. Returns [x/q] where [] is the rounding operation.

Parameters
&qis the denominator to be divided.
Returns
is the result of divide and round operation.

◆ DivideAndRoundEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::DivideAndRoundEq ( const T &  q)

Divide and Rounding operation. Returns [x/q] where [] is the rounding operation. In-place variant.

Parameters
&qis the denominator to be divided.
Returns
is the result of divide and round operation.

◆ DividedBy()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::DividedBy ( const T &  b) const

Division operation.

Parameters
&bis the value to divide by.
Returns
is the result of the division operation.

◆ DividedByEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::DividedByEq ( const T &  b)

Division operation. In-place variant.

Parameters
&bis the value to divide by.
Returns
is the result of the division operation.

◆ GetDigitAtIndexForBase()

template<typename T>
usint lbcrypto::BigIntegerInterface< T >::GetDigitAtIndexForBase ( usint  index,
usint  base 
) const

Get the number of digits using a specific base - support for arbitrary base may be needed. Example: for number 83, index 2 and base 4 we have:

                    index:0,1,2,3

83 –base 4 decomposition–> (3,0,1,1) –at index 2–> 1

The return number is 1.

Parameters
indexis the location to return value from in the specific base.
baseis the base with which to determine length in.
Returns
the length of the representation in a specific base.

◆ GetLengthForBase()

template<typename T>
usint lbcrypto::BigIntegerInterface< T >::GetLengthForBase ( usint  base) const

Get the number of digits using a specific base - support for arbitrary base may be needed.

Parameters
baseis the base with which to determine length in.
Returns
the length of the representation in a specific base.

◆ GetMSB()

template<typename T>
usint lbcrypto::BigIntegerInterface< T >::GetMSB ( ) const

Returns the MSB location of the value.

Returns
the index of the most significant bit.

◆ LShift()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::LShift ( usshort  shift) const

Left shift operation.

Parameters
shift# of bits.
Returns
result of the shift operation.

◆ LShiftEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::LShiftEq ( usshort  shift)

Left shift operation. In-place variant.

Parameters
shift# of bits.
Returns
result of the shift operation.

◆ Mod() [1/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::Mod ( const T &  modulus) const

Naive modulus operation.

Parameters
&modulusis the modulus to perform.
Returns
is the result of the modulus operation.

◆ Mod() [2/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::Mod ( const T &  modulus,
const T &  mu 
) const

Barrett modulus operation. Implements generalized Barrett modular reduction algorithm. Uses one precomputed value of mu.

Parameters
&modulusis the modulus to perform.
&muis the Barrett value.
Returns
is the result of the modulus operation.

◆ ModAdd() [1/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModAdd ( const T &  b,
const T &  modulus 
) const

Modulus addition operation.

Parameters
&bis the scalar to add.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus addition operation.

◆ ModAdd() [2/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModAdd ( const T &  b,
const T &  modulus,
const T &  mu 
) const

Barrett modulus addition operation.

Parameters
&bis the scalar to add.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus addition operation.

◆ ModAddEq() [1/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModAddEq ( const T &  b,
const T &  modulus 
)

Modulus addition operation. In-place variant.

Parameters
&bis the scalar to add.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus addition operation.

◆ ModAddEq() [2/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModAddEq ( const T &  b,
const T &  modulus,
const T &  mu 
)

Barrett modulus addition operation. In-place variant.

Parameters
&bis the scalar to add.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus addition operation.

◆ ModAddFast()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModAddFast ( const T &  b,
const T &  modulus 
) const

Modulus addition where operands are < modulus.

Parameters
&bis the scalar to add.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus addition operation.

◆ ModAddFastEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModAddFastEq ( const T &  b,
const T &  modulus 
)

Modulus addition where operands are < modulus. In-place variant.

Parameters
&bis the scalar to add.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus addition operation.

◆ ModEq() [1/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModEq ( const T &  modulus)

Naive modulus operation. In-place variant.

Parameters
&modulusis the modulus to perform.
Returns
is the result of the modulus operation.

◆ ModEq() [2/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModEq ( const T &  modulus,
const T &  mu 
)

Barrett modulus operation. In-place variant. Implements generalized Barrett modular reduction algorithm. Uses one precomputed value of mu.

Parameters
&modulusis the modulus to perform.
&muis the Barrett value.
Returns
is the result of the modulus operation.

◆ ModExp()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModExp ( const T &  b,
const T &  modulus 
) const

Modulus exponentiation operation.

Parameters
&bis the scalar to exponentiate at all locations.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus exponentiation operation.

◆ ModExpEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModExpEq ( const T &  b,
const T &  modulus 
)

Modulus exponentiation operation. In-place variant.

Parameters
&bis the scalar to exponentiate at all locations.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus exponentiation operation.

◆ ModInverse()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModInverse ( const T &  modulus) const

Modulus inverse operation.

Parameters
&modulusis the modulus to perform.
Returns
is the result of the modulus inverse operation.

◆ ModInverseEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModInverseEq ( const T &  modulus)

Modulus inverse operation. In-place variant.

Parameters
&modulusis the modulus to perform.
Returns
is the result of the modulus inverse operation.

◆ ModMul() [1/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModMul ( const T &  b,
const T &  modulus 
) const

Modulus multiplication operation.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus multiplication operation.

◆ ModMul() [2/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModMul ( const T &  b,
const T &  modulus,
const T &  mu 
) const

Barrett modulus multiplication.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus multiplication operation.

◆ ModMulEq() [1/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModMulEq ( const T &  b,
const T &  modulus 
)

Modulus multiplication operation. In-place variant.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus multiplication operation.

◆ ModMulEq() [2/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModMulEq ( const T &  b,
const T &  modulus,
const T &  mu 
)

Barrett modulus multiplication. In-place variant.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus multiplication operation.

◆ ModMulFast() [1/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModMulFast ( const T &  b,
const T &  modulus 
) const

Modulus multiplication that assumes the operands are < modulus.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus multiplication operation.

◆ ModMulFast() [2/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModMulFast ( const T &  b,
const T &  modulus,
const T &  mu 
) const

Barrett modulus multiplication that assumes the operands are < modulus.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus multiplication operation.

◆ ModMulFastConst()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModMulFastConst ( const T &  b,
const T &  modulus,
const T &  bInv 
) const

NTL-optimized modular multiplication using a precomputation for the multiplicand. Assumes operands are < modulus.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
&bInvNTL precomputation for b.
Returns
is the result of the modulus multiplication operation.

◆ ModMulFastConstEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModMulFastConstEq ( const T &  b,
const T &  modulus,
const T &  bInv 
)

NTL-optimized modular multiplication using a precomputation for the multiplicand. Assumes operands are < modulus. In-place variant.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
&bInvNTL precomputation for b.
Returns
is the result of the modulus multiplication operation.

◆ ModMulFastEq() [1/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModMulFastEq ( const T &  b,
const T &  modulus 
)

Modulus multiplication that assumes the operands are < modulus. In-place variant.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus multiplication operation.

◆ ModMulFastEq() [2/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModMulFastEq ( const T &  b,
const T &  modulus,
const T &  mu 
)

Barrett modulus multiplication that assumes the operands are < modulus. In-place variant.

Parameters
&bis the scalar to multiply.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus multiplication operation.

◆ ModSub() [1/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModSub ( const T &  b,
const T &  modulus 
) const

Modulus subtraction operation.

Parameters
&bis the scalar to subtract.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus subtraction operation.

◆ ModSub() [2/2]

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModSub ( const T &  b,
const T &  modulus,
const T &  mu 
) const

Barrett modulus subtraction operation.

Parameters
&bis the scalar to subtract.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus subtraction operation.

◆ ModSubEq() [1/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModSubEq ( const T &  b,
const T &  modulus 
)

Modulus subtraction operation. In-place variant.

Parameters
&bis the scalar to subtract.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus subtraction operation.

◆ ModSubEq() [2/2]

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModSubEq ( const T &  b,
const T &  modulus,
const T &  mu 
)

Barrett modulus subtraction operation. In-place variant.

Parameters
&bis the scalar to subtract.
&modulusis the modulus to perform operations with.
&muis the Barrett value.
Returns
is the result of the modulus subtraction operation.

◆ ModSubFast()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::ModSubFast ( const T &  b,
const T &  modulus 
) const

Modulus subtraction where operands are < modulus.

Parameters
&bis the scalar to subtract.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus subtraction operation.

◆ ModSubFastEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::ModSubFastEq ( const T &  b,
const T &  modulus 
)

Modulus subtraction where operands are < modulus. In-place variant.

Parameters
&bis the scalar to subtract.
&modulusis the modulus to perform operations with.
Returns
is the result of the modulus subtraction operation.

◆ Mul()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::Mul ( const T &  b) const

Multiplication operation.

Parameters
&bis the value to multiply with.
Returns
is the result of the multiplication operation.

◆ MulEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::MulEq ( const T &  b)

Multiplication operation. In-place variant.

Parameters
&bis the value to multiply with.
Returns
is the result of the multiplication operation.

◆ MultiplyAndRound()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::MultiplyAndRound ( const T &  p,
const T &  q 
) const

Multiply and Rounding operation. Returns [x*p/q] where [] is the rounding operation.

Parameters
&pis the numerator to be multiplied.
&qis the denominator to be divided.
Returns
is the result of multiply and round operation.

◆ MultiplyAndRoundEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::MultiplyAndRoundEq ( const T &  p,
const T &  q 
)

Multiply and Rounding operation. Returns [x*p/q] where [] is the rounding operation. In-place variant.

Parameters
&pis the numerator to be multiplied.
&qis the denominator to be divided.
Returns
is the result of multiply and round operation.

◆ RShift()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::RShift ( usshort  shift) const

Right shift operation.

Parameters
shift# of bits.
Returns
result of the shift operation.

◆ RShiftEq()

template<typename T>
const T& lbcrypto::BigIntegerInterface< T >::RShiftEq ( usshort  shift)

Right shift operation. In-place variant.

Parameters
shift# of bits.
Returns
result of the shift operation.

◆ SetValue()

template<typename T>
void lbcrypto::BigIntegerInterface< T >::SetValue ( const std::string &  str)

Set from a string

Parameters
stris the string representation of the value

◆ Sub()

template<typename T>
T lbcrypto::BigIntegerInterface< T >::Sub ( const T &  b) const

Subtraction operation.

Parameters
&bis the value to subtract.
Returns
is the result of the subtraction operation.

◆ ToString()

template<typename T>
const std::string lbcrypto::BigIntegerInterface< T >::ToString ( ) const

Convert this integer into a std::string, for serialization

Returns
the value of this T as a string.

The documentation for this class was generated from the following file: