add millerLoopVec

update-fork
MITSUNARI Shigeo 5 years ago
parent 7df73796d5
commit 1d7c99e8a7
  1. 2
      include/mcl/bn.h
  2. 4
      include/mcl/impl/bn_c_impl.hpp
  3. 20
      test/bn_c_test.hpp

@ -407,6 +407,8 @@ MCLBN_DLL_API void mclBnGT_pow(mclBnGT *z, const mclBnGT *x, const mclBnFr *y);
MCLBN_DLL_API void mclBn_pairing(mclBnGT *z, const mclBnG1 *x, const mclBnG2 *y);
MCLBN_DLL_API void mclBn_finalExp(mclBnGT *y, const mclBnGT *x);
MCLBN_DLL_API void mclBn_millerLoop(mclBnGT *z, const mclBnG1 *x, const mclBnG2 *y);
// z = prod_{i=0}^{n-1} millerLoop(x[i], y[i])
MCLBN_DLL_API void mclBn_millerLoopVec(mclBnGT *z, const mclBnG1 *x, const mclBnG2 *y, mclSize n);
// return precomputedQcoeffSize * sizeof(Fp6) / sizeof(uint64_t)
MCLBN_DLL_API int mclBn_getUint64NumToPrecompute(void);

@ -527,6 +527,10 @@ void mclBn_millerLoop(mclBnGT *z, const mclBnG1 *x, const mclBnG2 *y)
{
millerLoop(*cast(z), *cast(x), *cast(y));
}
void mclBn_millerLoopVec(mclBnGT *z, const mclBnG1 *x, const mclBnG2 *y, mclSize n)
{
millerLoopVec(*cast(z), cast(x), cast(y), n);
}
int mclBn_getUint64NumToPrecompute(void)
{
return int(BN::param.precomputedQcoeffSize * sizeof(Fp6) / sizeof(uint64_t));

@ -367,6 +367,26 @@ CYBOZU_TEST_AUTO(precomputed)
CYBOZU_TEST_ASSERT(mclBnGT_isEqual(&e1, &f3));
}
CYBOZU_TEST_AUTO(millerLoopVec)
{
const size_t n = 7;
mclBnG1 Pvec[n];
mclBnG2 Qvec[n];
for (size_t i = 0; i < n; i++) {
char d = (char)(i + 1);
mclBnG1_hashAndMapTo(&Pvec[i], &d, 1);
mclBnG2_hashAndMapTo(&Qvec[i], &d, 1);
}
mclBnGT e1, e2;
mclBnGT_setInt(&e2, 1);
for (size_t i = 0; i < n; i++) {
mclBn_millerLoop(&e1, &Pvec[i], &Qvec[i]);
mclBnGT_mul(&e2, &e2, &e1);
}
mclBn_millerLoopVec(&e1, Pvec, Qvec, n);
CYBOZU_TEST_ASSERT(mclBnGT_isEqual(&e1, &e2));
}
CYBOZU_TEST_AUTO(serialize)
{
const size_t FrSize = mclBn_getFrByteSize();

Loading…
Cancel
Save