34 const Fp g1[3] = { pt.
g1.a, pt.
g1.b, 1 };
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");
44 ecop::ScalarMult(t, g1, Param::r);
46 verify(
"orgder of g1 == r", t[2], 0);
50 ecop::ScalarMult(t, g2, Param::r);
51 verify(
"order of g2 == r", t[2], 0);
53 const char *aStr =
"123456789012345";
54 const char *bStr =
"998752342342342342424242421";
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);
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);
96 opt_atePairingJac<Fp>(e, g2, g1);
99 Fp12 t = power(e, Param::r);
100 verify(
"order of e == r", t, 1);
103 ecop::ScalarMult(g2a, g2,
a);
105 opt_atePairingJac<Fp>(ea1, g2a, g1);
106 Fp12 ea2 = power(e,
a);
107 verify(
"e(g2 * a, g1) = e(g2, g1)^a", ea1, ea2);
110 ecop::ScalarMult(g1b, g1, b);
112 opt_atePairingJac<Fp>(eb1, g2, g1b);
113 Fp12 eb2 = power(e, b);
114 verify(
"e(g2a, g1 * b) = e(g2, g1)^b", eb1, eb2);
117 ecop::ScalarMult(q1, g1, 12345);
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);
139 const Ec1 g1(pt.
g1.a, pt.
g1.b);
143 puts(
"order of group");
146 Ec1 t = g1 * Param::r;
151 Ec2 t = g2 * Param::r;
155 const char *aStr =
"123456789012345";
156 const char *bStr =
"998752342342342342424242421";
168 verify(
"check g1 * c = g1 * a + g1 * b", Pc, out);
169#ifdef MIE_ATE_USE_GMP
173 mpz_class cc = aa + bb;
177 verify(
"gmp Paa == Pa", Paa, Pa);
178 verify(
"gmp Pbb == Pb", Pbb, Pb);
179 verify(
"gmp Pcc == Pc", Pcc, Pc);
186 opt_atePairing(e, g2, g1);
189 Fp12 t = power(e, Param::r);
190 verify(
"order of e == r", t, 1);
195 opt_atePairing(ea1, g2a, g1);
196 Fp12 ea2 = power(e,
a);
197 verify(
"e(g2 * a, g1) = e(g2, g1)^a", ea1, ea2);
202 opt_atePairing(eb1, g2, g1b);
203 Fp12 eb2 = power(e, b);
204 verify(
"e(g2a, g1 * b) = e(g2, g1)^b", eb1, eb2);
209 opt_atePairing(e1, g2, g1);
210 opt_atePairing(e2, g2, q1);
212 opt_atePairing(e, g2, q2);
213 verify(
"e = e1 * e2", e, e1 * e2);
220 verify(
"g2a == g2 * a", g2a, g2 *
a);
221 verify(
"g1b == g1 * b", g1b, g1 * b);