aboutsummaryrefslogtreecommitdiffstats
path: root/sample/random_smpl.cpp
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2015-05-05 09:52:44 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2015-05-05 09:52:44 +0800
commit14fd1d125d21f47c2539a0e820e2a417e0c715f8 (patch)
tree4fccb395f51a3f9c1202a783665ce396b649eeb9 /sample/random_smpl.cpp
downloadtangerine-mcl-14fd1d125d21f47c2539a0e820e2a417e0c715f8.tar.gz
tangerine-mcl-14fd1d125d21f47c2539a0e820e2a417e0c715f8.tar.zst
tangerine-mcl-14fd1d125d21f47c2539a0e820e2a417e0c715f8.zip
from mie
Diffstat (limited to 'sample/random_smpl.cpp')
-rw-r--r--sample/random_smpl.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/sample/random_smpl.cpp b/sample/random_smpl.cpp
new file mode 100644
index 0000000..19944de
--- /dev/null
+++ b/sample/random_smpl.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::setModulo(p);
+ Fp x;
+ printf("p=%s\n", p);
+ Map m;
+ for (int i = 0; i < 10000; i++) {
+ x.setRand(rg);
+ m[x.toStr(16)]++;
+ }
+ for (Map::const_iterator i = m.begin(), ie = m.end(); i != ie; ++i) {
+ printf("%s %d\n", i->first.c_str(), i->second);
+ }
+}