diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-11-06 16:24:04 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-11-06 16:24:04 +0800 |
commit | da48823cda0905fcf21396c5831b840106cb3a8c (patch) | |
tree | 672507ccadbe87f6bd05b41aa197d63f6841a348 /test | |
parent | 5f2112059cb6326f03e1ac5585b1df1bb6fdc55f (diff) | |
download | dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.gz dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.bz2 dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.lz dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.xz dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.zst dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.zip |
update test
Diffstat (limited to 'test')
-rw-r--r-- | test/bls_c_test.hpp | 44 | ||||
-rw-r--r-- | test/bls_test.hpp | 8 |
2 files changed, 30 insertions, 22 deletions
diff --git a/test/bls_c_test.hpp b/test/bls_c_test.hpp index 105be86..7864097 100644 --- a/test/bls_c_test.hpp +++ b/test/bls_c_test.hpp @@ -301,34 +301,40 @@ void blsBench() blsGetPublicKey(&pub, &sec); - CYBOZU_BENCH_C("sign", 1000, blsSign, &sig, &sec, msg, msgSize); + CYBOZU_BENCH_C("sign", 10000, blsSign, &sig, &sec, msg, msgSize); CYBOZU_BENCH_C("verify", 1000, blsVerify, &sig, &pub, msg, msgSize); } CYBOZU_TEST_AUTO(all) { - const int tbl[] = { - MCL_BN254, + const struct { + int curveType; + const char *p; + const char *r; + } tbl[] = { + { + MCL_BN254, + "16798108731015832284940804142231733909759579603404752749028378864165570215949", + "16798108731015832284940804142231733909889187121439069848933715426072753864723", + }, #if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6 - MCL_BN381_1, + { + MCL_BN381_1, + "5540996953667913971058039301942914304734176495422447785042938606876043190415948413757785063597439175372845535461389", + "5540996953667913971058039301942914304734176495422447785045292539108217242186829586959562222833658991069414454984723", + }, #endif -#if MCLBN_FR_UNIT_SIZE == 6 && MCLBN_FP_UNIT_SIZE == 4 - MCL_BLS12_381, +#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 4 + { + MCL_BLS12_381, + "52435875175126190479447740508185965837690552500527637822603658699938581184513", + "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", + }, #endif }; - const char *curveOrderTbl[] = { - "16798108731015832284940804142231733909759579603404752749028378864165570215949", - "5540996953667913971058039301942914304734176495422447785042938606876043190415948413757785063597439175372845535461389", - "52435875175126190479447740508185965837690552500527637822603658699938581184513", - }; - const char *fieldOrderTbl[] = { - "16798108731015832284940804142231733909889187121439069848933715426072753864723", - "5540996953667913971058039301942914304734176495422447785045292539108217242186829586959562222833658991069414454984723", - "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", - }; for (size_t i = 0; i < sizeof(tbl) / sizeof(tbl[0]); i++) { printf("i=%d\n", (int)i); - int ret = blsInit(tbl[i], MCLBN_COMPILED_TIME_VAR); + int ret = blsInit(tbl[i].curveType, MCLBN_COMPILED_TIME_VAR); CYBOZU_TEST_EQUAL(ret, 0); if (ret) { printf("ERR %d\n", ret); @@ -336,9 +342,9 @@ CYBOZU_TEST_AUTO(all) } bls_use_stackTest(); blsDataTest(); - blsOrderTest(curveOrderTbl[i], fieldOrderTbl[i]); + blsOrderTest(tbl[i].p, tbl[i].r); blsSerializeTest(); - if (tbl[i] == MCL_BLS12_381) blsVerifyOrderTest(); + if (tbl[i].curveType == MCL_BLS12_381) blsVerifyOrderTest(); blsAddSubTest(); blsBench(); } diff --git a/test/bls_test.hpp b/test/bls_test.hpp index 752f6fd..c3f6406 100644 --- a/test/bls_test.hpp +++ b/test/bls_test.hpp @@ -104,8 +104,8 @@ void blsTest() CYBOZU_TEST_ASSERT(sig.verify(pub, m)); CYBOZU_TEST_ASSERT(!sig.verify(pub, m + "a")); streamTest(sig); - CYBOZU_BENCH_C("sign", 100, sec.sign, sig, m); - CYBOZU_BENCH_C("verify", 100, sig.verify, pub, m); + CYBOZU_BENCH_C("sign", 10000, sec.sign, sig, m); + CYBOZU_BENCH_C("verify", 1000, sig.verify, pub, m); } } @@ -476,8 +476,10 @@ CYBOZU_TEST_AUTO(all) const char *name; } tbl[] = { { MCL_BN254, "BN254" }, -#if MCLBN_FP_UNIT_SIZE == 6 +#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6 { MCL_BN381_1, "BN381_1" }, +#endif +#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 4 { MCL_BLS12_381, "BLS12_381" }, #endif }; |