|
|
@ -28,9 +28,11 @@ struct Test { |
|
|
|
void cstr() const |
|
|
|
void cstr() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ec O; |
|
|
|
Ec O; |
|
|
|
|
|
|
|
O.clear(); |
|
|
|
CYBOZU_TEST_ASSERT(O.isZero()); |
|
|
|
CYBOZU_TEST_ASSERT(O.isZero()); |
|
|
|
CYBOZU_TEST_ASSERT(O.isValid()); |
|
|
|
CYBOZU_TEST_ASSERT(O.isValid()); |
|
|
|
Ec P; |
|
|
|
Ec P; |
|
|
|
|
|
|
|
P.clear(); |
|
|
|
Ec::neg(P, O); |
|
|
|
Ec::neg(P, O); |
|
|
|
CYBOZU_TEST_EQUAL(P, O); |
|
|
|
CYBOZU_TEST_EQUAL(P, O); |
|
|
|
} |
|
|
|
} |
|
|
@ -65,6 +67,7 @@ struct Test { |
|
|
|
CYBOZU_TEST_NO_EXCEPTION(Ec(x, y)); |
|
|
|
CYBOZU_TEST_NO_EXCEPTION(Ec(x, y)); |
|
|
|
CYBOZU_TEST_EXCEPTION(Ec(x, y + 1), cybozu::Exception); |
|
|
|
CYBOZU_TEST_EXCEPTION(Ec(x, y + 1), cybozu::Exception); |
|
|
|
Ec P(x, y), Q, R, O; |
|
|
|
Ec P(x, y), Q, R, O; |
|
|
|
|
|
|
|
O.clear(); |
|
|
|
CYBOZU_TEST_ASSERT(P.isNormalized()); |
|
|
|
CYBOZU_TEST_ASSERT(P.isNormalized()); |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ec::neg(Q, P); |
|
|
|
Ec::neg(Q, P); |
|
|
@ -153,6 +156,7 @@ struct Test { |
|
|
|
Ec P(x, y); |
|
|
|
Ec P(x, y); |
|
|
|
Ec Q; |
|
|
|
Ec Q; |
|
|
|
Ec R; |
|
|
|
Ec R; |
|
|
|
|
|
|
|
R.clear(); |
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
Ec::mul(Q, P, i); |
|
|
|
Ec::mul(Q, P, i); |
|
|
|
CYBOZU_TEST_EQUAL(Q, R); |
|
|
|
CYBOZU_TEST_EQUAL(Q, R); |
|
|
@ -167,6 +171,7 @@ struct Test { |
|
|
|
Ec P(x, y); |
|
|
|
Ec P(x, y); |
|
|
|
Ec Q; |
|
|
|
Ec Q; |
|
|
|
Ec R; |
|
|
|
Ec R; |
|
|
|
|
|
|
|
R.clear(); |
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
Ec::mul(Q, P, -i); |
|
|
|
Ec::mul(Q, P, -i); |
|
|
|
CYBOZU_TEST_EQUAL(Q, R); |
|
|
|
CYBOZU_TEST_EQUAL(Q, R); |
|
|
@ -194,6 +199,7 @@ struct Test { |
|
|
|
Ec P(x, y); |
|
|
|
Ec P(x, y); |
|
|
|
Ec Q; |
|
|
|
Ec Q; |
|
|
|
Ec R; |
|
|
|
Ec R; |
|
|
|
|
|
|
|
R.clear(); |
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
Ec::mul(Q, P, Zn(i)); |
|
|
|
Ec::mul(Q, P, Zn(i)); |
|
|
|
CYBOZU_TEST_EQUAL(Q, R); |
|
|
|
CYBOZU_TEST_EQUAL(Q, R); |
|
|
@ -299,6 +305,7 @@ struct Test { |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream ss; |
|
|
|
std::stringstream ss; |
|
|
|
Ec Q; |
|
|
|
Ec Q; |
|
|
|
|
|
|
|
Q.clear(); |
|
|
|
ss << Q; |
|
|
|
ss << Q; |
|
|
|
Ec R; |
|
|
|
Ec R; |
|
|
|
ss >> R; |
|
|
|
ss >> R; |
|
|
|