|
|
|
@ -21,11 +21,6 @@ CYBOZU_TEST_AUTO(init) |
|
|
|
|
CYBOZU_TEST_EQUAL(ret, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int64_t toInt(const uint32_t m[2]) |
|
|
|
|
{ |
|
|
|
|
return m[0] + (int64_t(m[1]) << 32); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(encDec) |
|
|
|
|
{ |
|
|
|
|
sheSecretKey sec; |
|
|
|
@ -39,11 +34,11 @@ CYBOZU_TEST_AUTO(encDec) |
|
|
|
|
sheEncG1(&c1, &pub, m); |
|
|
|
|
sheEncGT(&ct, &pub, m); |
|
|
|
|
|
|
|
|
|
uint32_t dec[2]; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecG1(dec, &sec, &c1), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(toInt(dec), m); |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(dec, &sec, &ct), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(toInt(dec), m); |
|
|
|
|
int64_t dec; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecG1(&dec, &sec, &c1), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(dec, m); |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(&dec, &sec, &ct), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(dec, m); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(addMul) |
|
|
|
@ -62,9 +57,9 @@ CYBOZU_TEST_AUTO(addMul) |
|
|
|
|
sheEncG2(&c2, &pub, m2); |
|
|
|
|
sheMul(&ct, &c1, &c2); |
|
|
|
|
|
|
|
|
|
uint32_t dec[2]; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(dec, &sec, &ct), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(toInt(dec), m1 * m2); |
|
|
|
|
int64_t dec; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(&dec, &sec, &ct), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(dec, m1 * m2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(allOp) |
|
|
|
@ -95,9 +90,9 @@ CYBOZU_TEST_AUTO(allOp) |
|
|
|
|
sheMulGT(&ct, &ct, -4); // 160 * (m1 - m2) * (m3 - m4)
|
|
|
|
|
|
|
|
|
|
int64_t t = 160 * (m1 - m2) * (m3 - m4); |
|
|
|
|
uint32_t dec[2]; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(dec, &sec, &ct), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(toInt(dec), t); |
|
|
|
|
int64_t dec; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(&dec, &sec, &ct), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(dec, t); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(rerand) |
|
|
|
@ -126,9 +121,9 @@ CYBOZU_TEST_AUTO(rerand) |
|
|
|
|
sheReRandGT(&ct2, &pub); |
|
|
|
|
sheAddGT(&ct1, &ct1, &ct2); |
|
|
|
|
|
|
|
|
|
uint32_t dec[2]; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(dec, &sec, &ct1), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(toInt(dec), m1 * m2 + m3); |
|
|
|
|
int64_t dec; |
|
|
|
|
CYBOZU_TEST_EQUAL(sheDecGT(&dec, &sec, &ct1), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(dec, m1 * m2 + m3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(serialize) |
|
|
|
|