move mclBn_* to mcl

dev
MITSUNARI Shigeo 8 years ago
parent c23d3804b3
commit 4a401bd204
  1. 20
      include/mcl/bn.h
  2. 50
      src/bn_c_impl.hpp

@ -273,6 +273,26 @@ 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);
/*
Lagrange interpolation
recover out = y(0) by { (xVec[i], yVec[i]) }
return 0 if success else -1
@note k >= 2, xVec[i] != 0, xVec[i] != xVec[j] for i != j
*/
MCLBN_DLL_API int mclBn_FrLagrangeInterpolation(mclBnFr *out, const mclBnFr *xVec, const mclBnFr *yVec, size_t k);
MCLBN_DLL_API int mclBn_G1LagrangeInterpolation(mclBnG1 *out, const mclBnFr *xVec, const mclBnG1 *yVec, size_t k);
MCLBN_DLL_API int mclBn_G2LagrangeInterpolation(mclBnG2 *out, const mclBnFr *xVec, const mclBnG2 *yVec, size_t k);
/*
evaluate polynomial
out = f(x) = c[0] + c[1] * x + c[2] * x^2 + ... + c[cSize - 1] * x^(cSize - 1)
@note cSize >= 2
*/
MCLBN_DLL_API int mclBn_FrEvaluatePolynomial(mclBnFr *out, const mclBnFr *cVec, size_t cSize, const mclBnFr *x);
MCLBN_DLL_API int mclBn_G1EvaluatePolynomial(mclBnG1 *out, const mclBnG1 *cVec, size_t cSize, const mclBnFr *x);
MCLBN_DLL_API int mclBn_G2EvaluatePolynomial(mclBnG2 *out, const mclBnG2 *cVec, size_t cSize, const mclBnFr *x);
#ifdef __cplusplus
}
#endif

@ -15,6 +15,7 @@ using namespace mcl::bn256;
#include <mcl/bn384.hpp>
using namespace mcl::bn384;
#endif
#include <mcl/lagrange.hpp>
static FILE *g_fp = NULL;
@ -526,3 +527,52 @@ void mclBn_precomputedMillerLoop2(mclBnGT *f, const mclBnG1 *P1, const uint64_t
{
BN::precomputedMillerLoop2(*cast(f), *cast(P1), cast(Q1buf), *cast(P2), cast(Q2buf));
}
int mclBn_FrLagrangeInterpolation(mclBnFr *out, const mclBnFr *xVec, const mclBnFr *yVec, size_t k)
try
{
mcl::LagrangeInterpolation(*cast(out), cast(xVec), cast(yVec), k);
return 0;
} catch (std::exception& e) {
return -1;
}
int mclBn_G1LagrangeInterpolation(mclBnG1 *out, const mclBnFr *xVec, const mclBnG1 *yVec, size_t k)
try
{
mcl::LagrangeInterpolation(*cast(out), cast(xVec), cast(yVec), k);
return 0;
} catch (std::exception& e) {
return -1;
}
int mclBn_G2LagrangeInterpolation(mclBnG2 *out, const mclBnFr *xVec, const mclBnG2 *yVec, size_t k)
try
{
mcl::LagrangeInterpolation(*cast(out), cast(xVec), cast(yVec), k);
return 0;
} catch (std::exception& e) {
return -1;
}
int mclBn_FrEvaluatePolynomial(mclBnFr *out, const mclBnFr *cVec, size_t cSize, const mclBnFr *x)
try
{
mcl::evaluatePolynomial(*cast(out), cast(cVec), cSize, *cast(x));
return 0;
} catch (std::exception& e) {
return -1;
}
int mclBn_G1EvaluatePolynomial(mclBnG1 *out, const mclBnG1 *cVec, size_t cSize, const mclBnFr *x)
try
{
mcl::evaluatePolynomial(*cast(out), cast(cVec), cSize, *cast(x));
return 0;
} catch (std::exception& e) {
return -1;
}
int mclBn_G2EvaluatePolynomial(mclBnG2 *out, const mclBnG2 *cVec, size_t cSize, const mclBnFr *x)
try
{
mcl::evaluatePolynomial(*cast(out), cast(cVec), cSize, *cast(x));
return 0;
} catch (std::exception& e) {
return -1;
}

Loading…
Cancel
Save