Remove unneeded T in ECP Add()

Switch to 'R' variable in AdditionFunction to avoid shadow warnings
pull/873/head
Jeffrey Walton 2019-08-06 03:28:53 -04:00
parent 0ded32192e
commit e5ab7919f9
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 11 additions and 13 deletions

24
ecp.cpp
View File

@ -661,7 +661,7 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P) const
} }
else // A_Montgomery else // A_Montgomery
{ {
ECP::Point& m_R = m_ecp.m_R; ECP::Point& R = m_ecp.m_R;
const ECP::Field& field = m_ecp.GetField(); const ECP::Field& field = m_ecp.GetField();
const FieldElement& a = m_ecp.m_a; const FieldElement& a = m_ecp.m_a;
@ -672,15 +672,15 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P) const
t = field.Add(field.Add(field.Double(t), t), a); t = field.Add(field.Add(field.Double(t), t), a);
t = field.Divide(t, field.Double(P.y)); t = field.Divide(t, field.Double(P.y));
FieldElement x = field.Subtract(field.Subtract(field.Square(t), P.x), P.x); FieldElement x = field.Subtract(field.Subtract(field.Square(t), P.x), P.x);
m_R.y = field.Subtract(field.Multiply(t, field.Subtract(P.x, x)), P.y); R.y = field.Subtract(field.Multiply(t, field.Subtract(P.x, x)), P.y);
m_R.x.swap(x); R.x.swap(x);
// More gyrations // More gyrations
m_R.x *= IdentityToInteger(!identity); R.x *= IdentityToInteger(!identity);
m_R.y *= IdentityToInteger(!identity); R.y *= IdentityToInteger(!identity);
m_R.identity = identity; R.identity = identity;
return m_R; return R;
} }
} }
@ -870,7 +870,7 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P, const Point& Q) con
{ {
const ECP::Field& field = m_ecp.GetField(); const ECP::Field& field = m_ecp.GetField();
const FieldElement& a = m_ecp.m_a; const FieldElement& a = m_ecp.m_a;
ECP::Point& R = m_ecp.m_R, S = m_ecp.m_R, T; ECP::Point& R = m_ecp.m_R, S = m_ecp.m_R;
// More gyrations // More gyrations
bool return_Q = P.identity; bool return_Q = P.identity;
@ -888,8 +888,8 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P, const Point& Q) con
t = field.Add(field.Add(field.Double(t), t), a); t = field.Add(field.Add(field.Double(t), t), a);
t = field.Divide(t, field.Double(P.y)); t = field.Divide(t, field.Double(P.y));
FieldElement x = field.Subtract(field.Subtract(field.Square(t), P.x), P.x); FieldElement x = field.Subtract(field.Subtract(field.Square(t), P.x), P.x);
T.y = field.Subtract(field.Multiply(t, field.Subtract(P.x, x)), P.y); R.y = field.Subtract(field.Multiply(t, field.Subtract(P.x, x)), P.y);
T.x.swap(x); R.x.swap(x);
} }
else else
{ {
@ -910,10 +910,8 @@ ECP::Point ECP::AdditionFunction::operator()(const Point& P, const Point& Q) con
return (R = S), Q; return (R = S), Q;
else if (return_P) else if (return_P)
return (R = S), P; return (R = S), P;
else if (double_P)
return (T = R), R;
else else
return (T = R), R; return (S = R), R;
} }
} }