Skip to content

Commit

Permalink
yParity is valid up to 2**256 as well
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lehrner <[email protected]>
  • Loading branch information
daniellehrner committed Sep 20, 2024
1 parent 0ef4227 commit 31b30f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static CodeDelegationSignature create(
"Invalid 's' value, should be < 2^256 but got " + s.toString(16));
}

if (yParity.compareTo(TWO_POW_256) > 0) {
if (yParity.compareTo(TWO_POW_256) >= 0) {
throw new IllegalArgumentException(
"Invalid 'yParity' value, should be < 2^256 but got " + yParity.toString(16));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ void testSValueExceedsTwoPow256() {
.withMessageContainingAll("Invalid 's' value, should be < 2^256");
}

@Test
void testYParityExceedsTwoPow256() {
BigInteger r = BigInteger.ONE;
BigInteger s = BigInteger.TWO;
BigInteger yParity = TWO_POW_256;

assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> CodeDelegationSignature.create(r, s, yParity))
.withMessageContainingAll("Invalid 'yParity' value, should be < 2^256");
}

@Test
void testValidYParityZero() {
BigInteger r = BigInteger.ONE;
Expand Down

0 comments on commit 31b30f6

Please sign in to comment.