51 #include "../System/cl_platform.h"
109 void set_bit(
unsigned int bit_number,
unsigned int value);
113 void sieve(
const uint32_t *primes,
unsigned int num_primes, std::vector<unsigned char> &
sieve);
268 std::unique_ptr<BigInt_Impl> impl;
bool fermat(uint32_t w) const
Using w as a witness, try pseudo-primality testing based on Fermat's little theorem.
void exptmod(const BigInt *b, const BigInt *m, BigInt *c) const
Compute c = (a ** b) mod m.
BigInt operator%(const BigInt &b)
Compute result = this % b.
void to_unsigned_octets(unsigned char *output_str, unsigned int output_length) const
BigInt(uint64_t value)
Constructs a big integer (initialised to value)
int unsigned_octet_size() const
BigInt operator*=(const BigInt &b)
Compute this *= b.
bool is_odd() const
Returns a true if number is odd.
uint32_t mod_d(uint32_t d) const
Compute c = a (mod d). Result will always be 0 <= c < d.
unsigned int trailing_zeros() const
BigInt(int32_t value)
Constructs a big integer (initialised to value)
BigInt operator/(const BigInt &b)
Compute result = this / b.
void set(int32_t d)
Sets a value.
bool invmod(const BigInt *m, BigInt *c) const
Compute c = a^-1 (mod m), if there is an inverse for a (mod m).
void exch(BigInt *mp2)
Exchange mp1 and mp2 without allocating any intermediate memory.
BigInt operator-(const BigInt &b)
Compute result = this - b.
int cmp(const BigInt *b) const
void div(const BigInt &b, BigInt *q, BigInt *r) const
Compute q = a / b and r = a mod b.
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.
BigInt()
Constructs a big integer (initialised to zero)
int cmp_z() const
Compare a <=> 0. Returns <0 if a<0, 0 if a=0, >0 if a>0.
void div_2(BigInt *c) const
Compute c = a / 2, disregarding the remainder.
Big Integer class.
Definition: big_int.h:62
int significant_bits() const
void div(uint32_t d, BigInt *q, BigInt *r) const
BigInt(uint32_t value)
Constructs a big integer (initialised to value)
void random()
Assigns a random value to a.
void get(uint32_t &d)
Gets a value.
BigInt operator%=(const BigInt &b)
Compute this %= b.
void mod(const BigInt *m, BigInt *c) const
Compute c = a (mod m). Result will always be 0 <= c < m.
int cmp_d(uint32_t d) const
Compare a <=> d. Returns <0 if a<d, 0 if a=d, >0 if a>d.
void abs(BigInt *b) const
Compute b = |a|. 'a' and 'b' may be identical.
void sqrmod(const BigInt *m, BigInt *c) const
BigInt operator+=(const BigInt &b)
Compute this += b.
void sieve(const uint32_t *primes, unsigned int num_primes, std::vector< unsigned char > &sieve)
BigInt operator/=(const BigInt &b)
Compute this /= b.
bool pprime(int nt) const
Performs nt iteration of the Miller-Rabin probabilistic primality test on a.
void set_bit(unsigned int bit_number, unsigned int value)
BigInt(int64_t value)
Constructs a big integer (initialised to value)
void sqr(BigInt *b) const
void read_unsigned_octets(const unsigned char *input_str, unsigned int input_length)
BigInt operator*(const BigInt &b)
Compute result = this * b.
bool is_even() const
Returns a true if number is even.
void neg(BigInt *b) const
Compute b = -a. 'a' and 'b' may be identical.
BigInt operator+(const BigInt &b)
Compute result = this + b.
void div_d(uint32_t d, BigInt *q, uint32_t *r) const
Compute the quotient q = a / d and remainder r = a mod d, for a single digit d. Respects the sign of ...
BigInt(const BigInt &other)
Copy constructor.
bool make_prime(unsigned int num_bits)
BigInt operator-=(const BigInt &b)
Compute this -= b.
BigInt & operator=(const BigInt &other)