Cleanup Add and Double return values

pull/871/head
Jeffrey Walton 2019-08-05 02:05:11 -04:00
parent 88b37cff04
commit bb8e4cb74c
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 24 additions and 26 deletions

50
ecp.cpp
View File

@ -503,12 +503,10 @@ ECP::AdditionFunction::AdditionFunction(const ECP& ecp)
{
if (m_ecp.GetField().IsMontgomeryRepresentation())
{
// std::cerr << "Montgomery, skipping" << std::endl;
m_alpha = A_Montgomery;
}
else
{
// std::cerr << "non-Montgomery, continuing" << std::endl;
if (m_ecp.m_a == 0)
{
m_alpha = A_0;
@ -577,10 +575,10 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P) const
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
if (Z3.IsZero())
return m_ecp.Identity();
else
return ECP::Point(X3, Y3);
// More gyrations
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
result.identity = Z3.IsZero();
return result;
}
else if (m_alpha == A_0)
{
@ -617,10 +615,10 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P) const
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
if (Z3.IsZero())
return m_ecp.Identity();
else
return ECP::Point(X3, Y3);
// More gyrations
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
result.identity = Z3.IsZero();
return result;
}
else if (m_alpha == A_Star)
{
@ -657,10 +655,10 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P) const
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
if (Z3.IsZero())
return m_ecp.Identity();
else
return ECP::Point(X3, Y3);
// More gyrations
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
result.identity = Z3.IsZero();
return result;
}
else // A_Montgomery
{
@ -747,10 +745,10 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P, const Point& Q) con
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
if (Z3.IsZero())
return m_ecp.Identity();
else
return ECP::Point(X3, Y3);
// More gyrations
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
result.identity = Z3.IsZero();
return result;
}
else if (m_alpha == A_0)
{
@ -791,10 +789,10 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P, const Point& Q) con
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
if (Z3.IsZero())
return m_ecp.Identity();
else
return ECP::Point(X3, Y3);
// More gyrations
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
result.identity = Z3.IsZero();
return result;
}
else if (m_alpha == A_Star)
{
@ -858,10 +856,10 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P, const Point& Q) con
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
if (Z3.IsZero())
return m_ecp.Identity();
else
return ECP::Point(X3, Y3);
// More gyrations
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
result.identity = Z3.IsZero();
return result;
}
else // A_Montgomery
{