[she] add test of pub.convert

dev
MITSUNARI Shigeo 7 years ago
parent 4f88d30c46
commit b06b6c93f1
  1. 8
      include/mcl/she.hpp
  2. 6
      test/she_test.cpp

@ -897,8 +897,7 @@ public:
BN::precomputedMillerLoop(cm.g_[2], c1.T_, Qcoeff_);
BN::finalExp(cm.g_[2], cm.g_[2]);
cm.g_[1] = 1;
cm.g_[3] = 1;
cm.g_[1] = cm.g_[3] = 1;
}
/*
convert from CipherTextG2 to CipherTextGT
@ -909,8 +908,9 @@ public:
Enc(1) = (S, T) = (P + r xP, rP) = (P, 0) if r = 0
cm = (P, 0) * c2 = (e(P, S), e(P, T), 1, 1)
*/
G1 zero; zero.clear();
tensorProduct(cm.g_, P_, zero, c2.S_, c2.T_);
BN::pairing(cm.g_[0], P_, c2.S_);
BN::pairing(cm.g_[1], P_, c2.T_);
cm.g_[2] = cm.g_[3] = 1;
}
void convert(CipherTextGT& cm, const CipherTextA& ca) const
{

@ -107,10 +107,16 @@ CYBOZU_TEST_AUTO(enc_dec)
CYBOZU_TEST_EQUAL(sec.dec(c1), i);
CYBOZU_TEST_EQUAL(sec.decViaGT(c1), i);
CYBOZU_TEST_EQUAL(sec.isZero(c1), i == 0);
ct1.clear();
pub.convert(ct1, c1);
CYBOZU_TEST_EQUAL(sec.dec(ct1), i);
ppub.enc(c2, i);
CYBOZU_TEST_EQUAL(sec.dec(c2), i);
CYBOZU_TEST_EQUAL(sec.decViaGT(c2), i);
CYBOZU_TEST_EQUAL(sec.isZero(c2), i == 0);
ct1.clear();
pub.convert(ct1, c2);
CYBOZU_TEST_EQUAL(sec.dec(ct1), i);
pub.enc(c, i);
CYBOZU_TEST_EQUAL(sec.isZero(c), i == 0);
}

Loading…
Cancel
Save