diff options
Diffstat (limited to 'vendor/github.com/byzantine-lab/mcl/sample/random.cpp')
-rw-r--r-- | vendor/github.com/byzantine-lab/mcl/sample/random.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/byzantine-lab/mcl/sample/random.cpp b/vendor/github.com/byzantine-lab/mcl/sample/random.cpp new file mode 100644 index 000000000..a2a3619ad --- /dev/null +++ b/vendor/github.com/byzantine-lab/mcl/sample/random.cpp @@ -0,0 +1,29 @@ +#include <mcl/fp.hpp> +#include <mcl/gmp_util.hpp> +#include <mcl/ecparam.hpp> +#include <cybozu/random_generator.hpp> +#include <map> +#include <mcl/fp.hpp> +typedef mcl::FpT<> Fp; + +typedef std::map<std::string, int> Map; + +int main(int argc, char *argv[]) +{ + cybozu::RandomGenerator rg; + const char *p = mcl::ecparam::secp192k1.p; + if (argc == 2) { + p = argv[1]; + } + Fp::init(p); + Fp x; + printf("p=%s\n", p); + Map m; + for (int i = 0; i < 10000; i++) { + x.setRand(rg); + m[x.getStr(16)]++; + } + for (Map::const_iterator i = m.begin(), ie = m.end(); i != ie; ++i) { + printf("%s %d\n", i->first.c_str(), i->second); + } +} |