|
|
|
@ -1,10 +1,5 @@ |
|
|
|
|
#include <cybozu/test.hpp> |
|
|
|
|
#include <cybozu/random_generator.hpp> |
|
|
|
|
#ifdef MCL_DONT_USE_OPENSSL |
|
|
|
|
#include <cybozu/sha1.hpp> |
|
|
|
|
#else |
|
|
|
|
#include <cybozu/crypto.hpp> |
|
|
|
|
#endif |
|
|
|
|
#include <mcl/fp.hpp> |
|
|
|
|
#include <mcl/ecparam.hpp> |
|
|
|
|
#include <mcl/elgamal.hpp> |
|
|
|
@ -147,19 +142,14 @@ CYBOZU_TEST_AUTO(testEc) |
|
|
|
|
{ |
|
|
|
|
ElgamalEc::Zkp zkp; |
|
|
|
|
ElgamalEc::CipherText c; |
|
|
|
|
#ifdef MCL_DONT_USE_OPENSSL |
|
|
|
|
cybozu::Sha1 hash; |
|
|
|
|
#else |
|
|
|
|
cybozu::crypto::Hash hash(cybozu::crypto::Hash::N_SHA256); |
|
|
|
|
#endif |
|
|
|
|
pub.encWithZkp(c, zkp, 0, hash, rg); |
|
|
|
|
CYBOZU_TEST_ASSERT(pub.verify(c, zkp, hash)); |
|
|
|
|
pub.encWithZkp(c, zkp, 0, rg); |
|
|
|
|
CYBOZU_TEST_ASSERT(pub.verify(c, zkp)); |
|
|
|
|
zkp.s0 += 1; |
|
|
|
|
CYBOZU_TEST_ASSERT(!pub.verify(c, zkp, hash)); |
|
|
|
|
pub.encWithZkp(c, zkp, 1, hash, rg); |
|
|
|
|
CYBOZU_TEST_ASSERT(pub.verify(c, zkp, hash)); |
|
|
|
|
CYBOZU_TEST_ASSERT(!pub.verify(c, zkp)); |
|
|
|
|
pub.encWithZkp(c, zkp, 1, rg); |
|
|
|
|
CYBOZU_TEST_ASSERT(pub.verify(c, zkp)); |
|
|
|
|
zkp.s0 += 1; |
|
|
|
|
CYBOZU_TEST_ASSERT(!pub.verify(c, zkp, hash)); |
|
|
|
|
CYBOZU_TEST_EXCEPTION_MESSAGE(pub.encWithZkp(c, zkp, 2, hash, rg), cybozu::Exception, "encWithZkp"); |
|
|
|
|
CYBOZU_TEST_ASSERT(!pub.verify(c, zkp)); |
|
|
|
|
CYBOZU_TEST_EXCEPTION_MESSAGE(pub.encWithZkp(c, zkp, 2, rg), cybozu::Exception, "encWithZkp"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|