PALISADE Lattice Crypto Library
1.11.9
A lattice crypto library for software engineers by software engineers.
|
Main class for big integers represented as an array of native (primitive) unsigned integers. More...
#include <ubintfxd.h>
Public Member Functions | |
BigInteger () | |
BigInteger (const BigInteger &val) | |
BigInteger (BigInteger &&val) | |
BigInteger (const std::string &strval) | |
BigInteger (uint64_t val) | |
BigInteger (U128BITS val) | |
BigInteger (int val) | |
BigInteger (uint32_t val) | |
BigInteger (long val) | |
BigInteger (long long val) | |
template<typename T > | |
BigInteger (const bigintnat::NativeIntegerT< T > &val) | |
BigInteger (double val) __attribute__((deprecated("Cannot const ruct from a double"))) | |
const BigInteger & | operator= (const BigInteger &val) |
const BigInteger & | operator= (BigInteger &&val) |
const BigInteger & | operator= (const std::string strval) |
const BigInteger & | operator= (uint64_t val) |
const BigInteger & | operator= (const bigintnat::NativeInteger &val) |
void | SetValue (const std::string &strval) |
void | SetValue (const BigInteger &val) |
void | SetIdentity () |
void | SetIntAtIndex (usint idx, uint_type value) |
BigInteger | Add (const BigInteger &b) const |
const BigInteger & | AddEq (const BigInteger &b) |
BigInteger | Sub (const BigInteger &b) const |
const BigInteger & | SubEq (const BigInteger &b) |
BigInteger | operator- () const |
BigInteger | Mul (const BigInteger &b) const |
const BigInteger & | MulEq (const BigInteger &b) |
BigInteger | DividedBy (const BigInteger &b) const |
const BigInteger & | DividedByEq (const BigInteger &b) |
BigInteger | Exp (usint p) const |
const BigInteger & | ExpEq (usint p) |
BigInteger | MultiplyAndRound (const BigInteger &p, const BigInteger &q) const |
const BigInteger & | MultiplyAndRoundEq (const BigInteger &p, const BigInteger &q) |
BigInteger | DivideAndRound (const BigInteger &q) const |
const BigInteger & | DivideAndRoundEq (const BigInteger &q) |
BigInteger | Mod (const BigInteger &modulus) const |
const BigInteger & | ModEq (const BigInteger &modulus) |
BigInteger | ComputeMu () const |
BigInteger | Mod (const BigInteger &modulus, const BigInteger &mu) const |
const BigInteger & | ModEq (const BigInteger &modulus, const BigInteger &mu) |
BigInteger | ModAdd (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModAddEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModAddFast (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModAddFastEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModAdd (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) const |
const BigInteger & | ModAddEq (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) |
BigInteger | ModSub (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModSubEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModSubFast (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModSubFastEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModSub (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) const |
const BigInteger & | ModSubEq (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) |
BigInteger | ModMul (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModMulEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModMul (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) const |
const BigInteger & | ModMulEq (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) |
BigInteger | ModMulFast (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModMulFastEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModMulFast (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) const |
const BigInteger & | ModMulFastEq (const BigInteger &b, const BigInteger &modulus, const BigInteger &mu) |
BigInteger | ModMulFastConst (const BigInteger &b, const BigInteger &modulus, const BigInteger &bInv) const |
const BigInteger & | ModMulFastConstEq (const BigInteger &b, const BigInteger &modulus, const BigInteger &bInv) |
BigInteger | ModExp (const BigInteger &b, const BigInteger &modulus) const |
const BigInteger & | ModExpEq (const BigInteger &b, const BigInteger &modulus) |
BigInteger | ModInverse (const BigInteger &modulus) const |
const BigInteger & | ModInverseEq (const BigInteger &modulus) |
BigInteger | LShift (usshort shift) const |
const BigInteger & | LShiftEq (usshort shift) |
BigInteger | RShift (usshort shift) const |
const BigInteger & | RShiftEq (usshort shift) |
int | Compare (const BigInteger &a) const |
template<typename T = bigintnat::BasicInteger> | |
T | ConvertToInt () const |
double | ConvertToDouble () const |
usint | GetMSB () const |
usint | GetLengthForBase (usint base) const |
usint | GetDigitAtIndexForBase (usint index, usint base) const |
bool | CheckIfPowerOfTwo (const BigInteger &m_numToCheck) |
uschar | GetBitAtIndex (usint index) const |
const std::string | ToString () const |
std::string | GetInternalRepresentation (void) 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::BigIntegerInterface< BigInteger< uint_type, BITLENGTH > > | |
void | SetValue (const std::string &str) |
BigInteger< uint_type, BITLENGTH > | Add (const BigInteger< uint_type, BITLENGTH > &b) const |
const BigInteger< uint_type, BITLENGTH > & | AddEq (const BigInteger< uint_type, BITLENGTH > &b) |
BigInteger< uint_type, BITLENGTH > | Sub (const BigInteger< uint_type, BITLENGTH > &b) const |
const BigInteger< uint_type, BITLENGTH > & | SubEq (const BigInteger< uint_type, BITLENGTH > &b) |
BigInteger< uint_type, BITLENGTH > | Mul (const BigInteger< uint_type, BITLENGTH > &b) const |
const BigInteger< uint_type, BITLENGTH > & | MulEq (const BigInteger< uint_type, BITLENGTH > &b) |
BigInteger< uint_type, BITLENGTH > | DividedBy (const BigInteger< uint_type, BITLENGTH > &b) const |
const BigInteger< uint_type, BITLENGTH > & | DividedByEq (const BigInteger< uint_type, BITLENGTH > &b) |
BigInteger< uint_type, BITLENGTH > | MultiplyAndRound (const BigInteger< uint_type, BITLENGTH > &p, const BigInteger< uint_type, BITLENGTH > &q) const |
const BigInteger< uint_type, BITLENGTH > & | MultiplyAndRoundEq (const BigInteger< uint_type, BITLENGTH > &p, const BigInteger< uint_type, BITLENGTH > &q) |
BigInteger< uint_type, BITLENGTH > | DivideAndRound (const BigInteger< uint_type, BITLENGTH > &q) const |
const BigInteger< uint_type, BITLENGTH > & | DivideAndRoundEq (const BigInteger< uint_type, BITLENGTH > &q) |
BigInteger< uint_type, BITLENGTH > | Mod (const BigInteger< uint_type, BITLENGTH > &modulus) const |
BigInteger< uint_type, BITLENGTH > | Mod (const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) const |
const BigInteger< uint_type, BITLENGTH > & | ModEq (const BigInteger< uint_type, BITLENGTH > &modulus) |
const BigInteger< uint_type, BITLENGTH > & | ModEq (const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) |
BigInteger< uint_type, BITLENGTH > | ComputeMu () const |
BigInteger< uint_type, BITLENGTH > | ModAdd (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
BigInteger< uint_type, BITLENGTH > | ModAdd (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) const |
const BigInteger< uint_type, BITLENGTH > & | ModAddEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
const BigInteger< uint_type, BITLENGTH > & | ModAddEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) |
BigInteger< uint_type, BITLENGTH > | ModAddFast (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
const BigInteger< uint_type, BITLENGTH > & | ModAddFastEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
BigInteger< uint_type, BITLENGTH > | ModSub (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
BigInteger< uint_type, BITLENGTH > | ModSub (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) const |
const BigInteger< uint_type, BITLENGTH > & | ModSubEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
const BigInteger< uint_type, BITLENGTH > & | ModSubEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) |
BigInteger< uint_type, BITLENGTH > | ModSubFast (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
const BigInteger< uint_type, BITLENGTH > & | ModSubFastEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
BigInteger< uint_type, BITLENGTH > | ModMul (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
BigInteger< uint_type, BITLENGTH > | ModMul (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) const |
const BigInteger< uint_type, BITLENGTH > & | ModMulEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
const BigInteger< uint_type, BITLENGTH > & | ModMulEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) |
BigInteger< uint_type, BITLENGTH > | ModMulFast (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
BigInteger< uint_type, BITLENGTH > | ModMulFast (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) const |
const BigInteger< uint_type, BITLENGTH > & | ModMulFastEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
const BigInteger< uint_type, BITLENGTH > & | ModMulFastEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &mu) |
BigInteger< uint_type, BITLENGTH > | ModMulFastConst (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &bInv) const |
const BigInteger< uint_type, BITLENGTH > & | ModMulFastConstEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus, const BigInteger< uint_type, BITLENGTH > &bInv) |
BigInteger< uint_type, BITLENGTH > | ModExp (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) const |
const BigInteger< uint_type, BITLENGTH > & | ModExpEq (const BigInteger< uint_type, BITLENGTH > &b, const BigInteger< uint_type, BITLENGTH > &modulus) |
BigInteger< uint_type, BITLENGTH > | ModInverse (const BigInteger< uint_type, BITLENGTH > &modulus) const |
const BigInteger< uint_type, BITLENGTH > & | ModInverseEq (const BigInteger< uint_type, BITLENGTH > &modulus) |
BigInteger< uint_type, BITLENGTH > | LShift (usshort shift) const |
const BigInteger< uint_type, BITLENGTH > & | LShiftEq (usshort shift) |
BigInteger< uint_type, BITLENGTH > | RShift (usshort shift) const |
const BigInteger< uint_type, BITLENGTH > & | RShiftEq (usshort shift) |
int | Compare (const BigInteger< uint_type, BITLENGTH > &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 |
Static Public Member Functions | |
static BigInteger | intToBigInteger (usint m) |
static BigInteger | FromBinaryString (const std::string &bitString) |
static BigInteger | Allocator () |
static const std::string | IntegerTypeName () |
static uint32_t | SerializedVersion () |
Protected Member Functions | |
void | AssignVal (const std::string &v) |
void | SetMSB () |
void | SetMSB (usint guessIdxChar) |
Friends | |
template<typename uint_type_c , usint BITLENGTH_c> | |
std::ostream & | operator<< (std::ostream &os, const BigInteger< uint_type_c, BITLENGTH_c > &ptr_obj) |
Main class for big integers represented as an array of native (primitive) unsigned integers.
uint_type | native unsigned integer type |
BITLENGTH | maximum bitwidth supported for big integers |
bigintfxd::BigInteger< uint_type, BITLENGTH >::BigInteger | ( | ) |
Default constructor.
bigintfxd::BigInteger< uint_type, BITLENGTH >::BigInteger | ( | const BigInteger< uint_type, BITLENGTH > & | val | ) |
Copy constructor.
&val | is the big binary integer to be copied. |
bigintfxd::BigInteger< uint_type, BITLENGTH >::BigInteger | ( | BigInteger< uint_type, BITLENGTH > && | val | ) |
Move constructor.
&&val | is the big binary integer to be copied. |
|
explicit |
Constructor from a string.
&strval | is the initial integer represented as a string. |
bigintfxd::BigInteger< uint_type, BITLENGTH >::BigInteger | ( | uint64_t | val | ) |
Constructor from an unsigned integer.
val | is the initial integer represented as a uint64_t. |
|
inline |
Constructors from smaller basic types
val | is the initial integer represented as a basic integer type. |
|
inline |
Constructor from a NativeInteger
&val | is the initial integer represented as a native integer. |
bigintfxd::BigInteger< uint_type, BITLENGTH >::BigInteger | ( | double | val | ) | const |
Constructor from double is not permitted
val |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::Add | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) | const |
Addition operation.
&b | is the value to add. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::AddEq | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) |
Addition operation. In-place variant.
&b | is the value to add. |
|
inlinestatic |
A zero allocator that is called by the Matrix class. It is used to initialize a Matrix of BigInteger objects.
|
protected |
Converts the string v into base-r integer where r is equal to 2^bitwidth of integral data type.
v | The input string |
bool bigintfxd::BigInteger< uint_type, BITLENGTH >::CheckIfPowerOfTwo | ( | const BigInteger< uint_type, BITLENGTH > & | m_numToCheck | ) |
Tests whether the BigInteger is a power of 2.
m_numToCheck | is the value to check. |
int bigintfxd::BigInteger< uint_type, BITLENGTH >::Compare | ( | const BigInteger< uint_type, BITLENGTH > & | a | ) | const |
Compares the current BigInteger to BigInteger a.
a | is the BigInteger to be compared with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ComputeMu | ( | ) | const |
Pre-computes the mu factor that is used in Barrett modulo reduction
|
inline |
Converts the value to an double.
|
inline |
Converts the value to an int.
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::DivideAndRound | ( | const BigInteger< uint_type, BITLENGTH > & | q | ) | const |
Divide and Rounding operation. Returns [x/q] where [] is the rounding operation.
&q | is the denominator to be divided. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::DivideAndRoundEq | ( | const BigInteger< uint_type, BITLENGTH > & | q | ) |
Divide and Rounding operation. Returns [x/q] where [] is the rounding operation. In-place variant.
&q | is the denominator to be divided. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::DividedBy | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) | const |
Division operation.
&b | is the value to divide by. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::DividedByEq | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) |
Division operation. In-place variant.
&b | is the value to divide by. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::Exp | ( | usint | p | ) | const |
Exponentiation operation. Returns x^p.
p | the exponent. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ExpEq | ( | usint | p | ) |
Exponentiation operation. Returns x^p. In-place variant.
p | the exponent. |
|
static |
Convert a string representation of a binary number to a decimal BigInteger.
bitString | the binary num in string. |
uschar bigintfxd::BigInteger< uint_type, BITLENGTH >::GetBitAtIndex | ( | usint | index | ) | const |
Gets the bit at the specified index.
index | is the index of the bit to get. |
usint bigintfxd::BigInteger< uint_type, BITLENGTH >::GetDigitAtIndexForBase | ( | usint | index, |
usint | base | ||
) | const |
Get a specific digit at "digit" index; big integer is seen as an array of digits, where a 0 <= digit < base Warning: only power-of-2 bases are currently supported. 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.
index | is the "digit" index of the requested digit |
base | is the base with which to determine length in. |
|
inline |
Delivers value of the internal limb storage Used primarily for debugging
|
inline |
Get the number of digits using a specific base - support for arbitrary base may be needed.
base | is the base with which to determine length in. |
usint bigintfxd::BigInteger< uint_type, BITLENGTH >::GetMSB | ( | ) | const |
Returns the MSB location of the value.
|
static |
Convert a value from an int to a BigInteger.
m | the value to convert from. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::LShift | ( | usshort | shift | ) | const |
Left shift operation.
shift | # of bits. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::LShiftEq | ( | usshort | shift | ) |
Left shift operation. In-place variant.
shift | # of bits. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::Mod | ( | const BigInteger< uint_type, BITLENGTH > & | modulus | ) | const |
Naive modulus operation.
&modulus | is the modulus to perform. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::Mod | ( | const BigInteger< uint_type, BITLENGTH > & | modulus, |
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) | const |
Barrett modulus operation. Implements generalized Barrett modular reduction algorithm. Uses one precomputed value of mu.
&modulus | is the modulus to perform. |
&mu | is the Barrett value. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModAdd | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus addition operation.
&b | is the scalar to add. |
&modulus | is the modulus to perform operations with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModAdd | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) | const |
Barrett modulus addition operation.
&b | is the scalar to add. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModAddEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus addition operation. In-place variant.
&b | is the scalar to add. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModAddEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) |
Barrett modulus addition operation. In-place variant.
&b | is the scalar to add. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModAddFast | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus addition where operands are < modulus.
&b | is the scalar to add. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModAddFastEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus addition where operands are < modulus. In-place variant.
&b | is the scalar to add. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModEq | ( | const BigInteger< uint_type, BITLENGTH > & | modulus | ) |
Naive modulus operation. In-place variant.
&modulus | is the modulus to perform. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModEq | ( | const BigInteger< uint_type, BITLENGTH > & | modulus, |
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) |
Barrett modulus operation. In-place variant. Implements generalized Barrett modular reduction algorithm. Uses one precomputed value of mu.
&modulus | is the modulus to perform. |
&mu | is the Barrett value. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModExp | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus exponentiation operation. Square-and-multiply algorithm is used.
&b | is the scalar to exponentiate at all locations. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModExpEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus exponentiation operation. Square-and-multiply algorithm is used. In-place variant.
&b | is the scalar to exponentiate at all locations. |
&modulus | is the modulus to perform operations with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModInverse | ( | const BigInteger< uint_type, BITLENGTH > & | modulus | ) | const |
Modulus inverse operation.
&modulus | is the modulus to perform. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModInverseEq | ( | const BigInteger< uint_type, BITLENGTH > & | modulus | ) |
Modulus inverse operation. In-place variant.
&modulus | is the modulus to perform. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMul | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus multiplication operation.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMul | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) | const |
Barrett modulus multiplication.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMulEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus multiplication operation. In-place variant.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMulEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) |
Barrett modulus multiplication. In-place variant.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMulFast | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus multiplication that assumes the operands are < modulus.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMulFast | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) | const |
Barrett modulus multiplication that assumes the operands are < modulus.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMulFastEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus multiplication that assumes the operands are < modulus. In-place variant.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModMulFastEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) |
Barrett modulus multiplication that assumes the operands are < modulus. In-place variant.
&b | is the scalar to multiply. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModSub | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus subtraction operation.
&b | is the scalar to subtract. |
&modulus | is the modulus to perform operations with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModSub | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) | const |
Barrett modulus subtraction operation.
&b | is the scalar to subtract. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModSubEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus subtraction operation. In-place variant.
&b | is the scalar to subtract. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModSubEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus, | ||
const BigInteger< uint_type, BITLENGTH > & | mu | ||
) |
Barrett modulus subtraction operation. In-place variant.
&b | is the scalar to subtract. |
&modulus | is the modulus to perform operations with. |
&mu | is the Barrett value. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::ModSubFast | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) | const |
Modulus subtraction where operands are < modulus.
&b | is the scalar to subtract. |
&modulus | is the modulus to perform operations with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::ModSubFastEq | ( | const BigInteger< uint_type, BITLENGTH > & | b, |
const BigInteger< uint_type, BITLENGTH > & | modulus | ||
) |
Modulus subtraction where operands are < modulus. In-place variant.
&b | is the scalar to subtract. |
&modulus | is the modulus to perform operations with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::Mul | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) | const |
Multiplication operation.
&b | is the value to multiply with. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::MulEq | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) |
Multiplication operation. In-place variant.
&b | is the value to multiply with. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::MultiplyAndRound | ( | const BigInteger< uint_type, BITLENGTH > & | p, |
const BigInteger< uint_type, BITLENGTH > & | 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 BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::MultiplyAndRoundEq | ( | const BigInteger< uint_type, BITLENGTH > & | p, |
const BigInteger< uint_type, BITLENGTH > & | 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. |
|
inline |
Operator for unary minus
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::operator= | ( | const BigInteger< uint_type, BITLENGTH > & | val | ) |
Copy assignment operator
&val | is the big binary integer to be assigned from. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::operator= | ( | BigInteger< uint_type, BITLENGTH > && | val | ) |
Move assignment operator
&val | is the big binary integer to be assigned from. |
|
inline |
Assignment operator from string
strval | is the string to be assigned from |
|
inline |
Assignment operator from unsigned integer
val | is the unsigned integer to be assigned from. |
|
inline |
Assignment operator from native integer
&val | is the native integer to be assigned from. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::RShift | ( | usshort | shift | ) | const |
Right shift operation.
shift | # of bits. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::RShiftEq | ( | usshort | shift | ) |
Right shift operation. In-place variant.
shift | # of bits. |
|
inline |
Set this int to 1.
void bigintfxd::BigInteger< uint_type, BITLENGTH >::SetIntAtIndex | ( | usint | idx, |
uint_type | value | ||
) |
Sets the int value at the specified index.
index | is the index of the int to set in the uint array. |
|
protected |
Sets the MSB to the correct value from the BigInteger.
|
protected |
Sets the MSB to the correct value from the BigInteger.
guessIdxChar | is the hint of the MSB position. |
void bigintfxd::BigInteger< uint_type, BITLENGTH >::SetValue | ( | const std::string & | strval | ) |
Basic set method for setting the value of a big binary integer
strval | is the string representation of the big binary integer to be copied. |
void bigintfxd::BigInteger< uint_type, BITLENGTH >::SetValue | ( | const BigInteger< uint_type, BITLENGTH > & | val | ) |
Basic set method for setting the value of a big binary integer
val | is the big binary integer representation of the big binary integer to be assigned. |
BigInteger< uint_type, BITLENGTH > bigintfxd::BigInteger< uint_type, BITLENGTH >::Sub | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) | const |
Subtraction operation.
&b | is the value to subtract. |
const BigInteger< uint_type, BITLENGTH > & bigintfxd::BigInteger< uint_type, BITLENGTH >::SubEq | ( | const BigInteger< uint_type, BITLENGTH > & | b | ) |
Subtraction operation. In-place variant.
&b | is the value to subtract. |
const std::string bigintfxd::BigInteger< uint_type, BITLENGTH >::ToString | ( | ) | const |
Stores the based 10 equivalent/Decimal value of the BigInteger in a string object and returns it.
|
friend |
Console output operation.
os | is the std ostream object. |
ptr_obj | is BigInteger to be printed. |