diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-04-09 14:50:50 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-04-09 14:50:50 +0800 |
commit | 076cb73f57616c4ddc01db19c6c0487cd886d6a8 (patch) | |
tree | caf06716c3e7d19711222b0af38ae7f3a405fad1 /test/bls_if_test.cpp | |
parent | f299770465daefdb309c72845f41c9c078ba6d49 (diff) | |
download | dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.tar dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.tar.gz dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.tar.bz2 dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.tar.lz dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.tar.xz dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.tar.zst dexon-bls-076cb73f57616c4ddc01db19c6c0487cd886d6a8.zip |
add GetData/SetData/IsSame
Diffstat (limited to 'test/bls_if_test.cpp')
-rw-r--r-- | test/bls_if_test.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/bls_if_test.cpp b/test/bls_if_test.cpp index ed59396..2292bfa 100644 --- a/test/bls_if_test.cpp +++ b/test/bls_if_test.cpp @@ -49,6 +49,37 @@ void bls_if_use_stackTest() CYBOZU_TEST_ASSERT(blsSignVerify(&sign, &pub, msg, msgSize)); } +void bls_ifDataTest() +{ + const char *msg = "test test"; + const size_t msgSize = strlen(msg); + const size_t fpSize = blsGetOpUnitSize() * sizeof(uint64_t); + blsSecretKey sec1, sec2; + blsSecretKeyInit(&sec1); + char buf[BLS_MAX_OP_UNIT_SIZE * sizeof(uint64_t) * 2]; + size_t n; + int ret; + n = blsSecretKeyGetData(&sec1, buf, sizeof(buf)); + CYBOZU_TEST_EQUAL(n, fpSize); + ret = blsSecretKeySetData(&sec2, buf, n); + CYBOZU_TEST_EQUAL(ret, 0); + CYBOZU_TEST_ASSERT(blsSecretKeyIsSame(&sec1, &sec2)); + blsPublicKey pub1, pub2; + blsSecretKeyGetPublicKey(&sec1, &pub1); + n = blsPublicKeyGetData(&pub1, buf, sizeof(buf)); + CYBOZU_TEST_EQUAL(n, fpSize * 2); + ret = blsPublicKeySetData(&pub2, buf, n); + CYBOZU_TEST_EQUAL(ret, 0); + CYBOZU_TEST_ASSERT(blsPublicKeyIsSame(&pub1, &pub2)); + blsSign sign1, sign2; + blsSecretKeySign(&sec1, &sign1, msg, msgSize); + n = blsSignGetData(&sign1, buf, sizeof(buf)); + CYBOZU_TEST_EQUAL(n, fpSize); + ret = blsSignSetData(&sign2, buf, n); + CYBOZU_TEST_EQUAL(ret, 0); + CYBOZU_TEST_ASSERT(blsSignIsSame(&sign1, &sign2)); +} + CYBOZU_TEST_AUTO(all) { const int tbl[] = { @@ -63,5 +94,6 @@ CYBOZU_TEST_AUTO(all) blsInit(tbl[i], BLS_MAX_OP_UNIT_SIZE); bls_ifTest(); bls_if_use_stackTest(); + bls_ifDataTest(); } } |