Skip to content

Commit 0f6c9f5

Browse files
committed
core/vm: use go-bigmodexpfix for modexp
1 parent cbf0b5b commit 0f6c9f5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

core/vm/contracts.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/ethereum/go-ethereum/crypto/kzg4844"
4040
"github.com/ethereum/go-ethereum/crypto/secp256r1"
4141
"github.com/ethereum/go-ethereum/params"
42+
patched_big "github.com/fjl/go-bigmodexpfix/src/math/big"
4243
"github.com/holiman/uint256"
4344
"golang.org/x/crypto/ripemd160"
4445
)
@@ -631,9 +632,9 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
631632
}
632633
// Retrieve the operands and execute the exponentiation
633634
var (
634-
base = new(big.Int).SetBytes(getData(input, 0, baseLen))
635-
exp = new(big.Int).SetBytes(getData(input, baseLen, expLen))
636-
mod = new(big.Int).SetBytes(getData(input, baseLen+expLen, modLen))
635+
base = new(patched_big.Int).SetBytes(getData(input, 0, baseLen))
636+
exp = new(patched_big.Int).SetBytes(getData(input, baseLen, expLen))
637+
mod = new(patched_big.Int).SetBytes(getData(input, baseLen+expLen, modLen))
637638
v []byte
638639
)
639640
switch {

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ require (
2727
github.com/fatih/color v1.16.0
2828
github.com/ferranbt/fastssz v0.1.4
2929
github.com/fjl/gencodec v0.1.0
30+
github.com/fjl/go-bigmodexpfix v0.0.0-20250910180133-3854a26432e2
3031
github.com/fsnotify/fsnotify v1.6.0
3132
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
3233
github.com/gofrs/flock v0.12.1
@@ -68,7 +69,7 @@ require (
6869
golang.org/x/crypto v0.36.0
6970
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
7071
golang.org/x/sync v0.12.0
71-
golang.org/x/sys v0.31.0
72+
golang.org/x/sys v0.36.0
7273
golang.org/x/text v0.23.0
7374
golang.org/x/time v0.9.0
7475
golang.org/x/tools v0.29.0

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ github.com/ferranbt/fastssz v0.1.4 h1:OCDB+dYDEQDvAgtAGnTSidK1Pe2tW3nFV40XyMkTeD
122122
github.com/ferranbt/fastssz v0.1.4/go.mod h1:Ea3+oeoRGGLGm5shYAeDgu6PGUlcvQhE2fILyD9+tGg=
123123
github.com/fjl/gencodec v0.1.0 h1:B3K0xPfc52cw52BBgUbSPxYo+HlLfAgWMVKRWXUXBcs=
124124
github.com/fjl/gencodec v0.1.0/go.mod h1:Um1dFHPONZGTHog1qD1NaWjXJW/SPB38wPv0O8uZ2fI=
125+
github.com/fjl/go-bigmodexpfix v0.0.0-20250910180133-3854a26432e2 h1:Alg35Y26VUpLVkuLDYmaLKONVllI4g0leaeLFgfrXy4=
126+
github.com/fjl/go-bigmodexpfix v0.0.0-20250910180133-3854a26432e2/go.mod h1:FMKd2dlNcWw0/Ub80EKa8FX1y5uWwGOPt5TGclrlmqQ=
125127
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
126128
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
127129
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
@@ -449,8 +451,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
449451
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
450452
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
451453
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
452-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
453-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
454+
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
455+
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
454456
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
455457
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
456458
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

0 commit comments

Comments
 (0)