Merge pull request #3374 from nspcc-dev/improve-err

*: improve error text for System.Crypto.CheckMultisig handling
This commit is contained in:
Roman Khimov 2024-03-25 19:20:35 +03:00 committed by GitHub
commit f8ca51db93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -18,14 +18,14 @@ import (
func ECDSASecp256r1CheckMultisig(ic *interop.Context) error { func ECDSASecp256r1CheckMultisig(ic *interop.Context) error {
pkeys, err := ic.VM.Estack().PopSigElements() pkeys, err := ic.VM.Estack().PopSigElements()
if err != nil { if err != nil {
return fmt.Errorf("wrong parameters: %w", err) return fmt.Errorf("wrong key parameters: %w", err)
} }
if !ic.VM.AddGas(ic.BaseExecFee() * fee.ECDSAVerifyPrice * int64(len(pkeys))) { if !ic.VM.AddGas(ic.BaseExecFee() * fee.ECDSAVerifyPrice * int64(len(pkeys))) {
return errors.New("gas limit exceeded") return errors.New("gas limit exceeded")
} }
sigs, err := ic.VM.Estack().PopSigElements() sigs, err := ic.VM.Estack().PopSigElements()
if err != nil { if err != nil {
return fmt.Errorf("wrong parameters: %w", err) return fmt.Errorf("wrong signature parameters: %w", err)
} }
// It's ok to have more keys than there are signatures (it would // It's ok to have more keys than there are signatures (it would
// just mean that some keys didn't sign), but not the other way around. // just mean that some keys didn't sign), but not the other way around.

View file

@ -345,7 +345,7 @@ func (s *Stack) PopSigElements() ([][]byte, error) {
default: default:
num = int(item.BigInt().Int64()) num = int(item.BigInt().Int64())
if num < 1 || num > s.Len() { if num < 1 || num > s.Len() {
return nil, fmt.Errorf("wrong number of elements: %d", num) return nil, fmt.Errorf("wrong number of elements: need %d, have %d", num, s.Len())
} }
elems = make([][]byte, num) elems = make([][]byte, num)
for i := 0; i < num; i++ { for i := 0; i < num; i++ {