From e68b2a3fb07999ba000eccb1727c527763d56e9f Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Fri, 21 Sep 2018 17:48:19 +0900 Subject: add blsVerifyAggregatedHashes --- include/bls/bls.h | 13 +++++-------- include/bls/bls.hpp | 10 +--------- 2 files changed, 6 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/bls/bls.h b/include/bls/bls.h index 71e3d02..45bd839 100644 --- a/include/bls/bls.h +++ b/include/bls/bls.h @@ -123,11 +123,6 @@ BLS_DLL_API int blsPublicKeyIsValidOrder(const blsPublicKey *pub); #ifndef BLS_MINIMUM_API -/* - set h to a point of G1 - return 0 if success else -1 -*/ -BLS_DLL_API int blsG1SetHash(mclBnG1 *g1, const void *h, mclSize size); /* sign the hash use the low (bitSize of r) - 1 bit of h @@ -137,12 +132,14 @@ BLS_DLL_API int blsG1SetHash(mclBnG1 *g1, const void *h, mclSize size); BLS_DLL_API int blsSignHash(blsSignature *sig, const blsSecretKey *sec, const void *h, mclSize size); // return 1 if valid BLS_DLL_API int blsVerifyHash(const blsSignature *sig, const blsPublicKey *pub, const void *h, mclSize size); + /* - verify aggSig with pubVec[0, n) and g1Vec[0, n) - e(aggSig, Q) = prod_i e(g1Vec[i], pubVec[i]) + verify aggSig with pubVec[0, n) and hVec[0, n) + e(aggSig, Q) = prod_i e(hVec[i], pubVec[i]) return 1 if valid + @note do not check duplication of hVec */ -BLS_DLL_API int blsVerifyAggregation(const blsSignature *aggSig, const blsPublicKey *pubVec, const mclBnG1 *g1Vec, mclSize n); +BLS_DLL_API int blsVerifyAggregatedHashes(const blsSignature *aggSig, const blsPublicKey *pubVec, const void *hVec, size_t sizeofHash, mclSize n); // sub BLS_DLL_API void blsSecretKeySub(blsSecretKey *sec, const blsSecretKey *rhs); diff --git a/include/bls/bls.hpp b/include/bls/bls.hpp index 868e574..722e4e2 100644 --- a/include/bls/bls.hpp +++ b/include/bls/bls.hpp @@ -419,17 +419,9 @@ public: { return verifyHash(pub, h.c_str(), h.size()); } - bool verifyAggregation(const PublicKey *pubVec, const mclBnG1 *g1Vec, size_t n) const - { - return blsVerifyAggregation(&self_, &pubVec[0].self_, g1Vec, n) == 1; - } bool verifyAggregatedHashes(const PublicKey *pubVec, const void *hVec, size_t sizeofHash, size_t n) const { - std::vector g1Vec(n); - for (size_t i = 0; i < n; i++) { - if (blsG1SetHash(&g1Vec[i], (const char*)hVec + sizeofHash * i, sizeofHash) != 0) throw std::runtime_error("blsG1SetHash"); - } - return verifyAggregation(pubVec, g1Vec.data(), n); + return blsVerifyAggregatedHashes(&self_, &pubVec[0].self_, hVec, sizeofHash, n) == 1; } /* verify self(pop) with pub -- cgit v1.2.3