refactor namespace

dev
MITSUNARI Shigeo 7 years ago
parent e53ae142e8
commit ede0f9b207
  1. 1717
      include/mcl/bn.hpp
  2. 27
      test/bench.hpp
  3. 8
      test/bls12_test.cpp
  4. 2
      test/bn384_test.cpp
  5. 2
      test/bn512_test.cpp
  6. 8
      test/bn_test.cpp

File diff suppressed because it is too large Load Diff

@ -1,10 +1,9 @@
template<class CT>
void testBench(const G1& P, const G2& Q)
{
G1 Pa;
G2 Qa;
Fp12 e1, e2;
CT::pairing(e1, P, Q);
pairing(e1, P, Q);
Fp12::pow(e2, e1, 12345);
const int C = 500;
const int C2 = 1000;
@ -26,22 +25,22 @@ void testBench(const G1& P, const G2& Q)
CYBOZU_BENCH_C("G2::add ", C, G2::add, Qa, Qa, Q);
CYBOZU_BENCH_C("G2::dbl ", C, G2::dbl, Qa, Qa);
CYBOZU_BENCH_C("GT::pow ", C, GT::pow, e1, e1, a);
// CYBOZU_BENCH_C("GT::powGLV ", C, CT::param.glv2.pow, e1, e1, a);
// CYBOZU_BENCH_C("GT::powGLV ", C, BN::param.glv2.pow, e1, e1, a);
G1 PP;
G2 QQ;
std::string s;
s = P.getStr();
CYBOZU_BENCH_C("G1::setStr chk", C, PP.setStr, s);
CT::verifyOrderG1(false);
verifyOrderG1(false);
CYBOZU_BENCH_C("G1::setStr ", C, PP.setStr, s);
CT::verifyOrderG1(true);
verifyOrderG1(true);
s = Q.getStr();
CYBOZU_BENCH_C("G2::setStr chk", C, QQ.setStr, s);
CT::verifyOrderG2(false);
verifyOrderG2(false);
CYBOZU_BENCH_C("G2::setStr ", C, QQ.setStr, s);
CT::verifyOrderG2(true);
CYBOZU_BENCH_C("hashAndMapToG1", C, CT::hashAndMapToG1, PP, "abc", 3);
CYBOZU_BENCH_C("hashAndMapToG2", C, CT::hashAndMapToG2, QQ, "abc", 3);
verifyOrderG2(true);
CYBOZU_BENCH_C("hashAndMapToG1", C, hashAndMapToG1, PP, "abc", 3);
CYBOZU_BENCH_C("hashAndMapToG2", C, hashAndMapToG2, QQ, "abc", 3);
CYBOZU_BENCH_C("Fp::add ", C2, Fp::add, x, x, y);
CYBOZU_BENCH_C("Fp::mul ", C2, Fp::mul, x, x, y);
CYBOZU_BENCH_C("Fp::sqr ", C2, Fp::sqr, x, x);
@ -51,10 +50,10 @@ void testBench(const G1& P, const G2& Q)
CYBOZU_BENCH_C("GT::mul ", C2, GT::mul, e1, e1, e2);
CYBOZU_BENCH_C("GT::sqr ", C2, GT::sqr, e1, e1);
CYBOZU_BENCH_C("GT::inv ", C2, GT::inv, e1, e1);
CYBOZU_BENCH_C("pairing ", C, CT::pairing, e1, P, Q);
CYBOZU_BENCH_C("millerLoop ", C, CT::millerLoop, e1, P, Q);
CYBOZU_BENCH_C("finalExp ", C, CT::finalExp, e1, e1);
CYBOZU_BENCH_C("pairing ", C, pairing, e1, P, Q);
CYBOZU_BENCH_C("millerLoop ", C, millerLoop, e1, P, Q);
CYBOZU_BENCH_C("finalExp ", C, finalExp, e1, e1);
std::vector<Fp6> Qcoeff;
CT::precomputeG2(Qcoeff, Q);
CYBOZU_BENCH_C("precomputedML ", C, CT::precomputedMillerLoop, e2, P, Qcoeff);
precomputeG2(Qcoeff, Q);
CYBOZU_BENCH_C("precomputedML ", C, precomputedMillerLoop, e2, P, Qcoeff);
}

@ -320,7 +320,7 @@ CYBOZU_TEST_AUTO(naive)
testPairing(P, Q, ts.e);
testPrecomputed(P, Q);
testMillerLoop2(P, Q);
testBench<BN>(P, Q);
testBench(P, Q);
}
int count = (int)clk.getCount();
if (count) {
@ -430,7 +430,7 @@ const char *r1Str =
l.a.setStr(l0Str, mode);
l.b.setStr(l4Str, mode);
l.c.setStr(l1Str, mode);
BN::addLine(l, R, Q, P);
local::addLine(l, R, Q, P);
m.a.setStr(m0Str, mode);
m.b.setStr(m4Str, mode);
m.c.setStr(m1Str, mode);
@ -494,7 +494,7 @@ const char *q1Str =
l.a.setStr(l0Str, mode);
l.b.setStr(l4Str, mode);
l.c.setStr(l1Str, mode);
BN::dblLine(l, Q, P);
local::dblLine(l, Q, P);
m.a.setStr(m0Str, mode);
m.b.setStr(m4Str, mode);
m.c.setStr(m1Str, mode);
@ -551,7 +551,7 @@ const char *f2Str =
l.c.setStr(l1Str, 16);
f.setStr(fStr, 16);
f2.setStr(f2Str, 16);
BN::mulSparse(f, l);
local::mulSparse(f, l);
CYBOZU_TEST_EQUAL(f, f2);
}

@ -33,7 +33,7 @@ void testCurve(const mcl::CurveParam& cp)
pairing(e2, aP, bQ);
GT::pow(e1, e1, a * b);
CYBOZU_TEST_EQUAL(e1, e2);
testBench<BN>(P, Q);
testBench(P, Q);
}
CYBOZU_TEST_AUTO(pairing)

@ -33,7 +33,7 @@ void testCurve(const mcl::CurveParam& cp)
pairing(e2, aP, bQ);
GT::pow(e1, e1, a * b);
CYBOZU_TEST_EQUAL(e1, e2);
testBench<BN>(P, Q);
testBench(P, Q);
}
CYBOZU_TEST_AUTO(pairing)

@ -11,7 +11,7 @@ cybozu::CpuClock clk;
#define MCL_AVOID_EXCEPTION_TEST
#endif
typedef mcl::bn256::BN::Compress Compress;
typedef mcl::bn::local::Compress Compress;
using namespace mcl::bn256;
mcl::fp::Mode g_mode;
@ -152,7 +152,7 @@ void testCyclotomic()
for (int i = 0; i < 12; ++i) {
a.getFp0()[i] = i * i;
}
BN::mapToCyclotomic(a, a);
local::mapToCyclotomic(a, a);
Fp12 d;
Compress b(d, a);
a *= a;
@ -171,7 +171,7 @@ void testCompress(const G1& P, const G2& Q)
if (BN::param.cp.curveType != MCL_BN254) return;
Fp12 a;
pairing(a, P, Q);
BN::mapToCyclotomic(a, a);
local::mapToCyclotomic(a, a);
Fp12 b;
Compress::fixed_power(b, a);
Fp12 c;
@ -360,7 +360,7 @@ CYBOZU_TEST_AUTO(naive)
testPairing(P, Q, ts.e);
testPrecomputed(P, Q);
testMillerLoop2(P, Q);
testBench<BN>(P, Q);
testBench(P, Q);
}
int count = (int)clk.getCount();
if (count) {

Loading…
Cancel
Save