[she] rename rerandomize to reRand

dev
MITSUNARI Shigeo 7 years ago
parent d0696009d7
commit e2c7097f79
  1. 25
      include/mcl/she.hpp
  2. 12
      test/she_test.cpp

@ -751,28 +751,28 @@ public:
c += Enc(0)
*/
template<class RG>
void rerandomize(CipherTextG1& c, RG& rg) const
void reRand(CipherTextG1& c, RG& rg) const
{
CipherTextG1 c0;
enc(c0, 0, rg);
CipherTextG1::add(c, c, c0);
}
template<class RG>
void rerandomize(CipherTextG2& c, RG& rg) const
void reRand(CipherTextG2& c, RG& rg) const
{
CipherTextG2 c0;
enc(c0, 0, rg);
CipherTextG2::add(c, c, c0);
}
template<class RG>
void rerandomize(CipherTextA& c, RG& rg) const
void reRand(CipherTextA& c, RG& rg) const
{
CipherTextA c0;
enc(c0, 0, rg);
CipherTextA::add(c, c, c0);
}
template<class RG>
void rerandomize(CipherTextM& c, RG& rg) const
void reRand(CipherTextM& c, RG& rg) const
{
#if 1 // for circuit security : 3.58Mclk -> 5.4Mclk
CipherTextM c0;
@ -798,19 +798,19 @@ public:
#endif
}
template<class RG>
void rerandomize(CipherText& c, RG& rg) const
void reRand(CipherText& c, RG& rg) const
{
if (c.isMultiplied()) {
rerandomize(c.m_, rg);
reRand(c.m_, rg);
} else {
rerandomize(c.a_, rg);
reRand(c.a_, rg);
}
}
void rerandomize(CipherTextG1& c) const { rerandomize(c, local::g_rg); }
void rerandomize(CipherTextG2& c) const { rerandomize(c, local::g_rg); }
void rerandomize(CipherTextA& c) const { rerandomize(c, local::g_rg); }
void rerandomize(CipherTextM& c) const { rerandomize(c, local::g_rg); }
void rerandomize(CipherText& c) const { rerandomize(c, local::g_rg); }
void reRand(CipherTextG1& c) const { reRand(c, local::g_rg); }
void reRand(CipherTextG2& c) const { reRand(c, local::g_rg); }
void reRand(CipherTextA& c) const { reRand(c, local::g_rg); }
void reRand(CipherTextM& c) const { reRand(c, local::g_rg); }
void reRand(CipherText& c) const { reRand(c, local::g_rg); }
std::istream& readStream(std::istream& is, int ioMode)
{
@ -1152,6 +1152,7 @@ typedef SHE::CipherTextG1 CipherTextG1;
typedef SHE::CipherTextG2 CipherTextG2;
typedef SHE::CipherTextA CipherTextA;
typedef SHE::CipherTextM CipherTextM;
typedef CipherTextM CipherTextGT;
typedef SHE::CipherText CipherText;
} } // mcl::she

@ -85,7 +85,7 @@ CYBOZU_TEST_AUTO(enc_dec)
for (int i = -5; i < 5; i++) {
pub.enc(c, i);
CYBOZU_TEST_EQUAL(sec.dec(c), i);
pub.rerandomize(c);
pub.reRand(c);
CYBOZU_TEST_EQUAL(sec.dec(c), i);
}
}
@ -103,7 +103,7 @@ CYBOZU_TEST_AUTO(add_sub_mul)
CipherText::add(c3, c1, c2);
CYBOZU_TEST_EQUAL(m1 + m2, sec.dec(c3));
pub.rerandomize(c3);
pub.reRand(c3);
CYBOZU_TEST_EQUAL(m1 + m2, sec.dec(c3));
CipherText::sub(c3, c1, c2);
@ -117,7 +117,7 @@ CYBOZU_TEST_AUTO(add_sub_mul)
CipherText::mul(c3, c1, c2);
CYBOZU_TEST_EQUAL(m1 * m2, sec.dec(c3));
pub.rerandomize(c3);
pub.reRand(c3);
CYBOZU_TEST_EQUAL(m1 * m2, sec.dec(c3));
CipherText::mul(c3, c3, -25);
@ -375,9 +375,9 @@ CYBOZU_TEST_AUTO(hashBench)
CYBOZU_BENCH_C("addG1 ", C, CipherTextG1::add, ca1, ca1, ca1);
CYBOZU_BENCH_C("addG2 ", C, CipherTextG2::add, ca2, ca2, ca2);
CYBOZU_BENCH_C("addGT ", C, CipherTextM::add, cm, cm, cm);
CYBOZU_BENCH_C("rerandG1", C, pub.rerandomize, ca1);
CYBOZU_BENCH_C("rerandG2", C, pub.rerandomize, ca2);
CYBOZU_BENCH_C("rerandGT", C, pub.rerandomize, cm);
CYBOZU_BENCH_C("reRandG1", C, pub.reRand, ca1);
CYBOZU_BENCH_C("reRandG2", C, pub.reRand, ca2);
CYBOZU_BENCH_C("reRandGT", C, pub.reRand, cm);
CYBOZU_BENCH_C("mulG1 ", C, CipherTextG1::mul, ca1, ca1, m);
CYBOZU_BENCH_C("mulG2 ", C, CipherTextG2::mul, ca2, ca2, m);
CYBOZU_BENCH_C("mulGT ", C, CipherTextM::mul, cm, cm, m);

Loading…
Cancel
Save