remove omitted version

dev
MITSUNARI Shigeo 8 years ago
parent 16fb544eb4
commit 96e8cdaf32
  1. 2
      include/mcl/bn.hpp
  2. 9
      include/mcl/fp.hpp
  3. 40
      test/fp_tower_test.cpp

@ -221,7 +221,7 @@ struct ParamT {
G1::init(0, b, mcl::ec::Proj);
G2::init(0, b_div_xi, mcl::ec::Proj);
pow(g[0], xi, (p - 1) / 6); // g = xi^((p-1)/6)
Fp2::pow(g[0], xi, (p - 1) / 6); // g = xi^((p-1)/6)
for (size_t i = 1; i < gN; i++) {
g[i] = g[i - 1] * g[0];
}

@ -548,15 +548,6 @@ template<class tag, size_t maxBitSize> fp::Op FpT<tag, maxBitSize>::op_;
template<class tag, size_t maxBitSize> FpT<tag, maxBitSize> FpT<tag, maxBitSize>::inv2_;
template<class tag, size_t maxBitSize> IoMode FpT<tag, maxBitSize>::ioMode_ = IoAuto;
template<class T> void add(T& z, const T& x, const T& y) { T::add(z, x, y); }
template<class T> void sub(T& z, const T& x, const T& y) { T::sub(z, x, y); }
template<class T> void mul(T& z, const T& x, const T& y) { T::mul(z, x, y); }
template<class T> void div(T& z, const T& x, const T& y) { T::div(z, x, y); }
template<class T> void neg(T& y, const T& x) { T::neg(y, x); }
template<class T> void inv(T& y, const T& x) { T::inv(y, x); }
template<class T> void sqr(T& y, const T& x) { T::sqr(y, x); }
template<class T, class S> void pow(T& z, const T& x, const S& y) { T::pow(z, x, y); }
} // mcl
#ifdef CYBOZU_USE_BOOST

@ -45,16 +45,16 @@ void testFp2()
x = 1 + 2i
y = 3 + 4i
*/
add(z, x, y);
Fp2::add(z, x, y);
CYBOZU_TEST_EQUAL(z, Fp2(4, 6));
sub(z, x, y);
Fp2::sub(z, x, y);
CYBOZU_TEST_EQUAL(z, Fp2(-2, -2));
mul(z, x, y);
Fp2::mul(z, x, y);
/*
(1 + 2i)(3 + 4i) = (3 - 8) + (4 + 6)i = -5 + 10i
*/
CYBOZU_TEST_EQUAL(z, Fp2(-5, 10));
neg(z, z);
Fp2::neg(z, z);
CYBOZU_TEST_EQUAL(z, Fp2(5, -10));
/*
xi = xi_a + i
@ -64,12 +64,12 @@ void testFp2()
Fp2::mul_xi(z, z);
CYBOZU_TEST_EQUAL(z, Fp2(Fp2::getXi_a() + 2, Fp2::getXi_a() * (-2) + 1));
z = x * x;
sqr(y, x);
Fp2::sqr(y, x);
CYBOZU_TEST_EQUAL(z, y);
x.a = -123456789;
x.b = 464652165165;
y = x * x;
sqr(x, x);
Fp2::sqr(x, x);
CYBOZU_TEST_EQUAL(x, y);
{
std::ostringstream oss;
@ -81,7 +81,7 @@ void testFp2()
}
y = 1;
for (int i = 0; i < 10; i++) {
pow(z, x, i);
Fp2::pow(z, x, i);
CYBOZU_TEST_EQUAL(z, y);
y *= x;
}
@ -92,9 +92,9 @@ void testFp2()
{
const mpz_class& mp = Fp::getOp().mp;
y = x;
pow(z, y, mp);
Fp2::pow(z, y, mp);
if ((mp % 4) == 3) {
neg(z.b, z.b);
Fp::neg(z.b, z.b);
}
CYBOZU_TEST_EQUAL(z, y);
}
@ -117,7 +117,7 @@ void testFp2()
CYBOZU_TEST_EQUAL(a * c, Fp2(2));
}
y = x;
inv(y, x);
Fp2::inv(y, x);
y *= x;
CYBOZU_TEST_EQUAL(y, 1);
@ -171,28 +171,28 @@ void testFp6()
ss >> z;
CYBOZU_TEST_EQUAL(x, z);
}
add(z, x, y);
Fp6::add(z, x, y);
CYBOZU_TEST_EQUAL(z, Fp6(Fp2(0, 3), Fp2(7, 1), Fp2(-1, 8)));
sub(z, x, y);
Fp6::sub(z, x, y);
CYBOZU_TEST_EQUAL(z, Fp6(Fp2(2, 1), Fp2(-1, 7), Fp2(11, 4)));
neg(z, x);
Fp6::neg(z, x);
CYBOZU_TEST_EQUAL(z, Fp6(-a, -b, -c));
sqr(z, x);
mul(w, x, x);
Fp6::sqr(z, x);
Fp6::mul(w, x, x);
testFp6sqr(a, b, c, z);
testFp6sqr(a, b, c, w);
z = x;
sqr(z, z);
mul(w, x, x);
Fp6::sqr(z, z);
Fp6::mul(w, x, x);
testFp6sqr(a, b, c, z);
testFp6sqr(a, b, c, w);
for (int i = 0; i < 10; i++) {
inv(y, x);
mul(z, y, x);
Fp6::inv(y, x);
Fp6::mul(z, y, x);
CYBOZU_TEST_EQUAL(z, 1);
x += y;
y = x;
inv(y, y);
Fp6::inv(y, y);
y *= x;
CYBOZU_TEST_EQUAL(y, 1);
}

Loading…
Cancel
Save