clan::BigInt Class Reference

Big Integer class. More...

#include <big_int.h>

Public Member Functions

Construction
 BigInt ()
 Constructs a big integer (initialised to zero) More...
 
 BigInt (ubyte32 value)
 Constructs a big integer (initialised to value) More...
 
 BigInt (byte32 value)
 Constructs a big integer (initialised to value) More...
 
 BigInt (ubyte64 value)
 Constructs a big integer (initialised to value) More...
 
 BigInt (byte64 value)
 Constructs a big integer (initialised to value) More...
 
 BigInt (const BigInt &other)
 Copy constructor. More...
 
 ~BigInt ()
 Destructor. More...
 
BigIntoperator= (const BigInt &other)
 
Operations
void read_unsigned_octets (const unsigned char *input_str, unsigned int input_length)
 
void zero ()
 
bool make_prime (unsigned int num_bits)
 
int cmp_z () const
 Compare a <=> 0. Returns <0 if a<0, 0 if a=0, >0 if a>0. More...
 
void set_bit (unsigned int bit_number, unsigned int value)
 
int significant_bits () const
 
void sieve (const ubyte32 *primes, unsigned int num_primes, std::vector< unsigned char > &sieve)
 
ubyte32 mod_d (ubyte32 d) const
 Compute c = a (mod d). Result will always be 0 <= c < d. More...
 
void div_d (ubyte32 d, BigInt *q, ubyte32 *r) const
 Compute the quotient q = a / d and remainder r = a mod d, for a single digit d. Respects the sign of its divisor (single digits are unsigned anyway). More...
 
bool fermat (ubyte32 w) const
 Using w as a witness, try pseudo-primality testing based on Fermat's little theorem. More...
 
bool pprime (int nt) const
 Performs nt iteration of the Miller-Rabin probabilistic primality test on a. More...
 
void set (byte32 d)
 Sets a value. More...
 
void set (ubyte32 d)
 
void set (ubyte64 d)
 
void set (byte64 d)
 
void get (ubyte32 &d)
 Gets a value. More...
 
void get (ubyte64 &d)
 
void get (byte64 &d)
 
void get (byte32 &d)
 
void exptmod (const BigInt *b, const BigInt *m, BigInt *c) const
 Compute c = (a ** b) mod m. More...
 
void mod (const BigInt *m, BigInt *c) const
 Compute c = a (mod m). Result will always be 0 <= c < m. More...
 
void div (const BigInt &b, BigInt *q, BigInt *r) const
 Compute q = a / b and r = a mod b. More...
 
void div (ubyte32 d, BigInt *q, BigInt *r) const
 
BigInt operator+ (const BigInt &b)
 Compute result = this + b. More...
 
BigInt operator+ (ubyte32 d)
 
BigInt operator+= (const BigInt &b)
 Compute this += b. More...
 
BigInt operator+= (ubyte32 d)
 
BigInt operator- (const BigInt &b)
 Compute result = this - b. More...
 
BigInt operator- (ubyte32 d)
 
BigInt operator-= (const BigInt &b)
 Compute this -= b. More...
 
BigInt operator-= (ubyte32 d)
 
BigInt operator* (const BigInt &b)
 Compute result = this * b. More...
 
BigInt operator* (ubyte32 d)
 
BigInt operator*= (const BigInt &b)
 Compute this *= b. More...
 
BigInt operator*= (ubyte32 d)
 
BigInt operator/ (const BigInt &b)
 Compute result = this / b. More...
 
BigInt operator/ (ubyte32 d)
 
BigInt operator/= (const BigInt &b)
 Compute this /= b. More...
 
BigInt operator/= (ubyte32 d)
 
BigInt operator% (const BigInt &b)
 Compute result = this % b. More...
 
BigInt operator% (ubyte32 d)
 
BigInt operator%= (const BigInt &b)
 Compute this %= b. More...
 
BigInt operator%= (ubyte32 d)
 
int cmp (const BigInt *b) const
 
int cmp_d (ubyte32 d) const
 Compare a <=> d. Returns <0 if a<d, 0 if a=d, >0 if a>d. More...
 
void neg (BigInt *b) const
 Compute b = -a. 'a' and 'b' may be identical. More...
 
unsigned int trailing_zeros () const
 
void sqrmod (const BigInt *m, BigInt *c) const
 
void sqr (BigInt *b) const
 
void random ()
 Assigns a random value to a. More...
 
void exch (BigInt *mp2)
 Exchange mp1 and mp2 without allocating any intermediate memory. More...
 
bool invmod (const BigInt *m, BigInt *c) const
 Compute c = a^-1 (mod m), if there is an inverse for a (mod m). More...
 
void xgcd (const BigInt *b, BigInt *g, BigInt *x, BigInt *y) const
 Compute g = (a, b) and values x and y satisfying Bezout's identity. More...
 
void abs (BigInt *b) const
 Compute b = |a|. 'a' and 'b' may be identical. More...
 
bool is_even () const
 Returns a true if number is even. More...
 
bool is_odd () const
 Returns a true if number is odd. More...
 
void div_2 (BigInt *c) const
 Compute c = a / 2, disregarding the remainder. More...
 
void to_unsigned_octets (unsigned char *output_str, unsigned int output_length) const
 
int unsigned_octet_size () const
 

Detailed Description

Big Integer class.


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