enable ZkpEqTest and ZkpBinEqTest

dev
MITSUNARI Shigeo 7 years ago
parent 1189ddf898
commit ddcbd090a4
  1. 9
      src/she_c_impl.hpp
  2. 12
      test/she_c_test.hpp
  3. 2
      test/she_test.cpp

@ -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;
}

@ -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);

@ -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)
{

Loading…
Cancel
Save