From 85a2a9a9899da8cee66a7cd4442e08f6bad606f3 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 25 Mar 2024 19:16:21 +0300 Subject: [PATCH] *: improve error text for System.Crypto.CheckMultisig handling Signed-off-by: Anna Shaleva --- pkg/core/interop/crypto/ecdsa.go | 4 ++-- pkg/vm/stack.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/core/interop/crypto/ecdsa.go b/pkg/core/interop/crypto/ecdsa.go index 668bda363..c0f712bfd 100644 --- a/pkg/core/interop/crypto/ecdsa.go +++ b/pkg/core/interop/crypto/ecdsa.go @@ -18,14 +18,14 @@ import ( func ECDSASecp256r1CheckMultisig(ic *interop.Context) error { pkeys, err := ic.VM.Estack().PopSigElements() 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))) { return errors.New("gas limit exceeded") } sigs, err := ic.VM.Estack().PopSigElements() 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 // just mean that some keys didn't sign), but not the other way around. diff --git a/pkg/vm/stack.go b/pkg/vm/stack.go index bd83fba6a..e8f3463ee 100644 --- a/pkg/vm/stack.go +++ b/pkg/vm/stack.go @@ -345,7 +345,7 @@ func (s *Stack) PopSigElements() ([][]byte, error) { default: num = int(item.BigInt().Int64()) 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) for i := 0; i < num; i++ {