diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-24 19:53:17 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-24 19:53:17 +0800 |
commit | 6b889517c31bb773e4ad1cb8c139c5d924520c2e (patch) | |
tree | f368f6811190ba887ed54d4d8322ecf4cc44bf8c /src | |
parent | e963394eb4d7497ece68218317a8690e1453c200 (diff) | |
download | dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.tar dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.tar.gz dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.tar.bz2 dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.tar.lz dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.tar.xz dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.tar.zst dexon-bls-6b889517c31bb773e4ad1cb8c139c5d924520c2e.zip |
remove std::vector
Diffstat (limited to 'src')
-rw-r--r-- | src/bls_c.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/bls_c.cpp b/src/bls_c.cpp index d443eaa..ae86508 100644 --- a/src/bls_c.cpp +++ b/src/bls_c.cpp @@ -1,11 +1,10 @@ -#include <iostream> -#include <sstream> -#include <vector> -#include <string> -#include <iosfwd> -#include <stdint.h> -#include <memory.h> +#ifdef __EMSCRIPTEN__ +#define MCLBN_DONT_EXPORT +#include "../mcl/src/fp.cpp" +#endif + #include "../mcl/src/bn_c_impl.hpp" + #define BLS_DLL_EXPORT #include <bls/bls.h> @@ -21,9 +20,9 @@ */ static G2 g_Q; -static std::vector<Fp6> g_Qcoeff; // precomputed Q +static mcl::Vector<Fp6> g_Qcoeff; // precomputed Q static const G2& getQ() { return g_Q; } -static const std::vector<Fp6>& getQcoeff() { return g_Qcoeff; } +static const mcl::Vector<Fp6>& getQcoeff() { return g_Qcoeff; } int blsInitNotThreadSafe(int curve, int maxUnitSize) { @@ -32,10 +31,17 @@ int blsInitNotThreadSafe(int curve, int maxUnitSize) bool b; mapToG2(&b, g_Q, 1); if (!b) return -100; - precomputeG2(g_Qcoeff, getQ()); + if (!precomputeG2(g_Qcoeff, getQ())) return -101; return 0; } +#ifdef __EMSCRIPTEN__ +extern "C" BLS_DLL_API void blsFree(void *p) +{ + free(p); +} +#endif + #ifndef __EMSCRIPTEN__ #if defined(CYBOZU_CPP_VERSION) && CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11 #include <mutex> @@ -76,8 +82,8 @@ static inline const mclBnG2 *cast(const G2* x) { return (const mclBnG2*)x; } */ bool isEqualTwoPairings(const G1& P1, const Fp6* Q1coeff, const G1& P2, const G2& Q2) { - std::vector<Fp6> Q2coeff; - precomputeG2(Q2coeff, Q2); + mcl::Vector<Fp6> Q2coeff; + if (!precomputeG2(Q2coeff, Q2)) return false; Fp12 e; precomputedMillerLoop2(e, P1, Q1coeff, -P2, Q2coeff.data()); finalExp(e, e); |