Skip to content

Commit

Permalink
feat: allow at most 4 inputs for Bn256Pairing precompile (#581)
Browse files Browse the repository at this point in the history
* feat: allow at most 4 inputs for `Bn256Pairing` precompile

* mv core/vm/testdata/precompiles/bn256Pairing.json core/vm/testdata/precompiles/fail-bn256Pairing.json
  • Loading branch information
0xmountaintop authored Nov 24, 2023
1 parent 563e36e commit 17bd8b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ var (
// runBn256Pairing implements the Bn256Pairing precompile, referenced by both
// Byzantium and Istanbul operations.
func runBn256Pairing(input []byte) ([]byte, error) {
// Allow at most 4 inputs
if len(input) > 4*192 {
return nil, errBadPairingInput
}
// Handle some corner cases cheaply
if len(input)%192 > 0 {
return nil, errBadPairingInput
Expand Down

0 comments on commit 17bd8b2

Please sign in to comment.