Clearmatics Libff
0.1
C++ library for Finite Fields and Elliptic Curves
|
Go to the documentation of this file.
20 template<mp_
size_t n, const big
int<n> &modulus>
class Fp_model;
22 template<mp_
size_t n, const big
int<n> &modulus>
25 template<mp_
size_t n, const big
int<n> &modulus>
38 template<mp_
size_t n, const big
int<n> &modulus>
class Fp_model
49 #ifdef PROFILE_OP_COUNTS
50 static long long add_cnt;
51 static long long sub_cnt;
52 static long long mul_cnt;
53 static long long sqr_cnt;
54 static long long inv_cnt;
86 return modulus.data[n - 1] != 0;
91 Fp_model(
const long x,
const bool is_unsigned =
false);
156 friend std::ostream &operator<<<n, modulus>(
158 friend std::istream &
operator>>
162 #ifdef PROFILE_OP_COUNTS
163 template<mp_
size_t n, const big
int<n> &modulus>
166 template<mp_
size_t n, const big
int<n> &modulus>
169 template<mp_
size_t n, const big
int<n> &modulus>
172 template<mp_
size_t n, const big
int<n> &modulus>
175 template<mp_
size_t n, const big
int<n> &modulus>
179 template<mp_
size_t n, const big
int<n> &modulus>
182 template<mp_
size_t n, const big
int<n> &modulus>
187 template<mp_
size_t n, const big
int<n> &modulus>
190 template<mp_
size_t n, const big
int<n> &modulus>
193 template<mp_
size_t n, const big
int<n> &modulus>
196 template<mp_
size_t n, const big
int<n> &modulus>
199 template<mp_
size_t n, const big
int<n> &modulus>
202 template<mp_
size_t n, const big
int<n> &modulus>
205 template<mp_
size_t n, const big
int<n> &modulus>
208 template<mp_
size_t n, const big
int<n> &modulus>
211 template<mp_
size_t n, const big
int<n> &modulus>
static Fp_model< n, modulus > s_zero
void set_ulong(const unsigned long x)
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
void mul_reduce(const bigint< n > &other)
static Fp_model< n, modulus > arithmetic_generator()
generator++, for k = 1 to m, domain size m
static Fp_model< n, modulus > nqr
a quadratic nonresidue
static const Fp_model< n, modulus > & zero()
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
static bigint< n > t
with t odd
static size_t s
modulus = 2^s * t + 1
bool operator!=(const Fp_model &other) const
static bigint< n > euler
(modulus-1)/2
static bool modulus_is_valid()
Fp_model operator^(const unsigned long pow) const
Fp_model & operator*=(const Fp_model &other)
Fp_model sqrt() const
HAS TO BE A SQUARE (else does not terminate)
static const Fp_model< n, modulus > & one()
static size_t size_in_bits()
Fp_model operator-() const
Fp_model & operator+=(const Fp_model &other)
static bigint< n > t_minus_1_over_2
(t-1)/2
static const mp_size_t num_limbs
Fp_model & operator^=(const unsigned long pow)
Fp_model operator*(const Fp_model &other) const
static void static_init()
static Fp_model< n, modulus > root_of_unity
generator^((modulus-1)/2^s)
bool operator==(const Fp_model &other) const
Fp_model & operator-=(const Fp_model &other)
static const bigint< n > & field_char()
bigint< n > as_bigint() const
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
static Fp_model< n, modulus > nqr_to_t
nqr^t
static Fp_model< n, modulus > multiplicative_generator
generator of Fp^*
Fp_model operator+(const Fp_model &other) const
static Fp_model< n, modulus > geometric_generator()
generator^k, for k = 1 to m, domain size m
static mp_limb_t inv
-modulus^(-1) mod W, where W = 2^(word size)
Fp_model< n, modulus > my_Fp
static const size_t tower_extension_degree
The "base"/"ground" field.
static const constexpr bigint< n > & mod
unsigned long as_ulong() const
static bigint< n > Rsquared
R^2, where R = W^k, where k = ??
static constexpr size_t extension_degree()
static bigint< n > Rcubed
R^3.
static bool s_initialized
static Fp_model< n, modulus > s_one