diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-28 16:37:25 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-28 16:37:25 +0800 |
commit | 58a7a21a96f7929f948601f23a1298e52f505088 (patch) | |
tree | 605ac191331a8ca697c5f53fe19a71da14754ee5 /include | |
parent | faccdfef8f15c26e814ba4362c7bef45dd919940 (diff) | |
download | tangerine-mcl-58a7a21a96f7929f948601f23a1298e52f505088.tar.gz tangerine-mcl-58a7a21a96f7929f948601f23a1298e52f505088.tar.zst tangerine-mcl-58a7a21a96f7929f948601f23a1298e52f505088.zip |
add test of IoMode for Ec
Diffstat (limited to 'include')
-rw-r--r-- | include/mcl/fp.hpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 11d6b9e..5225955 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -59,8 +59,8 @@ enum IoMode { IoBinary = 2, // binary number without prefix IoDecimal = 10, // decimal number without prefix IoHeximal = 16, // heximal number without prefix - IoArray = 17, // array of Unit - IoArrayRaw = 18, // raw array of Unit without Montgomery conversion + IoArray = -1, // array of Unit + IoArrayRaw = -2, // raw array of Unit without Montgomery conversion }; } // mcl::fp @@ -293,10 +293,25 @@ public: fp::getRandVal(v_, rg, op_.p, op_.bitSize); toMont(); } + /* + may use IoMode for base + ignore withPrefix if base = IoArray or IoArrayRaw + */ void getStr(std::string& str, int base = 10, bool withPrefix = false) const { + if (base == 0) base = 10; + if (base == fp::IoArrayRaw) { + str.resize(getBitSize() / 8); + memcpy(&str[0], v_, str.size()); + return; + } fp::Block b; getBlock(b); + if (base == fp::IoArray) { + str.resize(getBitSize() / 8); + memcpy(&str[0], b.p, str.size()); + return; + } fp::arrayToStr(str, b.p, b.n, base, withPrefix); } std::string getStr(int base = 10, bool withPrefix = false) const |