From af2e557d9eb824a0c8d5c42a8cf1c8f09c8d16a7 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 17 Sep 2018 11:43:16 +0900 Subject: add signHash and verifyHash for hashed value --- src/bls_c_impl.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/bls_c_impl.hpp b/src/bls_c_impl.hpp index 75e5a44..768c206 100644 --- a/src/bls_c_impl.hpp +++ b/src/bls_c_impl.hpp @@ -267,6 +267,29 @@ int blsPublicKeyIsValidOrder(const blsPublicKey *pub) } #ifndef BLS_MINIMUM_API +inline bool toG1(G1& Hm, const void *h, mclSize size) +{ + Fp t; + t.setArrayMask((const char *)h, size); + bool b; + BN::mapToG1(&b, Hm, t); + return b; +} +int blsSignHash(blsSignature *sig, const blsSecretKey *sec, const void *h, mclSize size) +{ + G1 Hm; + if (!toG1(Hm, h, size)) return -1; + mclBnG1_mulCT(&sig->v, cast(&Hm), &sec->v); + return 0; +} + +int blsVerifyHash(const blsSignature *sig, const blsPublicKey *pub, const void *h, mclSize size) +{ + G1 Hm; + if (!toG1(Hm, h, size)) return 0; + return isEqualTwoPairings(*cast(&sig->v), getQcoeff().data(), Hm, *cast(&pub->v)); +} + void blsSecretKeySub(blsSecretKey *sec, const blsSecretKey *rhs) { mclBnFr_sub(&sec->v, &sec->v, &rhs->v); -- cgit v1.2.3