Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
libff::Fp_model< n, modulus > Class Template Reference

#include <fp.hpp>

Collaboration diagram for libff::Fp_model< n, modulus >:

Public Member Functions

 Fp_model ()
 
 Fp_model (const bigint< n > &b)
 
 Fp_model (const long x, const bool is_unsigned=false)
 
void set_ulong (const unsigned long x)
 
void mul_reduce (const bigint< n > &other)
 
void clear ()
 
bigint< n > as_bigint () const
 
unsigned long as_ulong () const
 
bool operator== (const Fp_model &other) const
 
bool operator!= (const Fp_model &other) const
 
bool is_zero () const
 
void print () const
 
Fp_modeloperator+= (const Fp_model &other)
 
Fp_modeloperator-= (const Fp_model &other)
 
Fp_modeloperator*= (const Fp_model &other)
 
Fp_modeloperator^= (const unsigned long pow)
 
template<mp_size_t m>
Fp_modeloperator^= (const bigint< m > &pow)
 
Fp_model operator+ (const Fp_model &other) const
 
Fp_model operator- (const Fp_model &other) const
 
Fp_model operator* (const Fp_model &other) const
 
Fp_model operator- () const
 
Fp_model squared () const
 
Fp_modelinvert ()
 
Fp_model inverse () const
 
Fp_model sqrt () const
 
Fp_model operator^ (const unsigned long pow) const
 
template<mp_size_t m>
Fp_model operator^ (const bigint< m > &pow) const
 

Static Public Member Functions

static bool modulus_is_valid ()
 
static size_t size_in_bits ()
 
static size_t capacity ()
 
static bigint< n > field_char ()
 
static Fp_model< n, modulus > zero ()
 
static Fp_model< n, modulus > one ()
 
static Fp_model< n, modulus > random_element ()
 
static Fp_model< n, modulus > geometric_generator ()
 
static Fp_model< n, modulus > arithmetic_generator ()
 

Public Attributes

bigint< n > mont_repr
 

Static Public Attributes

static const mp_size_t num_limbs = n
 
static const constexpr bigint< n > & mod = modulus
 
static size_t num_bits
 
static bigint< n > euler
 
static size_t s
 
static bigint< n > t
 
static bigint< n > t_minus_1_over_2
 
static Fp_model< n, modulus > nqr
 
static Fp_model< n, modulus > nqr_to_t
 
static Fp_model< n, modulus > multiplicative_generator
 
static Fp_model< n, modulus > root_of_unity
 
static mp_limb_t inv
 
static bigint< n > Rsquared
 
static bigint< n > Rcubed
 

Friends

std::ostream & operator (std::ostream &out, const Fp_model< n, modulus > &p)
 
std::istream & operator>> (std::istream &in, Fp_model< n, modulus > &p)
 

Detailed Description

template<mp_size_t n, const bigint< n > & modulus>
class libff::Fp_model< n, modulus >

Arithmetic in the finite field F[p], for prime p of fixed length.

This class implements Fp-arithmetic, for a large prime p, using a fixed number of words. It is optimized for tight memory consumption, so the modulus p is passed as a template parameter, to avoid per-element overheads.

The implementation is mostly a wrapper around GMP's MPN (constant-size integers). But for the integer sizes of interest for libff (3 to 5 limbs of 64 bits each), we implement performance-critical routines, like addition and multiplication, using hand-optimzied assembly code.

Definition at line 40 of file fp.hpp.

Constructor & Destructor Documentation

◆ Fp_model() [1/3]

template<mp_size_t n, const bigint< n > & modulus>
libff::Fp_model< n, modulus >::Fp_model ( )
inline

Definition at line 68 of file fp.hpp.

68{};

◆ Fp_model() [2/3]

template<mp_size_t n, const bigint< n > & modulus>
libff::Fp_model< n, modulus >::Fp_model ( const bigint< n > & b)

◆ Fp_model() [3/3]

template<mp_size_t n, const bigint< n > & modulus>
libff::Fp_model< n, modulus >::Fp_model ( const long x,
const bool is_unsigned = false )

Member Function Documentation

◆ arithmetic_generator()

template<mp_size_t n, const bigint< n > & modulus>
static Fp_model< n, modulus > libff::Fp_model< n, modulus >::arithmetic_generator ( )
static

◆ as_bigint()

template<mp_size_t n, const bigint< n > & modulus>
bigint< n > libff::Fp_model< n, modulus >::as_bigint ( ) const
Here is the caller graph for this function:

◆ as_ulong()

template<mp_size_t n, const bigint< n > & modulus>
unsigned long libff::Fp_model< n, modulus >::as_ulong ( ) const

◆ capacity()

template<mp_size_t n, const bigint< n > & modulus>
static size_t libff::Fp_model< n, modulus >::capacity ( )
inlinestatic

Definition at line 115 of file fp.hpp.

115{ return num_bits - 1; }
static size_t num_bits
Definition fp.hpp:53

◆ clear()

template<mp_size_t n, const bigint< n > & modulus>
void libff::Fp_model< n, modulus >::clear ( )
Here is the caller graph for this function:

◆ field_char()

template<mp_size_t n, const bigint< n > & modulus>
static bigint< n > libff::Fp_model< n, modulus >::field_char ( )
inlinestatic

Definition at line 116 of file fp.hpp.

116{ return modulus; }
Here is the caller graph for this function:

◆ geometric_generator()

template<mp_size_t n, const bigint< n > & modulus>
static Fp_model< n, modulus > libff::Fp_model< n, modulus >::geometric_generator ( )
static

◆ inverse()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::inverse ( ) const
Here is the caller graph for this function:

◆ invert()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model & libff::Fp_model< n, modulus >::invert ( )

◆ is_zero()

template<mp_size_t n, const bigint< n > & modulus>
bool libff::Fp_model< n, modulus >::is_zero ( ) const
Here is the caller graph for this function:

◆ modulus_is_valid()

template<mp_size_t n, const bigint< n > & modulus>
static bool libff::Fp_model< n, modulus >::modulus_is_valid ( )
inlinestatic

Definition at line 66 of file fp.hpp.

66{ return modulus.data[n-1] != 0; } // mpn inverse assumes that highest limb is non-zero
Here is the caller graph for this function:

◆ mul_reduce()

template<mp_size_t n, const bigint< n > & modulus>
void libff::Fp_model< n, modulus >::mul_reduce ( const bigint< n > & other)

◆ one()

template<mp_size_t n, const bigint< n > & modulus>
static Fp_model< n, modulus > libff::Fp_model< n, modulus >::one ( )
static

◆ operator!=()

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

◆ operator*()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::operator* ( const Fp_model< n, modulus > & other) const

◆ operator*=()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model & libff::Fp_model< n, modulus >::operator*= ( const Fp_model< n, modulus > & other)

◆ operator+()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::operator+ ( const Fp_model< n, modulus > & other) const

◆ operator+=()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model & libff::Fp_model< n, modulus >::operator+= ( const Fp_model< n, modulus > & other)

◆ operator-() [1/2]

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::operator- ( ) const

◆ operator-() [2/2]

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::operator- ( const Fp_model< n, modulus > & other) const

◆ operator-=()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model & libff::Fp_model< n, modulus >::operator-= ( const Fp_model< n, modulus > & other)

◆ operator==()

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

◆ operator^() [1/2]

template<mp_size_t n, const bigint< n > & modulus>
template<mp_size_t m>
Fp_model libff::Fp_model< n, modulus >::operator^ ( const bigint< m > & pow) const

◆ operator^() [2/2]

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::operator^ ( const unsigned long pow) const

◆ operator^=() [1/2]

template<mp_size_t n, const bigint< n > & modulus>
template<mp_size_t m>
Fp_model & libff::Fp_model< n, modulus >::operator^= ( const bigint< m > & pow)

◆ operator^=() [2/2]

template<mp_size_t n, const bigint< n > & modulus>
Fp_model & libff::Fp_model< n, modulus >::operator^= ( const unsigned long pow)

◆ print()

template<mp_size_t n, const bigint< n > & modulus>
void libff::Fp_model< n, modulus >::print ( ) const
Here is the caller graph for this function:

◆ random_element()

template<mp_size_t n, const bigint< n > & modulus>
static Fp_model< n, modulus > libff::Fp_model< n, modulus >::random_element ( )
static
Here is the caller graph for this function:

◆ set_ulong()

template<mp_size_t n, const bigint< n > & modulus>
void libff::Fp_model< n, modulus >::set_ulong ( const unsigned long x)

◆ size_in_bits()

template<mp_size_t n, const bigint< n > & modulus>
static size_t libff::Fp_model< n, modulus >::size_in_bits ( )
inlinestatic

Definition at line 114 of file fp.hpp.

114{ return num_bits; }
Here is the caller graph for this function:

◆ sqrt()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::sqrt ( ) const

◆ squared()

template<mp_size_t n, const bigint< n > & modulus>
Fp_model libff::Fp_model< n, modulus >::squared ( ) const
Here is the caller graph for this function:

◆ zero()

template<mp_size_t n, const bigint< n > & modulus>
static Fp_model< n, modulus > libff::Fp_model< n, modulus >::zero ( )
static

Friends And Related Symbol Documentation

◆ operator

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

◆ operator>>

template<mp_size_t n, const bigint< n > & modulus>
std::istream & operator>> ( std::istream & in,
Fp_model< n, modulus > & p )
friend

Member Data Documentation

◆ euler

template<mp_size_t n, const bigint< n > & modulus>
bigint< n > libff::Fp_model< n, modulus >::euler
static

Definition at line 54 of file fp.hpp.

◆ inv

template<mp_size_t n, const bigint< n > & modulus>
mp_limb_t libff::Fp_model< n, modulus >::inv
static

Definition at line 62 of file fp.hpp.

◆ mod

template<mp_size_t n, const bigint< n > & modulus>
const constexpr bigint<n>& libff::Fp_model< n, modulus >::mod = modulus
staticconstexpr

Definition at line 45 of file fp.hpp.

◆ mont_repr

template<mp_size_t n, const bigint< n > & modulus>
bigint<n> libff::Fp_model< n, modulus >::mont_repr

Definition at line 42 of file fp.hpp.

◆ multiplicative_generator

template<mp_size_t n, const bigint< n > & modulus>
Fp_model< n, modulus > libff::Fp_model< n, modulus >::multiplicative_generator
static

Definition at line 60 of file fp.hpp.

◆ nqr

template<mp_size_t n, const bigint< n > & modulus>
Fp_model< n, modulus > libff::Fp_model< n, modulus >::nqr
static

Definition at line 58 of file fp.hpp.

◆ nqr_to_t

template<mp_size_t n, const bigint< n > & modulus>
Fp_model< n, modulus > libff::Fp_model< n, modulus >::nqr_to_t
static

Definition at line 59 of file fp.hpp.

◆ num_bits

template<mp_size_t n, const bigint< n > & modulus>
size_t libff::Fp_model< n, modulus >::num_bits
static

Definition at line 53 of file fp.hpp.

◆ num_limbs

template<mp_size_t n, const bigint< n > & modulus>
const mp_size_t libff::Fp_model< n, modulus >::num_limbs = n
static

Definition at line 44 of file fp.hpp.

◆ Rcubed

template<mp_size_t n, const bigint< n > & modulus>
bigint< n > libff::Fp_model< n, modulus >::Rcubed
static

Definition at line 64 of file fp.hpp.

◆ root_of_unity

template<mp_size_t n, const bigint< n > & modulus>
Fp_model< n, modulus > libff::Fp_model< n, modulus >::root_of_unity
static

Definition at line 61 of file fp.hpp.

◆ Rsquared

template<mp_size_t n, const bigint< n > & modulus>
bigint< n > libff::Fp_model< n, modulus >::Rsquared
static

Definition at line 63 of file fp.hpp.

◆ s

template<mp_size_t n, const bigint< n > & modulus>
size_t libff::Fp_model< n, modulus >::s
static

Definition at line 55 of file fp.hpp.

◆ t

template<mp_size_t n, const bigint< n > & modulus>
bigint< n > libff::Fp_model< n, modulus >::t
static

Definition at line 56 of file fp.hpp.

◆ t_minus_1_over_2

template<mp_size_t n, const bigint< n > & modulus>
bigint< n > libff::Fp_model< n, modulus >::t_minus_1_over_2
static

Definition at line 57 of file fp.hpp.


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