aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-04-11 18:32:33 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit21ac6a5ed287112f685174b482d36392c594f0e8 (patch)
treef36d198fdee235aac353ae32b8d927890bcae060 /vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp
parent67637a63cab266b30d2a634bb8039bd7ff1ae335 (diff)
downloadgo-tangerine-21ac6a5ed287112f685174b482d36392c594f0e8.tar.gz
go-tangerine-21ac6a5ed287112f685174b482d36392c594f0e8.tar.zst
go-tangerine-21ac6a5ed287112f685174b482d36392c594f0e8.zip
vendor: use BLS-12_384 curve and update dependencies (#356)
Diffstat (limited to 'vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp')
-rw-r--r--vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp b/vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp
new file mode 100644
index 000000000..c3a0e758d
--- /dev/null
+++ b/vendor/github.com/dexon-foundation/mcl/test/aggregate_sig_test.cpp
@@ -0,0 +1,74 @@
+//#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::BN381_1);
+// AGGS::init(mcl::BLS12_381);
+ SecretKey sec;
+ sec.init();
+ PublicKey pub;
+ sec.getPublicKey(pub);
+ const std::string m = "abc";
+ Signature sig;
+ sec.sign(sig, m);
+ CYBOZU_TEST_ASSERT(pub.verify(sig, m));
+}
+
+void aggregateTest(const std::vector<std::string>& msgVec)
+{
+ const size_t n = msgVec.size();
+ std::vector<SecretKey> secVec(n);
+ std::vector<PublicKey> pubVec(n);
+ std::vector<Signature> sigVec(n);
+ Signature aggSig;
+ for (size_t i = 0; i < n; i++) {
+ secVec[i].init();
+ secVec[i].getPublicKey(pubVec[i]);
+ secVec[i].sign(sigVec[i], msgVec[i]);
+ CYBOZU_TEST_ASSERT(pubVec[i].verify(sigVec[i], msgVec[i]));
+ }
+ 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
+ # of sig 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
+}