add millerLoop2mixed for C

dev
MITSUNARI Shigeo 7 years ago
parent 2713e69d88
commit 5564e669c0
  1. 1
      include/mcl/bn.h
  2. 5
      src/bn_c_impl.hpp
  3. 12
      test/bls12_test.cpp
  4. 4
      test/bn_c_test.hpp
  5. 12
      test/bn_test.cpp

@ -308,6 +308,7 @@ MCLBN_DLL_API void mclBn_precomputeG2(uint64_t *Qbuf, const mclBnG2 *Q);
MCLBN_DLL_API void mclBn_precomputedMillerLoop(mclBnGT *f, const mclBnG1 *P, const uint64_t *Qbuf);
MCLBN_DLL_API void mclBn_precomputedMillerLoop2(mclBnGT *f, const mclBnG1 *P1, const uint64_t *Q1buf, const mclBnG1 *P2, const uint64_t *Q2buf);
MCLBN_DLL_API void mclBn_precomputedMillerLoop2mixed(mclBnGT *f, const mclBnG1 *P1, const mclBnG2 *Q1, const mclBnG1 *P2, const uint64_t *Q2buf);
/*
Lagrange interpolation

@ -451,6 +451,11 @@ void mclBn_precomputedMillerLoop2(mclBnGT *f, const mclBnG1 *P1, const uint64_t
precomputedMillerLoop2(*cast(f), *cast(P1), cast(Q1buf), *cast(P2), cast(Q2buf));
}
void mclBn_precomputedMillerLoop2mixed(mclBnGT *f, const mclBnG1 *P1, const mclBnG2 *Q1, const mclBnG1 *P2, const uint64_t *Q2buf)
{
precomputedMillerLoop2mixed(*cast(f), *cast(P1), *cast(Q1), *cast(P2), cast(Q2buf));
}
int mclBn_FrLagrangeInterpolation(mclBnFr *out, const mclBnFr *xVec, const mclBnFr *yVec, mclSize k)
{
bool b;

@ -231,6 +231,18 @@ void testMillerLoop2(const G1& P1, const G2& Q1)
CYBOZU_TEST_EQUAL(e2, e3);
finalExp(e2, e2);
CYBOZU_TEST_EQUAL(e1, e2);
// special value
G2 Z;
Z.clear();
Q2 += Q2;
precomputeG2(Q1coeff, Z);
precomputeG2(Q2coeff, Q2);
precomputedMillerLoop2(e2, P1, Q1coeff, P2, Q2coeff);
precomputedMillerLoop2mixed(e3, P1, Z, P2, Q2coeff);
finalExp(e2, e2);
finalExp(e3, e3);
CYBOZU_TEST_EQUAL(e2, e3);
}
void testPairing(const G1& P, const G2& Q, const char *eStr)

@ -334,7 +334,7 @@ CYBOZU_TEST_AUTO(precomputed)
mclBn_precomputeG2(Q1buf.data(), &Q1);
mclBn_precomputeG2(Q2buf.data(), &Q2);
mclBnGT e1, e2, f1, f2, f3;
mclBnGT e1, e2, f1, f2, f3, f4;
mclBn_pairing(&e1, &P1, &Q1);
mclBn_precomputedMillerLoop(&f1, &P1, Q1buf.data());
mclBn_finalExp(&f1, &f1);
@ -346,6 +346,8 @@ CYBOZU_TEST_AUTO(precomputed)
CYBOZU_TEST_ASSERT(mclBnGT_isEqual(&e2, &f2));
mclBn_precomputedMillerLoop2(&f3, &P1, Q1buf.data(), &P2, Q2buf.data());
mclBn_precomputedMillerLoop2mixed(&f4, &P1, &Q1, &P2, Q2buf.data());
CYBOZU_TEST_ASSERT(mclBnGT_isEqual(&f3, &f4));
mclBn_finalExp(&f3, &f3);
mclBnGT_mul(&e1, &e1, &e2);

@ -232,6 +232,18 @@ void testMillerLoop2(const G1& P1, const G2& Q1)
CYBOZU_TEST_EQUAL(e2, e3);
finalExp(e2, e2);
CYBOZU_TEST_EQUAL(e1, e2);
// special value
G2 Z;
Z.clear();
Q2 += Q2;
precomputeG2(Q1coeff, Z);
precomputeG2(Q2coeff, Q2);
precomputedMillerLoop2(e2, P1, Q1coeff, P2, Q2coeff);
precomputedMillerLoop2mixed(e3, P1, Z, P2, Q2coeff);
finalExp(e2, e2);
finalExp(e3, e3);
CYBOZU_TEST_EQUAL(e2, e3);
}
void testPairing(const G1& P, const G2& Q, const char *eStr)

Loading…
Cancel
Save