diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-23 15:20:22 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-23 15:20:22 +0800 |
commit | bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e (patch) | |
tree | 63950dbac01e0868258c5ab5c9cc3c9e038818f5 /src | |
parent | 7b0c8c7c7051c5ed1df620e7eeae25e768de29a6 (diff) | |
download | dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.tar dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.tar.gz dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.tar.bz2 dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.tar.lz dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.tar.xz dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.tar.zst dexon-bls-bdf09ff0465e5d2c159694fafec6c9ed8e7fb97e.zip |
remove try
Diffstat (limited to 'src')
-rw-r--r-- | src/bls_c.cpp | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/src/bls_c.cpp b/src/bls_c.cpp index 2135a8a..dd7a818 100644 --- a/src/bls_c.cpp +++ b/src/bls_c.cpp @@ -26,14 +26,14 @@ static const G2& getQ() { return g_Q; } static const std::vector<Fp6>& getQcoeff() { return g_Qcoeff; } int blsInitNotThreadSafe(int curve, int maxUnitSize) - try { - if (mclBn_init(curve, maxUnitSize) != 0) return -1; - mapToG2(g_Q, 1); + int ret = mclBn_init(curve, maxUnitSize); + if (ret < 0) return ret; + bool b; + mapToG2(&b, g_Q, 1); + if (!b) return -100; precomputeG2(g_Qcoeff, getQ()); return 0; -} catch (std::exception&) { - return -1; } #ifndef __EMSCRIPTEN__ @@ -84,39 +84,19 @@ bool isEqualTwoPairings(const G1& P1, const Fp6* Q1coeff, const G1& P2, const G2 return e.isOne(); } -mclSize checkAndCopy(char *buf, mclSize maxBufSize, const std::string& s) -{ - if (s.size() > maxBufSize + 1) { - return 0; - } - memcpy(buf, s.c_str(), s.size()); - buf[s.size()] = '\0'; - return s.size(); -} - mclSize blsGetOpUnitSize() // FpUint64Size { return Fp::getUnitSize() * sizeof(mcl::fp::Unit) / sizeof(uint64_t); } int blsGetCurveOrder(char *buf, mclSize maxBufSize) - try { - std::string s; - Fr::getModulo(s); - return (int)checkAndCopy(buf, maxBufSize, s); -} catch (std::exception&) { - return 0; + return Fr::getModulo(buf, maxBufSize); } int blsGetFieldOrder(char *buf, mclSize maxBufSize) - try { - std::string s; - Fp::getModulo(s); - return (int)checkAndCopy(buf, maxBufSize, s); -} catch (std::exception&) { - return 0; + return Fp::getModulo(buf, maxBufSize); } void blsGetGeneratorOfG2(blsPublicKey *pub) |