Skip to content

Commit 268f67f

Browse files
gurukamathSamWilsn
authored andcommitted
Implement EIP-7823
1 parent 1f5b621 commit 268f67f

File tree

1 file changed

+9
-0
lines changed
  • src/ethereum/osaka/vm/precompiled_contracts

1 file changed

+9
-0
lines changed

src/ethereum/osaka/vm/precompiled_contracts/modexp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ethereum_types.numeric import U256, Uint
1616

1717
from ...vm import Evm
18+
from ...vm.exceptions import ExceptionalHalt
1819
from ...vm.gas import charge_gas
1920
from ..memory import buffer_read
2021

@@ -30,8 +31,16 @@ def modexp(evm: Evm) -> None:
3031

3132
# GAS
3233
base_length = U256.from_be_bytes(buffer_read(data, U256(0), U256(32)))
34+
if base_length > U256(1024):
35+
raise ExceptionalHalt("Mod-exp base length is too large")
36+
3337
exp_length = U256.from_be_bytes(buffer_read(data, U256(32), U256(32)))
38+
if exp_length > U256(1024):
39+
raise ExceptionalHalt("Mod-exp exponent length is too large")
40+
3441
modulus_length = U256.from_be_bytes(buffer_read(data, U256(64), U256(32)))
42+
if modulus_length > U256(1024):
43+
raise ExceptionalHalt("Mod-exp modulus length is too large")
3544

3645
exp_start = U256(96) + base_length
3746

0 commit comments

Comments
 (0)