![]() |
PIVX Core
5.6.99
P2P Digital Currency
|
C++ wrapper for BIGNUM. More...
#include <bignum.h>
Public Member Functions | |
| CBigNum () | |
| C++ wrapper for BIGNUM (Gmp bignum) More... | |
| CBigNum (const CBigNum &b) | |
| CBigNum & | operator= (const CBigNum &b) |
| ~CBigNum () | |
| CBigNum (signed char n) | |
| CBigNum (short n) | |
| CBigNum (int n) | |
| CBigNum (long n) | |
| CBigNum (long long n) | |
| CBigNum (unsigned char n) | |
| CBigNum (unsigned short n) | |
| CBigNum (unsigned int n) | |
| CBigNum (unsigned long n) | |
| CBigNum (unsigned long long n) | |
| CBigNum (uint256 n) | |
| CBigNum (const std::vector< unsigned char > &vch) | |
| int | bitSize () const |
| Returns the size in bits of the underlying bignum. More... | |
| void | setulong (unsigned long n) |
| unsigned long | getulong () const |
| unsigned int | getuint () const |
| int | getint () const |
| void | setint64 (int64_t sn) |
| void | setuint64 (uint64_t n) |
| void | setuint256 (uint256 n) |
| arith_uint256 | getuint256 () const |
| void | setvch (const std::vector< unsigned char > &vch) |
| std::vector< unsigned char > | getvch () const |
| void | SetDec (const std::string &str) |
| void | SetHex (const std::string &str) |
| bool | SetHexBool (const std::string &str) |
| std::string | ToString (int nBase=10) const |
| std::string | GetHex () const |
| std::string | GetDec () const |
| template<typename Stream > | |
| void | Serialize (Stream &s) const |
| template<typename Stream > | |
| void | Unserialize (Stream &s) |
| CBigNum | pow (const int e) const |
| exponentiation with an int. More... | |
| CBigNum | pow (const CBigNum &e) const |
| exponentiation this^e More... | |
| CBigNum | mul_mod (const CBigNum &b, const CBigNum &m) const |
| modular multiplication: (this * b) mod m More... | |
| CBigNum | pow_mod (const CBigNum &e, const CBigNum &m) const |
| modular exponentiation: this^e mod n More... | |
| CBigNum | inverse (const CBigNum &m) const |
| Calculates the inverse of this element mod m. More... | |
| CBigNum | gcd (const CBigNum &b) const |
| Calculates the greatest common divisor (GCD) of two numbers. More... | |
| bool | isPrime (const int checks=15) const |
| Miller-Rabin primality test on this element. More... | |
| bool | isOne () const |
| bool | operator! () const |
| CBigNum & | operator+= (const CBigNum &b) |
| CBigNum & | operator-= (const CBigNum &b) |
| CBigNum & | operator*= (const CBigNum &b) |
| CBigNum & | operator/= (const CBigNum &b) |
| CBigNum & | operator%= (const CBigNum &b) |
| CBigNum & | operator<<= (unsigned int shift) |
| CBigNum & | operator>>= (unsigned int shift) |
| CBigNum & | operator++ () |
| const CBigNum | operator++ (int) |
| CBigNum & | operator-- () |
| const CBigNum | operator-- (int) |
Static Public Member Functions | |
| static CBigNum | randBignum (const CBigNum &range) |
| Generates a cryptographically secure random number between zero and range exclusive i.e. More... | |
Private Attributes | |
| mpz_t | bn |
Friends | |
| const CBigNum | operator+ (const CBigNum &a, const CBigNum &b) |
| const CBigNum | operator- (const CBigNum &a, const CBigNum &b) |
| const CBigNum | operator/ (const CBigNum &a, const CBigNum &b) |
| const CBigNum | operator% (const CBigNum &a, const CBigNum &b) |
| const CBigNum | operator* (const CBigNum &a, const CBigNum &b) |
| const CBigNum | operator<< (const CBigNum &a, unsigned int shift) |
| const CBigNum | operator- (const CBigNum &a) |
| bool | operator== (const CBigNum &a, const CBigNum &b) |
| bool | operator!= (const CBigNum &a, const CBigNum &b) |
| bool | operator<= (const CBigNum &a, const CBigNum &b) |
| bool | operator>= (const CBigNum &a, const CBigNum &b) |
| bool | operator< (const CBigNum &a, const CBigNum &b) |
| bool | operator> (const CBigNum &a, const CBigNum &b) |
| CBigNum::CBigNum | ( | ) |
C++ wrapper for BIGNUM (Gmp bignum)
Definition at line 10 of file bignum.cpp.
| CBigNum::CBigNum | ( | const CBigNum & | b | ) |
Definition at line 15 of file bignum.cpp.
| CBigNum::~CBigNum | ( | ) |
Definition at line 27 of file bignum.cpp.
| CBigNum::CBigNum | ( | signed char | n | ) |
Definition at line 33 of file bignum.cpp.
| CBigNum::CBigNum | ( | short | n | ) |
Definition at line 34 of file bignum.cpp.
| CBigNum::CBigNum | ( | int | n | ) |
Definition at line 35 of file bignum.cpp.
| CBigNum::CBigNum | ( | long | n | ) |
Definition at line 36 of file bignum.cpp.
| CBigNum::CBigNum | ( | long long | n | ) |
Definition at line 37 of file bignum.cpp.
| CBigNum::CBigNum | ( | unsigned char | n | ) |
Definition at line 38 of file bignum.cpp.
| CBigNum::CBigNum | ( | unsigned short | n | ) |
Definition at line 39 of file bignum.cpp.
| CBigNum::CBigNum | ( | unsigned int | n | ) |
Definition at line 40 of file bignum.cpp.
| CBigNum::CBigNum | ( | unsigned long | n | ) |
Definition at line 41 of file bignum.cpp.
| CBigNum::CBigNum | ( | unsigned long long | n | ) |
|
explicit |
|
explicit |
| int CBigNum::bitSize | ( | ) | const |
Returns the size in bits of the underlying bignum.
Definition at line 78 of file bignum.cpp.
Calculates the greatest common divisor (GCD) of two numbers.
| m | the second element |
Definition at line 248 of file bignum.cpp.
| std::string CBigNum::GetDec | ( | ) | const |
Definition at line 326 of file bignum.cpp.
| std::string CBigNum::GetHex | ( | ) | const |
Definition at line 321 of file bignum.cpp.
| int CBigNum::getint | ( | ) | const |
| unsigned int CBigNum::getuint | ( | ) | const |
Definition at line 93 of file bignum.cpp.
| arith_uint256 CBigNum::getuint256 | ( | ) | const |
Definition at line 113 of file bignum.cpp.
| unsigned long CBigNum::getulong | ( | ) | const |
| std::vector< unsigned char > CBigNum::getvch | ( | ) | const |
Calculates the inverse of this element mod m.
i.e. i such this*i = 1 mod m
| m | the modu |
Definition at line 236 of file bignum.cpp.
| bool CBigNum::isOne | ( | ) | const |
| bool CBigNum::isPrime | ( | const int | checks = 15 | ) | const |
Miller-Rabin primality test on this element.
| checks | optional, the number of Miller-Rabin tests to run default causes error rate of 2^-80. |
Definition at line 261 of file bignum.cpp.
modular multiplication: (this * b) mod m
| b | operand |
| m | modulus |
Definition at line 207 of file bignum.cpp.
| bool CBigNum::operator! | ( | ) | const |
Definition at line 272 of file bignum.cpp.
Definition at line 347 of file bignum.cpp.
Definition at line 289 of file bignum.cpp.
| CBigNum & CBigNum::operator++ | ( | ) |
Definition at line 307 of file bignum.cpp.
| const CBigNum CBigNum::operator++ | ( | int | ) |
Definition at line 353 of file bignum.cpp.
Definition at line 277 of file bignum.cpp.
| CBigNum & CBigNum::operator-- | ( | ) |
Definition at line 314 of file bignum.cpp.
| const CBigNum CBigNum::operator-- | ( | int | ) |
Definition at line 361 of file bignum.cpp.
Definition at line 283 of file bignum.cpp.
Definition at line 341 of file bignum.cpp.
| CBigNum & CBigNum::operator<<= | ( | unsigned int | shift | ) |
Definition at line 295 of file bignum.cpp.
Definition at line 21 of file bignum.cpp.
| CBigNum & CBigNum::operator>>= | ( | unsigned int | shift | ) |
Definition at line 301 of file bignum.cpp.
| CBigNum CBigNum::pow | ( | const int | e | ) | const |
exponentiation with an int.
this^e
| e | the exponent as an int |
Definition at line 331 of file bignum.cpp.
modular exponentiation: this^e mod n
| e | exponent |
| m | modulus |
Definition at line 220 of file bignum.cpp.
Generates a cryptographically secure random number between zero and range exclusive i.e.
PRNGs use GMP for consistency with seed initialization.
0 < returned number < range
| range | The upper bound on the number. |
Generates a cryptographically secure random number between zero and range-1 (inclusive) i.e. 0 <= returned number < range
| range | The upper bound on the number. |
Definition at line 58 of file bignum.cpp.
|
inline |
| void CBigNum::SetDec | ( | const std::string & | str | ) |
| void CBigNum::SetHex | ( | const std::string & | str | ) |
Definition at line 336 of file bignum.cpp.
| bool CBigNum::SetHexBool | ( | const std::string & | str | ) |
| void CBigNum::setint64 | ( | int64_t | sn | ) |
| void CBigNum::setuint256 | ( | uint256 | n | ) |
Definition at line 108 of file bignum.cpp.
| void CBigNum::setuint64 | ( | uint64_t | n | ) |
| void CBigNum::setulong | ( | unsigned long | n | ) |
Definition at line 83 of file bignum.cpp.
| void CBigNum::setvch | ( | const std::vector< unsigned char > & | vch | ) |
| std::string CBigNum::ToString | ( | int | nBase = 10 | ) | const |
|
inline |