Redundant point-at-infinity check in `projectiveAdd()`
Closed this issue · 1 comments
ilitteri commented
Context: P256VERIFY.yul#L442
Description:
In the projectiveAdd()
the check if and(pIsInfinity, qIsInfinity)
is redundant. In this case where both if pIsInfinity
: the
Recommendation:
Remove the if and(pIsInfinity, qIsInfinity)
check.
diff --git a/precompiles/P256VERIFY.yul b/precompiles/P256VERIFY.yul
index c75be80..4baca50 100644
--- a/precompiles/P256VERIFY.yul
+++ b/precompiles/P256VERIFY.yul
@@ -439,13 +439,6 @@ object "P256VERIFY" {
function projectiveAdd(xp, yp, zp, xq, yq, zq) -> xr, yr, zr {
let qIsInfinity := projectivePointIsInfinity(xq, yq, zq)
let pIsInfinity := projectivePointIsInfinity(xp, yp, zp)
- if and(pIsInfinity, qIsInfinity) {
- // Infinity + Infinity = Infinity
- xr := 0
- yr := MONTGOMERY_ONE_P()
- zr := 0
- leave
- }
if pIsInfinity {
// Infinity + Q = Q
xr := xq