*: improve error text for System.Crypto.CheckMultisig handling

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2024-03-25 19:16:21 +03:00
parent 37d7a3a2d5
commit 85a2a9a989
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++ {