aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-02-03 15:26:35 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-02-03 15:26:35 +0800
commitbc582f62fd7b59213e832a5ebf77d9b5dfd9063a (patch)
tree9cf0a3d203e436dbae22b9459bf181d491e44d4a /include
parentd09cdd7979281cd682848a54abe3f491ffbd406e (diff)
downloadtangerine-mcl-bc582f62fd7b59213e832a5ebf77d9b5dfd9063a.tar.gz
tangerine-mcl-bc582f62fd7b59213e832a5ebf77d9b5dfd9063a.tar.zst
tangerine-mcl-bc582f62fd7b59213e832a5ebf77d9b5dfd9063a.zip
add Fp::setMsg()
Diffstat (limited to 'include')
-rw-r--r--include/mcl/fp.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp
index e98832d..d8cc1bf 100644
--- a/include/mcl/fp.hpp
+++ b/include/mcl/fp.hpp
@@ -89,6 +89,9 @@ void UnitToHex(char *buf, size_t maxBufSize, Unit x);
bool isEnableJIT(); // 1st call is not threadsafe
+// hash msg
+std::string hash(size_t bitSize, const char *msg, size_t msgSize);
+
} // mcl::fp
template<class tag = FpTag, size_t maxBitSize = MCL_MAX_BIT_SIZE>
@@ -295,6 +298,18 @@ public:
fp::getRandVal(v_, rg, op_.p, op_.bitSize);
toMont();
}
+ /*
+ hash msg and mask with (1 << (bitLen - 1)) - 1
+ */
+ void setMsg(const char *msg, size_t msgSize)
+ {
+ std::string digest = mcl::fp::hash(op_.bitSize, msg, msgSize);
+ setArrayMask(digest.c_str(), digest.size());
+ }
+ void setMsg(const std::string& msg)
+ {
+ setMsg(msg.data(), msg.size());
+ }
void getStr(std::string& str, int ioMode = 10) const
{
const size_t n = getByteSize();