Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
loop_test.cpp File Reference
#include "bn.h"
#include "test_point.hpp"
Include dependency graph for loop_test.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 10 of file loop_test.cpp.

11{
12#ifdef BN_SUPPORT_SNARK
13 puts("snark");
14 bn::CurveParam cp = bn::CurveSNARK1;
15#else
16 puts("fp254BNb");
18#endif
19 // init my library
21 // prepair a generator
22 const Point& pt = selectPoint(cp);
23 const Ec2 g2(
24 Fp2(Fp(pt.g2.aa), Fp(pt.g2.ab)),
25 Fp2(Fp(pt.g2.ba), Fp(pt.g2.bb))
26 );
27 const Ec1 g1(pt.g1.a, pt.g1.b);
28 Fp12 e, ea, ea1, ea2;
29 Ec2 g2a;
30 Ec1 g1a;
31 // calc e : G2 x G1 -> G3 pairing
32 opt_atePairing(e, g2, g1); // e = e(g2, g1)
33 mie::Vuint a("0x18b48dddfb2f81cc829b4b9acd393ccb1e90909aabe126bcdbe6a96438eaf313");
34 for (int i = 0; i < 3000; i++) {
35 ea = power(e, a);
36 g1a = g1 * a;
37 g2a = g2 * a;
38 opt_atePairing(ea1, g2, g1a); // ea1 = e(g2, g1a)
39 opt_atePairing(ea2, g2a, g1); // ea2 = e(g2a, g1)
40 if (ea != ea1 || ea != ea2) {
41 printf("ERR i=%d\n", i);
42 PUT(a);
43 PUT(ea);
44 PUT(ea1);
45 PUT(ea2);
46 exit(1);
47 }
48 a -= 1;
49 }
50 puts("ok");
51}
#define PUT(x)
Definition java_api.cpp:8
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
mie::Fp Fp
Definition bn.h:2952
const CurveParam CurveFp254BNb
Definition bn.h:84
void opt_atePairing(Fp12T< Fp6T< Fp2T< Fp > > > &f, const Fp2T< Fp > Q[2], const Fp P[2])
Definition bn.h:2720
Fp2T< Fp > Fp2
Definition bn.h:2954
T power(const T &x, const S &y)
Definition zm.h:1389
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
struct Point::G2 g2
struct Point::G1 g1
static void init(const CurveParam &cp, int mode=-1, bool useMulx=true)
Definition bn.h:206
const Point & selectPoint(const bn::CurveParam &cp)
Here is the call graph for this function: