aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/mcl/sample/random.cpp
blob: a2a3619adb3fd083b5e9c279e29f3ebc21826e0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
    }
}