forked from jancarlsson/snarkfront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitPairing.cpp
56 lines (42 loc) · 1.75 KB
/
InitPairing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <cassert>
#include "InitPairing.hpp"
namespace snarkfront {
////////////////////////////////////////////////////////////////////////////////
// Barreto-Naehrig 128 bits
//
const snarklib::BigInt<snarklib::BN128_Modulus::r_limbs>
BN128_MODULUS_R = snarklib::BN128::modulus_r();
const snarklib::BigInt<snarklib::BN128_Modulus::q_limbs>
BN128_MODULUS_Q = snarklib::BN128::modulus_q();
// initialize elliptic curve parameters
void init_BN128() {
typedef snarklib::BN128 CURVE;
// the R and Q modulus should be about the same size for GMP
#ifdef USE_ASSERT
assert(CURVE::r_limbs == CURVE::q_limbs);
#endif
// critically important to initialize finite field and group parameters
CURVE::Fields<BN128_NRQ, BN128_MODULUS_R>::initParams();
CURVE::Fields<BN128_NRQ, BN128_MODULUS_Q>::initParams();
CURVE::Groups<BN128_NRQ, BN128_MODULUS_R, BN128_MODULUS_Q>::initParams();
}
////////////////////////////////////////////////////////////////////////////////
// Edwards 80 bits
//
const snarklib::BigInt<snarklib::Edwards_Modulus::r_limbs>
EDWARDS_MODULUS_R = snarklib::Edwards::modulus_r();
const snarklib::BigInt<snarklib::Edwards_Modulus::q_limbs>
EDWARDS_MODULUS_Q = snarklib::Edwards::modulus_q();
// initialize elliptic curve parameters
void init_Edwards() {
typedef snarklib::Edwards CURVE;
// the R and Q modulus should be about the same size for GMP
#ifdef USE_ASSERT
assert(CURVE::r_limbs == CURVE::q_limbs);
#endif
// critically important to initialize finite field and group parameters
CURVE::Fields<EDWARDS_NRQ, EDWARDS_MODULUS_R>::initParams();
CURVE::Fields<EDWARDS_NRQ, EDWARDS_MODULUS_Q>::initParams();
CURVE::Groups<EDWARDS_NRQ, EDWARDS_MODULUS_R, EDWARDS_MODULUS_Q>::initParams();
}
} // namespace snarkfront