|
Clearmatics Libff
0.1
C++ library for Finite Fields and Elliptic Curves
|
#include <fp.hpp>
Public Types | |
| typedef Fp_model< n, modulus > | my_Fp |
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_model & | operator+= (const Fp_model &other) |
| Fp_model & | operator-= (const Fp_model &other) |
| Fp_model & | operator*= (const Fp_model &other) |
| Fp_model & | operator^= (const unsigned long pow) |
| template<mp_size_t m> | |
| Fp_model & | operator^= (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_model & | invert () |
| Fp_model | inverse () const |
| Fp_model | sqrt () const |
| HAS TO BE A SQUARE (else does not terminate) More... | |
| 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 void | static_init () |
| static bool | modulus_is_valid () |
| static size_t | size_in_bits () |
| static size_t | capacity () |
| static const bigint< n > & | field_char () |
| static constexpr size_t | extension_degree () |
| static const Fp_model< n, modulus > & | zero () |
| static const Fp_model< n, modulus > & | one () |
| static Fp_model< n, modulus > | random_element () |
| returns random element of Fp_model More... | |
| static Fp_model< n, modulus > | geometric_generator () |
| generator^k, for k = 1 to m, domain size m More... | |
| static Fp_model< n, modulus > | arithmetic_generator () |
| generator++, for k = 1 to m, domain size m More... | |
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 const size_t | tower_extension_degree = 1 |
| The "base"/"ground" field. More... | |
| static size_t | num_bits |
| static bigint< n > | euler |
| (modulus-1)/2 More... | |
| static size_t | s |
| modulus = 2^s * t + 1 More... | |
| static bigint< n > | t |
| with t odd More... | |
| static bigint< n > | t_minus_1_over_2 |
| (t-1)/2 More... | |
| static Fp_model< n, modulus > | nqr |
| a quadratic nonresidue More... | |
| static Fp_model< n, modulus > | nqr_to_t |
| nqr^t More... | |
| static Fp_model< n, modulus > | multiplicative_generator |
| generator of Fp^* More... | |
| static Fp_model< n, modulus > | root_of_unity |
| generator^((modulus-1)/2^s) More... | |
| static mp_limb_t | inv |
| -modulus^(-1) mod W, where W = 2^(word size) More... | |
| static bigint< n > | Rsquared |
| R^2, where R = W^k, where k = ?? More... | |
| static bigint< n > | Rcubed |
| R^3. More... | |
Static Protected Attributes | |
| static bool | s_initialized |
| static Fp_model< n, modulus > | s_zero |
| static Fp_model< n, modulus > | s_one |
Friends | |
| std::ostream & | operator (std::ostream &out, const Fp_model< n, modulus > &p) |
| std::istream & | operator>> (std::istream &in, Fp_model< n, modulus > &p) |
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.
| typedef Fp_model<n, modulus> libff::Fp_model< n, modulus >::my_Fp |
|
inline |
| libff::Fp_model< n, modulus >::Fp_model | ( | const bigint< n > & | b | ) |
| libff::Fp_model< n, modulus >::Fp_model | ( | const long | x, |
| const bool | is_unsigned = false |
||
| ) |
|
static |
generator++, for k = 1 to m, domain size m
| bigint<n> libff::Fp_model< n, modulus >::as_bigint | ( | ) | const |
Return the standard (not Montgomery) representation of the Field element's requivalence class. I.e. Fp(2).as_bigint() would return bigint(2)
| unsigned long libff::Fp_model< n, modulus >::as_ulong | ( | ) | const |
Return the last limb of the standard representation of the field element. E.g. on 64-bit architectures Fp(123).as_ulong() and Fp(2^64+123).as_ulong() would both return 123.
|
inlinestatic |
| void libff::Fp_model< n, modulus >::clear | ( | ) |

|
inlinestaticconstexpr |
|
inlinestatic |
|
static |
generator^k, for k = 1 to m, domain size m
| Fp_model libff::Fp_model< n, modulus >::inverse | ( | ) | const |

| Fp_model& libff::Fp_model< n, modulus >::invert | ( | ) |
| bool libff::Fp_model< n, modulus >::is_zero | ( | ) | const |

|
inlinestatic |
| void libff::Fp_model< n, modulus >::mul_reduce | ( | const bigint< n > & | other | ) |
|
static |
| bool libff::Fp_model< n, modulus >::operator!= | ( | const Fp_model< n, modulus > & | other | ) | const |
| Fp_model libff::Fp_model< n, modulus >::operator* | ( | const Fp_model< n, modulus > & | other | ) | const |
| Fp_model& libff::Fp_model< n, modulus >::operator*= | ( | const Fp_model< n, modulus > & | other | ) |
| Fp_model libff::Fp_model< n, modulus >::operator+ | ( | const Fp_model< n, modulus > & | other | ) | const |
| Fp_model& libff::Fp_model< n, modulus >::operator+= | ( | const Fp_model< n, modulus > & | other | ) |
| Fp_model libff::Fp_model< n, modulus >::operator- | ( | ) | const |
| Fp_model libff::Fp_model< n, modulus >::operator- | ( | const Fp_model< n, modulus > & | other | ) | const |
| Fp_model& libff::Fp_model< n, modulus >::operator-= | ( | const Fp_model< n, modulus > & | other | ) |
| bool libff::Fp_model< n, modulus >::operator== | ( | const Fp_model< n, modulus > & | other | ) | const |
| Fp_model libff::Fp_model< n, modulus >::operator^ | ( | const bigint< m > & | pow | ) | const |
| Fp_model libff::Fp_model< n, modulus >::operator^ | ( | const unsigned long | pow | ) | const |
| Fp_model& libff::Fp_model< n, modulus >::operator^= | ( | const bigint< m > & | pow | ) |
| Fp_model& libff::Fp_model< n, modulus >::operator^= | ( | const unsigned long | pow | ) |
| void libff::Fp_model< n, modulus >::print | ( | ) | const |

|
static |
| void libff::Fp_model< n, modulus >::set_ulong | ( | const unsigned long | x | ) |
|
inlinestatic |
| Fp_model libff::Fp_model< n, modulus >::sqrt | ( | ) | const |
HAS TO BE A SQUARE (else does not terminate)

| Fp_model libff::Fp_model< n, modulus >::squared | ( | ) | const |
|
static |

|
static |
|
friend |
|
friend |
|
static |
|
static |
|
staticconstexpr |
| bigint<n> libff::Fp_model< n, modulus >::mont_repr |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
static |
|
static |
|
static |
1.8.17