Skip to content

Commit 809ded8

Browse files
authored
Remove redundant modulo operation in P256 (#5200)
1 parent 37c35a1 commit 809ded8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contracts/utils/cryptography/P256.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ library P256 {
130130
uint256 ry2 = addmod(mulmod(addmod(mulmod(rx, rx, p), A, p), rx, p), B, p); // weierstrass equation y² = x³ + a.x + b
131131
uint256 ry = Math.modExp(ry2, P1DIV4, p); // This formula for sqrt work because P ≡ 3 (mod 4)
132132
if (mulmod(ry, ry, p) != ry2) return (0, 0); // Sanity check
133-
if (ry % 2 != v % 2) ry = p - ry;
133+
if (ry % 2 != v) ry = p - ry;
134134

135135
JPoint[16] memory points = _preComputeJacobianPoints(rx, ry);
136136
uint256 w = Math.invModPrime(uint256(r), N);

0 commit comments

Comments
 (0)