diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-04-17 08:52:44 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-04-17 08:52:44 +0800 |
commit | cfc6586a58b8af0770fa011fbbda453875f0a444 (patch) | |
tree | 97ac21ab94e8da1a05859ae4b42a89b01992a727 | |
parent | c63ef327159c166462a1512169ee63eb5bae13c6 (diff) | |
download | dexon-mcl-cfc6586a58b8af0770fa011fbbda453875f0a444.tar.gz dexon-mcl-cfc6586a58b8af0770fa011fbbda453875f0a444.tar.zst dexon-mcl-cfc6586a58b8af0770fa011fbbda453875f0a444.zip |
add alias of mcl::init
-rw-r--r-- | include/mcl/she.hpp | 16 | ||||
-rw-r--r-- | misc/she/she-api-ja.md | 4 |
2 files changed, 15 insertions, 5 deletions
diff --git a/include/mcl/she.hpp b/include/mcl/she.hpp index 19c352a..485412f 100644 --- a/include/mcl/she.hpp +++ b/include/mcl/she.hpp @@ -43,7 +43,7 @@ namespace local { #define MCLSHE_WIN_SIZE 10 #endif static const size_t winSize = MCLSHE_WIN_SIZE; -static const size_t defaultTryNum = 1024; +static const size_t defaultTryNum = 2048; struct KeyCount { uint32_t key; @@ -506,13 +506,19 @@ public: typedef CipherTextAT<G1> CipherTextG1; typedef CipherTextAT<G2> CipherTextG2; - static void init(const mcl::CurveParam& cp = mcl::BN254) + static void init(const mcl::CurveParam& cp = mcl::BN254, size_t hashSize = 1024, size_t tryNum = local::defaultTryNum) { bn_current::initPairing(cp); BN::hashAndMapToG1(P_, "0"); BN::hashAndMapToG2(Q_, "0"); BN::pairing(ePQ_, P_, Q_); BN::precomputeG2(Qcoeff_, Q_); + setRangeForDLP(hashSize); + setTryNum(tryNum); + } + static void init(size_t hashSize, size_t tryNum = local::defaultTryNum) + { + init(mcl::BN254, hashSize, tryNum); } /* set range for G1-DLP @@ -1472,7 +1478,11 @@ typedef CipherTextGT CipherTextGM; // old class typedef SHE::CipherText CipherText; typedef SHE::ZkpBin ZkpBin; -inline void init(const mcl::CurveParam& cp = mcl::BN254) { SHE::init(cp); } +inline void init(const mcl::CurveParam& cp = mcl::BN254, size_t hashSize = 1024, size_t tryNum = local::defaultTryNum) +{ + SHE::init(cp, hashSize, tryNum); +} +inline void init(size_t hashSize, size_t tryNum = local::defaultTryNum) { SHE::init(hashSize, tryNum); } inline void setRangeForG1DLP(size_t hashSize) { SHE::setRangeForG1DLP(hashSize); } inline void setRangeForG2DLP(size_t hashSize) { SHE::setRangeForG2DLP(hashSize); } inline void setRangeForGTDLP(size_t hashSize) { SHE::setRangeForGTDLP(hashSize); } diff --git a/misc/she/she-api-ja.md b/misc/she/she-api-ja.md index 9c04648..e02a6a4 100644 --- a/misc/she/she-api-ja.md +++ b/misc/she/she-api-ja.md @@ -249,8 +249,8 @@ int main() ## グローバル関数 -* `void init(const CurveParam& cp, size_t hashSize, size_t tryNum)`(C++) -* `void init(hashSize, tryNum)`(JS) +* `void init(const CurveParam& cp, size_t hashSize = 1024, size_t tryNum = 2048)`(C++) +* `void init(curveType = she.BN254, hashSize = 1024, tryNum = 2048)`(JS) * hashSizeの大きさの復号用テーブルとtryNumを元に初期化する * 復号可能な平文mの範囲は|m| <= hashSize * tryNum * `she.loadTableForGTDLP(Uint8Array a)`(JS) |