Skip to content

Commit

Permalink
core/vm: force the input length of p256verify
Browse files Browse the repository at this point in the history
(cherry picked from commit 21f4932c9bbb8664cf7b3e3c3602b6a48c747893)
  • Loading branch information
ulerdogan authored and anshalshukla committed Nov 3, 2023
1 parent d64d8e7 commit 2bbf30f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,13 +1124,15 @@ func (c *p256Verify) RequiredGas(input []byte) uint64 {
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) {
// Required input length is 160 bytes
const p256VerifyInputLength = 160

// "input" is (hash, r, s, x, y), each 32 bytes
input = common.RightPadBytes(input, p256VerifyInputLength)
// Check the input length
if len(input) != p256VerifyInputLength {
// Input length is invalid
return nil, nil
}

// Extract the hash, r, s, x, y from the input
hash := input[0:32]
Expand Down

0 comments on commit 2bbf30f

Please sign in to comment.