diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-02-20 18:43:19 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-02-20 18:43:19 +0800 |
commit | 0396b6dcff8c2c7053b780560818a7806540220c (patch) | |
tree | f671957d98b9a803c0fdcdc3d33d727d0df53a33 | |
parent | 2fde7eee3da11cb9e1b1296d2566a2ad88eaf358 (diff) | |
download | tangerine-mcl-0396b6dcff8c2c7053b780560818a7806540220c.tar.gz tangerine-mcl-0396b6dcff8c2c7053b780560818a7806540220c.tar.zst tangerine-mcl-0396b6dcff8c2c7053b780560818a7806540220c.zip |
add benchmark of aggregate_sig
-rw-r--r-- | test/aggregate_sig_test.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/test/aggregate_sig_test.cpp b/test/aggregate_sig_test.cpp index 318e418..8d79bec 100644 --- a/test/aggregate_sig_test.cpp +++ b/test/aggregate_sig_test.cpp @@ -1,11 +1,16 @@ +//#define MCLBN_FP_UNIT_SIZE 8 #include <cybozu/test.hpp> #include <mcl/aggregate_sig.hpp> +#include <cybozu/benchmark.hpp> +#include <cybozu/xorshift.hpp> using namespace mcl::aggs; CYBOZU_TEST_AUTO(init) { AGGS::init(); +// AGGS::init(mcl::bn::CurveFp382_1); +// AGGS::init(mcl::bn::CurveFp462); SecretKey sec; sec.init(); PublicKey pub; @@ -16,14 +21,9 @@ CYBOZU_TEST_AUTO(init) CYBOZU_TEST_ASSERT(pub.verify(sig, m)); } -CYBOZU_TEST_AUTO(aggregate) +void aggregateTest(const std::vector<std::string>& msgVec) { - const std::string msgArray[] = { "abc", "12345", "xyz", "pqr", "aggregate signature" }; - const size_t n = sizeof(msgArray) / sizeof(msgArray[0]); - std::vector<std::string> msgVec(n); - for (size_t i = 0; i < n; i++) { - msgVec[i] = msgArray[i]; - } + const size_t n = msgVec.size(); std::vector<SecretKey> secVec(n); std::vector<PublicKey> pubVec(n); std::vector<Signature> sigVec(n); @@ -36,4 +36,40 @@ CYBOZU_TEST_AUTO(aggregate) } aggSig.aggregate(sigVec); CYBOZU_TEST_ASSERT(aggSig.verify(msgVec, pubVec)); + CYBOZU_BENCH_C("aggSig.verify", 10, aggSig.verify, msgVec, pubVec); +} + +CYBOZU_TEST_AUTO(aggregate) +{ +#if 0 + /* + Core i7-7700 CPU @ 3.60GHz + BN254 Fp382 Fp462 + security bit 100 115? 128 + 100 69 200 476 + 1000 693 2037 4731 + 10000 6969 20448 47000(Mclk) + + */ + const size_t n = 1000; + const size_t msgSize = 16; + std::vector<std::string> msgVec(n); + cybozu::XorShift rg; + for (size_t i = 0; i < n; i++) { + std::string& msg = msgVec[i]; + msg.resize(msgSize); + for (size_t j = 0; j < msgSize; j++) { + msg[j] = (char)rg(); + } + } + aggregateTest(msgVec); +#else + const std::string msgArray[] = { "abc", "12345", "xyz", "pqr", "aggregate signature" }; + const size_t n = sizeof(msgArray) / sizeof(msgArray[0]); + std::vector<std::string> msgVec(n); + for (size_t i = 0; i < n; i++) { + msgVec[i] = msgArray[i]; + } + aggregateTest(msgVec); +#endif } |