core/vm: force the input length of p256verify

pull/27540/head
Ulaş Erdoğan 1 year ago
parent 1be1875156
commit 21f4932c9b
  1. 10
      core/vm/contracts.go

@ -1152,13 +1152,15 @@ func (c *p256Verify) RequiredGas(input []byte) uint64 {
return params.P256VerifyGas return params.P256VerifyGas
} }
// Run executes the precompiled contract, returning the output and the used gas // Run executes the precompiled contract with given 160 bytes of param, returning the output and the used gas
func (c *p256Verify) Run(input []byte) ([]byte, error) { func (c *p256Verify) Run(input []byte) ([]byte, error) {
// Required input length is 160 bytes // Required input length is 160 bytes
const p256VerifyInputLength = 160 const p256VerifyInputLength = 160
// Check the input length
// "input" is (hash, r, s, x, y), each 32 bytes if len(input) != p256VerifyInputLength {
input = common.RightPadBytes(input, p256VerifyInputLength) // Input length is invalid
return nil, nil
}
// Extract the hash, r, s, x, y from the input // Extract the hash, r, s, x, y from the input
hash := input[0:32] hash := input[0:32]

Loading…
Cancel
Save