feat: allow at most 4 inputs for Bn256Pairing precompile (#581)

* feat: allow at most 4 inputs for `Bn256Pairing` precompile

* mv core/vm/testdata/precompiles/bn256Pairing.json core/vm/testdata/precompiles/fail-bn256Pairing.json
This commit is contained in:
HAOYUatHZ 2023-11-24 13:50:53 +08:00 committed by GitHub
parent 563e36e542
commit 17bd8b2815
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -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