Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
libff::bigint< n > Class Template Reference

#include <bigint.hpp>

Public Member Functions

 bigint ()=default
 
 bigint (const unsigned long x)
 Initalize from a small integer. More...
 
 bigint (const char *s)
 Initialize from a string containing an integer in decimal notation. More...
 
 bigint (const mpz_t r)
 Initialize from MPZ element. More...
 
void print () const
 
void print_hex () const
 
bool operator== (const bigint< n > &other) const
 
bool operator!= (const bigint< n > &other) const
 
void clear ()
 
bool is_zero () const
 
size_t num_bits () const
 
unsigned long as_ulong () const
 
void to_mpz (mpz_t r) const
 Return the last limb of the integer. More...
 
bool test_bit (const std::size_t bitno) const
 
bigintrandomize ()
 

Static Public Member Functions

static constexpr size_t max_bits ()
 The number of bits representable by this bigint type. More...
 

Public Attributes

mp_limb_t data [n] = {0}
 

Static Public Attributes

static const mp_size_t N = n
 

Friends

std::ostream & operator (std::ostream &out, const bigint< n > &b)
 
std::istream & operator>> (std::istream &in, bigint< n > &b)
 

Detailed Description

template<mp_size_t n>
class libff::bigint< n >

Wrapper class around GMP's MPZ long integers. It supports arithmetic operations, serialization and randomization. Serialization is fragile, see common/serialization.hpp.

Definition at line 20 of file bigint.hpp.

Constructor & Destructor Documentation

◆ bigint() [1/4]

template<mp_size_t n>
libff::bigint< n >::bigint ( )
default

◆ bigint() [2/4]

template<mp_size_t n>
libff::bigint< n >::bigint ( const unsigned long  x)

Initalize from a small integer.

◆ bigint() [3/4]

template<mp_size_t n>
libff::bigint< n >::bigint ( const char *  s)

Initialize from a string containing an integer in decimal notation.

◆ bigint() [4/4]

template<mp_size_t n>
libff::bigint< n >::bigint ( const mpz_t  r)

Initialize from MPZ element.

Member Function Documentation

◆ as_ulong()

template<mp_size_t n>
unsigned long libff::bigint< n >::as_ulong ( ) const

◆ clear()

template<mp_size_t n>
void libff::bigint< n >::clear ( )

◆ is_zero()

template<mp_size_t n>
bool libff::bigint< n >::is_zero ( ) const

◆ max_bits()

template<mp_size_t n>
static constexpr size_t libff::bigint< n >::max_bits ( )
inlinestaticconstexpr

The number of bits representable by this bigint type.

Definition at line 51 of file bigint.hpp.

51 { return n * GMP_NUMB_BITS; };
Here is the caller graph for this function:

◆ num_bits()

template<mp_size_t n>
size_t libff::bigint< n >::num_bits ( ) const

The number of bits in this specific bigint value, i.e., position of the most-significant 1

◆ operator!=()

template<mp_size_t n>
bool libff::bigint< n >::operator!= ( const bigint< n > &  other) const

◆ operator==()

template<mp_size_t n>
bool libff::bigint< n >::operator== ( const bigint< n > &  other) const

◆ print()

template<mp_size_t n>
void libff::bigint< n >::print ( ) const

◆ print_hex()

template<mp_size_t n>
void libff::bigint< n >::print_hex ( ) const

◆ randomize()

template<mp_size_t n>
bigint& libff::bigint< n >::randomize ( )

◆ test_bit()

template<mp_size_t n>
bool libff::bigint< n >::test_bit ( const std::size_t  bitno) const
Here is the caller graph for this function:

◆ to_mpz()

template<mp_size_t n>
void libff::bigint< n >::to_mpz ( mpz_t  r) const

Return the last limb of the integer.

Friends And Related Function Documentation

◆ operator

template<mp_size_t n>
std::ostream& operator ( std::ostream &  out,
const bigint< n > &  b 
)
friend

◆ operator>>

template<mp_size_t n>
std::istream& operator>> ( std::istream &  in,
bigint< n > &  b 
)
friend

Member Data Documentation

◆ data

template<mp_size_t n>
mp_limb_t libff::bigint< n >::data[n] = {0}

Definition at line 33 of file bigint.hpp.

◆ N

template<mp_size_t n>
const mp_size_t libff::bigint< n >::N = n
static

Definition at line 31 of file bigint.hpp.


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