diff options
-rw-r--r-- | include/bls/bls.hpp | 2 | ||||
-rw-r--r-- | src/bls.cpp | 4 | ||||
-rw-r--r-- | src/bls_if.cpp | 4 |
3 files changed, 8 insertions, 2 deletions
diff --git a/include/bls/bls.hpp b/include/bls/bls.hpp index ddfbf50..f3a29a0 100644 --- a/include/bls/bls.hpp +++ b/include/bls/bls.hpp @@ -136,6 +136,8 @@ public: void set(const uint64_t *p); // bufSize is truncted/zero extended to keySize void setLittleEndian(const void *buf, size_t bufSize); + // set hash of buf + void setHashOf(const void *buf, size_t bufSize); void getPublicKey(PublicKey& pub) const; // constant time sign void sign(Signature& sig, const std::string& m) const; diff --git a/src/bls.cpp b/src/bls.cpp index 609e256..7b6f40b 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -419,6 +419,10 @@ void SecretKey::setLittleEndian(const void *buf, size_t bufSize) { getInner().s.setArrayMask((const char *)buf, bufSize); } +void SecretKey::setHashOf(const void *buf, size_t bufSize) +{ + getInner().s.setHashOf(buf, bufSize); +} void SecretKey::getPublicKey(PublicKey& pub) const { diff --git a/src/bls_if.cpp b/src/bls_if.cpp index 192a45d..2498759 100644 --- a/src/bls_if.cpp +++ b/src/bls_if.cpp @@ -143,8 +143,8 @@ size_t blsSecretKeyGetHexStr(char *buf, size_t maxBufSize, const blsSecretKey *s int blsSecretKeySetToHashOf(blsSecretKey *sec, const void *buf, size_t bufSize) try { - std::string s = mcl::fp::hash(384, (const char *)buf, bufSize); - return blsSecretKeySetLittleEndian(sec, s.c_str(), s.size()); + ((bls::SecretKey*)sec)->setHashOf(buf, bufSize); + return 0; } catch (std::exception& e) { fprintf(stderr, "err blsSecretKeySetByCSPRNG %s\n", e.what()); return -1; |