aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-05-03 06:02:34 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-05-03 06:02:34 +0800
commitddcbd090a41f4a435b5c1c19a0924aa9259601cb (patch)
tree44beb5913cf41d4129aab6629af5c6da4f54cbd3
parent1189ddf898f069d9f892abca7b47d2839064b5eb (diff)
downloadtangerine-mcl-ddcbd090a41f4a435b5c1c19a0924aa9259601cb.tar.gz
tangerine-mcl-ddcbd090a41f4a435b5c1c19a0924aa9259601cb.tar.zst
tangerine-mcl-ddcbd090a41f4a435b5c1c19a0924aa9259601cb.zip
enable ZkpEqTest and ZkpBinEqTest
-rw-r--r--src/she_c_impl.hpp9
-rw-r--r--test/she_c_test.hpp12
-rw-r--r--test/she_test.cpp2
3 files changed, 11 insertions, 12 deletions
diff --git a/src/she_c_impl.hpp b/src/she_c_impl.hpp
index 520da8c..b3a7ab7 100644
--- a/src/she_c_impl.hpp
+++ b/src/she_c_impl.hpp
@@ -352,8 +352,7 @@ int encWithZkpEqT(sheCipherTextG1 *c1, sheCipherTextG2 *c2, sheZkpEq *zkp, const
{
cast(pub)->encWithZkpEq(*cast(c1), *cast(c2), *cast(zkp), m);
return 0;
-} catch (std::exception& e) {
- fprintf(stderr, "err %s\n", e.what());
+} catch (std::exception&) {
return -1;
}
@@ -373,8 +372,7 @@ int encWithZkpBinEqT(sheCipherTextG1 *c1, sheCipherTextG2 *c2, sheZkpBinEq *zkp,
{
cast(pub)->encWithZkpBinEq(*cast(c1), *cast(c2), *cast(zkp), m);
return 0;
-} catch (std::exception& e) {
- fprintf(stderr, "err %s\n", e.what());
+} catch (std::exception&) {
return -1;
}
@@ -702,8 +700,7 @@ int verifyT(const PK& pub, const CipherTextG1& c1, const CipherTextG2& c2, const
try
{
return pub.verify(c1, c2, zkp);
-} catch (std::exception& e) {
- fprintf(stderr, "err %s\n", e.what());
+} catch (std::exception&) {
return 0;
}
diff --git a/test/she_c_test.hpp b/test/she_c_test.hpp
index 912fda0..f93ecaf 100644
--- a/test/she_c_test.hpp
+++ b/test/she_c_test.hpp
@@ -352,11 +352,13 @@ void ZkpBinEqTest(const sheSecretKey *sec, const PK *pub, encWithZkpFunc encWith
{
char buf[2048];
size_t n = sheZkpBinEqSerialize(buf, sizeof(buf), &zkp);
- CYBOZU_TEST_EQUAL(n, mclBn_getOpUnitSize() * 8 * 7);
+ CYBOZU_TEST_EQUAL(n, mclBn_getFrByteSize() * CYBOZU_NUM_OF_ARRAY(zkp.d));
sheZkpBinEq zkp2;
size_t r = sheZkpBinEqDeserialize(&zkp2, buf, n);
CYBOZU_TEST_EQUAL(r, n);
- CYBOZU_TEST_ASSERT(memcmp(&zkp, &zkp2, n) == 0);
+ for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(zkp.d); i++) {
+ CYBOZU_TEST_ASSERT(mclBnFr_isEqual(&zkp.d[i], &zkp2.d[i]));
+ }
}
zkp.d[0].d[0]++;
CYBOZU_TEST_EQUAL(verify(pub, &c1, &c2, &zkp), 0);
@@ -399,11 +401,13 @@ void ZkpEqTest(const sheSecretKey *sec, const PK *pub, encWithZkpFunc encWithZkp
{
char buf[2048];
size_t n = sheZkpEqSerialize(buf, sizeof(buf), &zkp);
- CYBOZU_TEST_EQUAL(n, mclBn_getOpUnitSize() * 8 * 4);
+ CYBOZU_TEST_EQUAL(n, mclBn_getFrByteSize() * CYBOZU_NUM_OF_ARRAY(zkp.d));
sheZkpEq zkp2;
size_t r = sheZkpEqDeserialize(&zkp2, buf, n);
CYBOZU_TEST_EQUAL(r, n);
- CYBOZU_TEST_ASSERT(memcmp(&zkp, &zkp2, n) == 0);
+ for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(zkp.d); i++) {
+ CYBOZU_TEST_ASSERT(mclBnFr_isEqual(&zkp.d[i], &zkp2.d[i]));
+ }
}
zkp.d[0].d[0]++;
CYBOZU_TEST_EQUAL(verify(pub, &c1, &c2, &zkp), 0);
diff --git a/test/she_test.cpp b/test/she_test.cpp
index aedadc0..810a749 100644
--- a/test/she_test.cpp
+++ b/test/she_test.cpp
@@ -256,7 +256,6 @@ CYBOZU_TEST_AUTO(ZkpBin)
ZkpBinTest<CipherTextG2>(sec, ppub);
}
-#if 0
template<class PubT>
void ZkpEqTest(const SecretKey& sec, const PubT& pub)
{
@@ -312,7 +311,6 @@ CYBOZU_TEST_AUTO(ZkpBinEq)
ppub.init(pub);
ZkpBinEqTest(sec, ppub);
}
-#endif
CYBOZU_TEST_AUTO(add_sub_mul)
{