Skip to content

Commit

Permalink
Rename: normalize -> normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Feb 24, 2025
1 parent 1bac432 commit 1bf09c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/utils/P256.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/P256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 1bf09c2

Please sign in to comment.