Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bn::ParamT< Fp2 > Struct Template Reference

#include <bn.h>

Collaboration diagram for bn::ParamT< Fp2 >:

Public Types

typedef Fp2::Fp Fp
 
typedef std::vector< signed char > SignVec
 

Static Public Member Functions

static void init (const CurveParam &cp, int mode=-1, bool useMulx=true)
 
static void init (int mode=-1, bool useMulx=true)
 
template<class T , class U >
static void eval (T &y, const U &x, const int *c)
 

Static Public Attributes

static mie::Vsint z
 
static mie::Vuint p
 
static mie::Vuint r
 
static mie::Vuint t
 
static mie::Vsint largest_c
 
static Fp Z
 
static Fp2 W2p
 
static Fp2 W3p
 
static Fp2 gammar [5]
 
static Fp2 gammar2 [5]
 
static Fp2 gammar3 [5]
 
static Fp i0
 
static Fp i1
 
static int b
 
static Fp2 b_invxi
 
static Fp half
 
static SignVec siTbl
 
static bool useNAF
 

Detailed Description

template<class Fp2>
struct bn::ParamT< Fp2 >

Definition at line 179 of file bn.h.

Member Typedef Documentation

◆ Fp

Definition at line 180 of file bn.h.

◆ SignVec

template<class Fp2 >
std::vector<signed char> bn::ParamT< Fp2 >::SignVec

Definition at line 199 of file bn.h.

Member Function Documentation

◆ eval()

template<class Fp2 >
template<class T , class U >
static void bn::ParamT< Fp2 >::eval ( T & y,
const U & x,
const int * c )
inlinestatic

Definition at line 276 of file bn.h.

276 {
277 U tmp = (((c[4] * x + c[3]) * x + c[2]) * x + c[1]) * x + c[0];
278 y = tmp.get();
279 }
uint64_t y
Definition sha3.cpp:34
Definition dtoa.c:306
Here is the caller graph for this function:

◆ init() [1/2]

template<class Fp2 >
static void bn::ParamT< Fp2 >::init ( const CurveParam & cp,
int mode = -1,
bool useMulx = true )
inlinestatic

Definition at line 206 of file bn.h.

207 {
208#ifdef BN_SUPPORT_SNARK
209 bool supported = cp == CurveSNARK1 || cp == CurveSNARK2;
210#else
211 bool supported = cp == CurveFp254BNb;
212#endif
213 if (!supported) {
214 fprintf(stderr, "not supported parameter\n");
215 exit(1);
216 }
217 mie::zmInit();
218 const int64_t org_z = cp.z; // NOTE: hard-coded Fp12::pow_neg_t too.
219 const int pCoff[] = { 1, 6, 24, 36, 36 };
220 const int rCoff[] = { 1, 6, 18, 36, 36 };
221 const int tCoff[] = { 1, 0, 6, 0, 0 };
222 z.set(org_z);
223 eval(p, z, pCoff);
224 eval(r, z, rCoff);
225 eval(t, z, tCoff);
226 largest_c = 6 * z + 2;
227 b = cp.b; // set b before calling Fp::setModulo
228 Fp::setModulo(p, mode, useMulx);
229 half = Fp(1) / Fp(2);
230 /*
231 b_invxi = b / xi
232 */
233 Fp2 xi(cp.xi_a, cp.xi_b);
234 b_invxi = xi;
236 b_invxi *= Fp2(b, 0);
237 gammar[0] = mie::power(xi, (p - 1) / 6);
238
239 for (size_t i = 1; i < sizeof(gammar) / sizeof(*gammar); ++i) {
240 gammar[i] = gammar[i - 1] * gammar[0];
241 }
242
243 for (size_t i = 0; i < sizeof(gammar2) / sizeof(*gammar2); ++i) {
244 gammar2[i] = Fp2(gammar[i].a_, -gammar[i].b_) * gammar[i];
245 }
246
247 for (size_t i = 0; i < sizeof(gammar2) / sizeof(*gammar2); ++i) {
248 gammar3[i] = gammar[i] * gammar2[i];
249 }
250
251 W2p = mie::power(xi, (p - 1) / 3);
252 W3p = mie::power(xi, (p - 1) / 2);
253 Fp2 temp = mie::power(xi, (p * p - 1) / 6);
254 assert(temp.b_.isZero());
255 Fp::square(Z, -temp.a_);
256 i0 = 0;
257 i1 = 1;
258
260#ifdef BN_SUPPORT_SNARK
261 util::getGoodRepl(zReplTbl, z.abs());
262#endif
263 }
static void setModulo(const mie::Vuint &p, int mode, bool useMulx=true, bool definedBN_SUPPORT_SNARK=false)
Definition zm2.cpp:3592
static void square(Fp &out, const Fp &x)
Definition zm2.h:282
V abs() const
Definition zm.h:1149
void set(value_type x)
Definition zm.h:982
bool getGoodRepl(Vec &v, const mie::Vuint &x)
Definition bn.h:159
const CurveParam CurveFp254BNb
Definition bn.h:84
Fp2T< Fp > Fp2
Definition bn.h:2954
void zmInit()
Definition zm.cpp:557
T power(const T &x, const S &y)
Definition zm.h:1389
signed __int64 int64_t
Definition stdint.h:135
void inverse()
Definition bn.h:505
static int b
Definition bn.h:194
static Fp Z
Definition bn.h:186
Fp2::Fp Fp
Definition bn.h:180
static SignVec siTbl
Definition bn.h:200
static mie::Vuint t
Definition bn.h:184
static Fp i1
Definition bn.h:193
static mie::Vuint p
Definition bn.h:182
static mie::Vsint largest_c
Definition bn.h:185
static mie::Vuint r
Definition bn.h:183
static Fp2 W2p
Definition bn.h:187
static Fp2 W3p
Definition bn.h:188
static bool useNAF
Definition bn.h:201
static Fp2 gammar[5]
Definition bn.h:189
static Fp2 gammar2[5]
Definition bn.h:190
static Fp2 gammar3[5]
Definition bn.h:191
static mie::Vsint z
Definition bn.h:181
static Fp i0
Definition bn.h:192
static void eval(T &y, const U &x, const int *c)
Definition bn.h:276
static Fp half
Definition bn.h:196
static Fp2 b_invxi
Definition bn.h:195
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/2]

template<class Fp2 >
static void bn::ParamT< Fp2 >::init ( int mode = -1,
bool useMulx = true )
inlinestatic

Definition at line 264 of file bn.h.

265 {
266#ifdef BN_SUPPORT_SNARK
267 init(CurveSNARK1, mode, useMulx);
268#else
269 init(CurveFp254BNb, mode, useMulx);
270#endif
271 }
void init()
Definition lib_test.cpp:3
Here is the call graph for this function:

Member Data Documentation

◆ b

template<class Fp2 >
int bn::ParamT< Fp2 >::b
static

Definition at line 194 of file bn.h.

◆ b_invxi

template<class Fp2 >
Fp2 bn::ParamT< Fp2 >::b_invxi
static

Definition at line 195 of file bn.h.

◆ gammar

template<class Fp2 >
Fp2 bn::ParamT< Fp2 >::gammar
static

Definition at line 189 of file bn.h.

◆ gammar2

template<class Fp2 >
Fp2 bn::ParamT< Fp2 >::gammar2
static

Definition at line 190 of file bn.h.

◆ gammar3

template<class Fp2 >
Fp2 bn::ParamT< Fp2 >::gammar3
static

Definition at line 191 of file bn.h.

◆ half

template<class Fp2 >
Fp2::Fp bn::ParamT< Fp2 >::half
static

Definition at line 196 of file bn.h.

◆ i0

template<class Fp2 >
Fp2::Fp bn::ParamT< Fp2 >::i0
static

Definition at line 192 of file bn.h.

◆ i1

template<class Fp2 >
Fp2::Fp bn::ParamT< Fp2 >::i1
static

Definition at line 193 of file bn.h.

◆ largest_c

template<class Fp2 >
mie::Vsint bn::ParamT< Fp2 >::largest_c
static

Definition at line 185 of file bn.h.

◆ p

template<class Fp2 >
mie::Vuint bn::ParamT< Fp2 >::p
static

Definition at line 182 of file bn.h.

◆ r

template<class Fp2 >
mie::Vuint bn::ParamT< Fp2 >::r
static

Definition at line 183 of file bn.h.

◆ siTbl

template<class Fp2 >
ParamT< Fp2 >::SignVec bn::ParamT< Fp2 >::siTbl
static

Definition at line 200 of file bn.h.

◆ t

template<class Fp2 >
mie::Vuint bn::ParamT< Fp2 >::t
static

Definition at line 184 of file bn.h.

◆ useNAF

template<class Fp2 >
bool bn::ParamT< Fp2 >::useNAF
static

Definition at line 201 of file bn.h.

◆ W2p

template<class Fp2 >
Fp2 bn::ParamT< Fp2 >::W2p
static

Definition at line 187 of file bn.h.

◆ W3p

template<class Fp2 >
Fp2 bn::ParamT< Fp2 >::W3p
static

Definition at line 188 of file bn.h.

◆ Z

template<class Fp2 >
Fp2::Fp bn::ParamT< Fp2 >::Z
static

Definition at line 186 of file bn.h.

◆ z

template<class Fp2 >
mie::Vsint bn::ParamT< Fp2 >::z
static

Definition at line 181 of file bn.h.


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