Browse Source

Remove redundant modulo operation in P256 (#5200)

Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
cairo 1 year ago
parent
commit
53f7ed8219
1 changed files with 1 additions and 1 deletions
  1. 1 1
      contracts/utils/cryptography/P256.sol

+ 1 - 1
contracts/utils/cryptography/P256.sol

@@ -130,7 +130,7 @@ library P256 {
         uint256 ry2 = addmod(mulmod(addmod(mulmod(rx, rx, p), A, p), rx, p), B, p); // weierstrass equation y² = x³ + a.x + b
         uint256 ry = Math.modExp(ry2, P1DIV4, p); // This formula for sqrt work because P ≡ 3 (mod 4)
         if (mulmod(ry, ry, p) != ry2) return (0, 0); // Sanity check
-        if (ry % 2 != v % 2) ry = p - ry;
+        if (ry % 2 != v) ry = p - ry;
 
         JPoint[16] memory points = _preComputeJacobianPoints(rx, ry);
         uint256 w = Math.invModPrime(uint256(r), N);