Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
minitest.cpp
Go to the documentation of this file.
1#include "bn.h"
2#include "test_point.hpp"
3
4static int errNum = 0;
5const char *expect = "[[[8118772341496577043438385328606447626730215814727396173233264007541007797690,6742571767760762192519140673058087976840103832045324348366170860928670686713],"
6" [9727912590495366720378364920530546614235713408261568635512172059018197267630,10180700148605185348549931182990442059136187839792856455707820203302941578832],"
7" [5054507763444412917986776641611331046146804026682679569910978464879371792565,6917005519826733659554708445125877487590687705432214234949972860245110398023]],"
8" [[10448556317747236258066222816126375978842661908560317699736569642190930635294,1516980358051268127904344653343215863076753141133525905743113718749531324025],"
9" [9794836735385959178744195210089532061310424844916928682580569566332541022353,9375574834170998962484906689780052970915033987453510324648351251071086068423],"
10" [710778048594563655498360873129325895716179849942646859397874562033386335205,10688745994254573144943003027511098295097561129365638275727908595677791826005]]]";
11
12template<class T, class S>
13void verify(const char *msg, const T& a, const S& b)
14{
15 if (a == b) {
16 printf("%s : ok\n", msg);
17 } else {
18 printf("%s : ng\n", msg);
19 PUT(a);
20 PUT(b);
21 errNum++;
22 }
23}
24
25int main()
26 try
27{
28// bn::CurveParam cp = bn::CurveSNARK1;
30 using namespace bn;
31 // init my library
32 Param::init(cp);
33 const Point& pt = selectPoint(cp);
34 const Ec2 g2(
35 Fp2(Fp(pt.g2.aa), Fp(pt.g2.ab)),
36 Fp2(Fp(pt.g2.ba), Fp(pt.g2.bb))
37 );
38 const Ec1 g1(pt.g1.a, pt.g1.b);
39
40 PUT(g1);
41 PUT(g2);
42 Fp12 e1, e2;
43 opt_atePairing(e1, g2, g1);
44 PUT(e1);
45 {
46 std::stringstream ss(expect);
47 ss >> e2;
48 }
49 printf("%s\n", e1 == e2 ? "OK" : "NG");
50} catch (std::exception& e) {
51 printf("ERR %s\n", e.what());
52}
53
54
BN parameter.
#define PUT(x)
Definition java_api.cpp:8
void verify(const char *msg, const T &a, const S &b)
Definition minitest.cpp:13
const char * expect
Definition minitest.cpp:5
int main()
Definition minitest.cpp:25
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
Definition bn.h:56
const CurveParam CurveFp254BNb
Definition bn.h:84
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
#define T(meth, val, expected)
struct Point::G2 g2
struct Point::G1 g1
const Point & selectPoint(const bn::CurveParam &cp)