diff --git a/src/utils/P256.sol b/src/utils/P256.sol index d9208f8b0..d514fa168 100644 --- a/src/utils/P256.sol +++ b/src/utils/P256.sol @@ -112,11 +112,11 @@ library P256 { /* OTHER OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - /// @dev Normalize `s` to the lower half of the curve. - function normalize(bytes32 s) internal pure returns (bytes32 result) { + /// @dev Returns `s` normalized to the lower half of the curve. + function normalized(bytes32 s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { - result := xor(s, mul(xor(s, sub(N, s)), gt(s, _HALF_N))) + result := xor(s, mul(xor(sub(N, s), s), gt(s, _HALF_N))) } } diff --git a/test/P256.t.sol b/test/P256.t.sol index 2cdf528f0..975fa9a56 100644 --- a/test/P256.t.sol +++ b/test/P256.t.sol @@ -249,16 +249,16 @@ contract P256Test is P256VerifierEtcher { assertEq(yDecoded, y); } - function check_P256Normalize(uint256 s) public pure { + function check_P256Normalized(uint256 s) public pure { uint256 n = uint256(P256.N); unchecked { uint256 expected = s > (n / 2) ? n - s : s; - assert(uint256(P256.normalize(bytes32(s))) == expected); + assert(uint256(P256.normalized(bytes32(s))) == expected); } } - function testP256Normalize(uint256 s) public pure { - check_P256Normalize(s); + function testP256Normalized(uint256 s) public pure { + check_P256Normalized(s); } }