Skip to content

Commit f1c6b1d

Browse files
0xMushowfab-10
andauthored
fix(evm): correct P256VERIFY input length in error message (#9137)
* fix(evm): correct P256VERIFY input length in error message Signed-off-by: Antoine James <antoine@ethereum.org> * chore(evm): replaced hardcoded value with constant Signed-off-by: Antoine James <antoine@ethereum.org> * Update evm/src/main/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContract.java Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Antoine James <antoine@ethereum.org> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
1 parent 616c835 commit f1c6b1d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

evm/src/main/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContract.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class P256VerifyPrecompiledContract extends AbstractPrecompiledContract {
4040
private static final String PRECOMPILE_NAME = "P256VERIFY";
4141
private static final Bytes32 VALID = Bytes32.leftPad(Bytes.of(1), (byte) 0);
4242
private static final Bytes INVALID = Bytes.EMPTY;
43+
private static final int SECP256R1_INPUT_LENGTH = 160;
4344

4445
private static final X9ECParameters R1_PARAMS = SECNamedCurves.getByName("secp256r1");
4546
private static final BigInteger N = R1_PARAMS.getN();
@@ -121,9 +122,10 @@ public long gasRequirement(final Bytes input) {
121122
@Override
122123
public PrecompileContractResult computePrecompile(
123124
final Bytes input, final MessageFrame messageFrame) {
124-
if (input.size() != 160) {
125+
if (input.size() != SECP256R1_INPUT_LENGTH) {
125126
LOG.warn(
126-
"Invalid input length for P256VERIFY precompile: expected 128 bytes but got {}",
127+
"Invalid input length for P256VERIFY precompile: expected {} bytes but got {}",
128+
SECP256R1_INPUT_LENGTH,
127129
input.size());
128130
return PrecompileContractResult.success(INVALID);
129131
}

0 commit comments

Comments
 (0)