23{
25
26 Param::init(cp);
27
33 };
34 const Fp g1[3] = { pt.
g1.a, pt.
g1.b, 1 };
35
36 verify(
"g1 is on EC", ecop::isOnECJac3(g1),
true);
37 verify(
"g2 is on twist EC", ecop::isOnTwistECJac3(g2),
true);
38 puts("order of group");
42 {
44 ecop::ScalarMult(t, g1, Param::r);
45
46 verify(
"orgder of g1 == r", t[2], 0);
47 }
48 {
50 ecop::ScalarMult(t, g2, Param::r);
51 verify(
"order of g2 == r", t[2], 0);
52 }
53 const char *aStr = "123456789012345";
54 const char *bStr = "998752342342342342424242421";
57
58
59 {
65
66 ecop::ScalarMult(Pa, g1,
a);
67 ecop::ScalarMult(Pb, g1, b);
68 ecop::ScalarMult(Pc, g1, c);
69 ecop::ECAdd(out, Pa, Pb);
70 ecop::NormalizeJac(Pc, Pc);
71 ecop::NormalizeJac(out, out);
72 std::cout << std::hex;
73 verify(
"check g1 * c = g1 * a + g1 * b", Pc[0] == out[0] && Pc[1] == out[1] && Pc[2] == out[2],
true);
74
75#ifdef MIE_ATE_USE_GMP
76 {
77 mpz_class aa(aStr);
78 mpz_class bb(bStr);
79 mpz_class cc = aa + bb;
83 ecop::ScalarMult(Paa, g1, aa);
84 ecop::ScalarMult(Pbb, g1, bb);
85 ecop::ScalarMult(Pcc, g1, cc);
86 ecop::NormalizeJac(Pcc, Pcc);
87 verify(
"gmp Paa == Pa", Paa[0] == Pa[0] && Paa[1] == Pa[1] && Paa[2] == Pa[2],
true);
88 verify(
"gmp Pbb == Pb", Pbb[0] == Pb[0] && Pbb[1] == Pb[1] && Pbb[2] == Pb[2],
true);
89 verify(
"gmp Pcc == Pc", Pcc[0] == Pc[0] && Pcc[1] == Pc[1] && Pcc[2] == Pc[2],
true);
90 }
91#endif
92 }
93
95
96 opt_atePairingJac<Fp>(e, g2, g1);
98 {
100 verify(
"order of e == r", t, 1);
101 }
103 ecop::ScalarMult(g2a, g2,
a);
105 opt_atePairingJac<Fp>(ea1, g2a, g1);
107 verify(
"e(g2 * a, g1) = e(g2, g1)^a", ea1, ea2);
108
110 ecop::ScalarMult(g1b, g1, b);
112 opt_atePairingJac<Fp>(eb1, g2, g1b);
114 verify(
"e(g2a, g1 * b) = e(g2, g1)^b", eb1, eb2);
115
117 ecop::ScalarMult(q1, g1, 12345);
118
119 verify(
"q1 is on EC", ecop::isOnECJac3(q1),
true);
121 opt_atePairingJac<Fp>(e1, g2, g1);
122 opt_atePairingJac<Fp>(e2, g2, q1);
124 ecop::ECAdd(q2, g1, q1);
125 opt_atePairingJac<Fp>(e, g2, q2);
126 verify(
"e = e1 * e2", e, e1 * e2);
127}
T power(const T &x, const S &y)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
void verify(const char *msg, const T &a, const S &b)