Skip to content

Commit 0d243a2

Browse files
committed
check for infinity before calling out to jni for ecmul
Signed-off-by: garyschulte <garyschulte@gmail.com>
1 parent be8f494 commit 0d243a2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class AltBN128MulPrecompiledContract extends AbstractAltBnPrecompiledCont
3838
new BigInteger(
3939
"115792089237316195423570985008687907853269984665640564039457584007913129639935");
4040

41+
private static final Bytes POINT_AT_INFINITY = Bytes.repeat((byte) 0, 64);
4142
private final long gasCost;
4243

4344
private AltBN128MulPrecompiledContract(final GasCalculator gasCalculator, final long gasCost) {
@@ -78,6 +79,12 @@ public long gasRequirement(final Bytes input) {
7879
@Override
7980
public PrecompileContractResult computePrecompile(
8081
final Bytes input, @Nonnull final MessageFrame messageFrame) {
82+
83+
if (input.size() >= 64 && input.slice(0,64).equals(POINT_AT_INFINITY)) {
84+
return new PrecompileContractResult(
85+
POINT_AT_INFINITY, false, MessageFrame.State.COMPLETED_SUCCESS, Optional.empty());
86+
}
87+
8188
if (useNative) {
8289
return computeNative(input, messageFrame);
8390
} else {

0 commit comments

Comments
 (0)