Skip to content

Commit

Permalink
Remove redundant modulo operation in P256 (#5200)
Browse files Browse the repository at this point in the history
  • Loading branch information
cairoeth authored Sep 17, 2024
1 parent 37c35a1 commit 809ded8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/utils/cryptography/P256.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 809ded8

Please sign in to comment.