Skip to content

Commit

Permalink
Remove unnecessary checks in ecAdd (#144)
Browse files Browse the repository at this point in the history
* #140

* #141

* #142
  • Loading branch information
ilitteri authored Sep 26, 2023
1 parent 3044527 commit a891bb8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions precompiles/EcAdd.yul
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ object "EcAdd" {
mstore(32, 0)
return(0, 64)
}
if and(p1IsInfinity, iszero(p2IsInfinity)) {
if p1IsInfinity {
// Infinity + P = P

// Ensure that the coordinates are between 0 and the field order.
Expand All @@ -307,7 +307,7 @@ object "EcAdd" {
mstore(32, y2)
return(0, 64)
}
if and(iszero(p1IsInfinity), p2IsInfinity) {
if p2IsInfinity {
// P + Infinity = P

// Ensure that the coordinates are between 0 and the field order.
Expand Down Expand Up @@ -352,7 +352,7 @@ object "EcAdd" {
let m_y2 := intoMontgomeryForm(y2)

// Ensure that the points are in the curve (Y^2 = X^3 + 3).
if or(iszero(pointIsInCurve(m_x1, m_y1)), iszero(pointIsInCurve(m_x2, m_y2))) {
if iszero(pointIsInCurve(m_x1, m_y1)) {
invalid()
}

Expand All @@ -364,10 +364,6 @@ object "EcAdd" {
return(0, 64)
}

if and(eq(x1, x2), and(iszero(eq(y1, y2)), iszero(eq(y1, submod(0, y2, P()))))) {
invalid()
}

if and(eq(x1, x2), eq(y1, y2)) {
// P + P = 2P

Expand Down

0 comments on commit a891bb8

Please sign in to comment.