Skip to content

Commit ccf684f

Browse files
authored
core/vm: refactor to use bitutil.TestBytes (ethereum#32434)
1 parent a002a6c commit ccf684f

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

core/vm/common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,3 @@ func toWordSize(size uint64) uint64 {
8484

8585
return (size + 31) / 32
8686
}
87-
88-
func allZero(b []byte) bool {
89-
for _, byte := range b {
90-
if byte != 0 {
91-
return false
92-
}
93-
}
94-
return true
95-
}

core/vm/contracts.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/consensys/gnark-crypto/ecc/bls12-381/fp"
3131
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
3232
"github.com/ethereum/go-ethereum/common"
33+
"github.com/ethereum/go-ethereum/common/bitutil"
3334
"github.com/ethereum/go-ethereum/core/tracing"
3435
"github.com/ethereum/go-ethereum/crypto"
3536
"github.com/ethereum/go-ethereum/crypto/blake2b"
@@ -289,7 +290,7 @@ func (c *ecrecover) Run(input []byte) ([]byte, error) {
289290
v := input[63] - 27
290291

291292
// tighter sig s values input homestead only apply to tx sigs
292-
if !allZero(input[32:63]) || !crypto.ValidateSignatureValues(v, r, s, false) {
293+
if bitutil.TestBytes(input[32:63]) || !crypto.ValidateSignatureValues(v, r, s, false) {
293294
return nil, nil
294295
}
295296
// We must make sure not to modify the 'input', so placing the 'v' along with

0 commit comments

Comments
 (0)