Cleanup Add and Double return values
parent
88b37cff04
commit
bb8e4cb74c
50
ecp.cpp
50
ecp.cpp
|
|
@ -503,12 +503,10 @@ ECP::AdditionFunction::AdditionFunction(const ECP& ecp)
|
||||||
{
|
{
|
||||||
if (m_ecp.GetField().IsMontgomeryRepresentation())
|
if (m_ecp.GetField().IsMontgomeryRepresentation())
|
||||||
{
|
{
|
||||||
// std::cerr << "Montgomery, skipping" << std::endl;
|
|
||||||
m_alpha = A_Montgomery;
|
m_alpha = A_Montgomery;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// std::cerr << "non-Montgomery, continuing" << std::endl;
|
|
||||||
if (m_ecp.m_a == 0)
|
if (m_ecp.m_a == 0)
|
||||||
{
|
{
|
||||||
m_alpha = 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);
|
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
|
||||||
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
||||||
|
|
||||||
if (Z3.IsZero())
|
// More gyrations
|
||||||
return m_ecp.Identity();
|
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
|
||||||
else
|
result.identity = Z3.IsZero();
|
||||||
return ECP::Point(X3, Y3);
|
return result;
|
||||||
}
|
}
|
||||||
else if (m_alpha == A_0)
|
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);
|
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
|
||||||
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
||||||
|
|
||||||
if (Z3.IsZero())
|
// More gyrations
|
||||||
return m_ecp.Identity();
|
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
|
||||||
else
|
result.identity = Z3.IsZero();
|
||||||
return ECP::Point(X3, Y3);
|
return result;
|
||||||
}
|
}
|
||||||
else if (m_alpha == A_Star)
|
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);
|
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
|
||||||
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
||||||
|
|
||||||
if (Z3.IsZero())
|
// More gyrations
|
||||||
return m_ecp.Identity();
|
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
|
||||||
else
|
result.identity = Z3.IsZero();
|
||||||
return ECP::Point(X3, Y3);
|
return result;
|
||||||
}
|
}
|
||||||
else // A_Montgomery
|
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);
|
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
|
||||||
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
||||||
|
|
||||||
if (Z3.IsZero())
|
// More gyrations
|
||||||
return m_ecp.Identity();
|
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
|
||||||
else
|
result.identity = Z3.IsZero();
|
||||||
return ECP::Point(X3, Y3);
|
return result;
|
||||||
}
|
}
|
||||||
else if (m_alpha == A_0)
|
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);
|
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
|
||||||
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
||||||
|
|
||||||
if (Z3.IsZero())
|
// More gyrations
|
||||||
return m_ecp.Identity();
|
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
|
||||||
else
|
result.identity = Z3.IsZero();
|
||||||
return ECP::Point(X3, Y3);
|
return result;
|
||||||
}
|
}
|
||||||
else if (m_alpha == A_Star)
|
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);
|
const FieldElement inv = field.MultiplicativeInverse(Z3.IsZero() ? Integer::One() : Z3);
|
||||||
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
X3 = field.Multiply(X3, inv); Y3 = field.Multiply(Y3, inv);
|
||||||
|
|
||||||
if (Z3.IsZero())
|
// More gyrations
|
||||||
return m_ecp.Identity();
|
ECP::Point result(X3*Z3.NotZero(), Y3*Z3.NotZero());
|
||||||
else
|
result.identity = Z3.IsZero();
|
||||||
return ECP::Point(X3, Y3);
|
return result;
|
||||||
}
|
}
|
||||||
else // A_Montgomery
|
else // A_Montgomery
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue