Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bigint.hpp
Go to the documentation of this file.
1
10#ifndef BIGINT_HPP_
11#define BIGINT_HPP_
12#include <cstddef>
13#include <iostream>
14
15#include <gmp.h>
16
18
19namespace libff {
20
21template<mp_size_t n> class bigint;
22template<mp_size_t n> std::ostream& operator<<(std::ostream &, const bigint<n>&);
23template<mp_size_t n> std::istream& operator>>(std::istream &, bigint<n>&);
24
30template<mp_size_t n>
31class bigint {
32public:
33 static const mp_size_t N = n;
34
35 mp_limb_t data[n] = {0};
36
37 bigint() = default;
38 bigint(const unsigned long x);
39 bigint(const char* s);
40 bigint(const mpz_t r);
41
42 void print() const;
43 void print_hex() const;
44 bool operator==(const bigint<n>& other) const;
45 bool operator!=(const bigint<n>& other) const;
46 void clear();
47 bool is_zero() const;
48 size_t max_bits() const { return n * GMP_NUMB_BITS; }
49 size_t num_bits() const;
50
51 unsigned long as_ulong() const;
52 void to_mpz(mpz_t r) const;
53 bool test_bit(const std::size_t bitno) const;
54
56
57 friend std::ostream& operator<< <n>(std::ostream &out, const bigint<n> &b);
58 friend std::istream& operator>> <n>(std::istream &in, bigint<n> &b);
59};
60
61} // libff
62#include <libff/algebra/fields/bigint.tcc>
63#endif
const mie::Vuint & r
Definition bn.cpp:28
size_t num_bits() const
Returns the number of bits representable by this bigint type.
bigint()=default
bool is_zero() const
static const mp_size_t N
Definition bigint.hpp:33
bigint(const unsigned long x)
void print() const
Initialize from MPZ element.
bigint(const char *s)
Initalize from a small integer.
void print_hex() const
bigint & randomize()
bool test_bit(const std::size_t bitno) const
bool operator==(const bigint< n > &other) const
size_t max_bits() const
Definition bigint.hpp:48
bigint(const mpz_t r)
Initialize from a string containing an integer in decimal notation.
unsigned long as_ulong() const
Returns the number of bits in this specific bigint value, i.e., position of the most-significant 1.
bool operator!=(const bigint< n > &other) const
void to_mpz(mpz_t r) const
Return the last limb of the integer.
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
char * s