Skip to content

Commit 3d48d5d

Browse files
authored
Merge pull request #883 from multiversx/crypto-ei-signature-hooks-errors
errors for invalid signatures in crypto hooks
2 parents b32bde1 + 18af34a commit 3d48d5d

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

test/features/basic-features/scenarios/crypto_verify_bls.scen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"expect": {
5959
"out": [],
6060
"status": "10",
61-
"message": "str:err blsSignatureDeserialize 0032a2ddf341c08d1eb7232f05dc34e4454155e676b58c40fddf9a036562ac2c01533d2d557cb49d73aa9d7a89744696",
61+
"message": "str:signature is invalid",
6262
"logs": "*",
6363
"gas": "*",
6464
"refund": "*"

test/features/basic-features/scenarios/crypto_verify_bls_aggregated_signature.scen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"expect": {
7171
"out": [],
7272
"status": "10",
73-
"message": "str:err blsSignatureDeserialize 0012858363e8caa5b398d3febdd7bc01bc2fae1fef8f486ff4d84a5f3342f2d38085904eb10b73c0879a45d23585ce8f",
73+
"message": "str:signature is invalid",
7474
"logs": "*",
7575
"gas": "*",
7676
"refund": "*"

test/features/basic-features/scenarios/crypto_verify_bls_share.scen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"expect": {
5959
"out": [],
6060
"status": "10",
61-
"message": "str:err blsSignatureDeserialize ff725db195e37aa237cdbbda76270d4a229b6e7a3651104dc58c4349c0388e8546976fe54a04240530b99064e434c90f",
61+
"message": "str:signature is invalid",
6262
"logs": "*",
6363
"gas": "*",
6464
"refund": "*"

test/features/basic-features/scenarios/crypto_verify_secp256r1.scen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"expect": {
5858
"out": [],
5959
"status": "10",
60-
"message": "str:signature verification failed",
60+
"message": "str:signature is invalid",
6161
"logs": "*",
6262
"gas": "*",
6363
"refund": "*"

vmhost/errors.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,6 @@ var ErrNilMapOpcodeAddress = errors.New("nil map opcode address")
301301

302302
// ErrOpcodeIsNotAllowed signals that opcode is not allowed for the address
303303
var ErrOpcodeIsNotAllowed = errors.New("opcode is not allowed")
304+
305+
// ErrInvalidSignature signals that a signature verification failed
306+
var ErrInvalidSignature = errors.New("signature is invalid")

vmhost/vmhooks/cryptoei.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package vmhooks
22

33
import (
44
"crypto/elliptic"
5+
56
"github.com/multiversx/mx-chain-vm-go/crypto/signing/secp256"
67
"github.com/multiversx/mx-chain-vm-go/executor"
78
"github.com/multiversx/mx-chain-vm-go/math"
@@ -401,7 +402,7 @@ func ManagedVerifyBLSWithHost(
401402
}
402403

403404
if invalidSigErr != nil {
404-
WithFaultAndHost(host, invalidSigErr, runtime.CryptoAPIErrorShouldFailExecution())
405+
WithFaultAndHost(host, vmhost.ErrInvalidSignature, runtime.CryptoAPIErrorShouldFailExecution())
405406
return -1
406407
}
407408

@@ -659,7 +660,7 @@ func ManagedVerifyCustomSecp256k1WithHost(
659660
}
660661

661662
if invalidSigErr != nil {
662-
WithFaultAndHost(host, invalidSigErr, runtime.CryptoAPIErrorShouldFailExecution())
663+
WithFaultAndHost(host, vmhost.ErrInvalidSignature, runtime.CryptoAPIErrorShouldFailExecution())
663664
return -1
664665
}
665666

0 commit comments

Comments
 (0)