Skip to content

Commit

Permalink
Merge pull request #883 from multiversx/crypto-ei-signature-hooks-errors
Browse files Browse the repository at this point in the history
errors for invalid signatures in crypto hooks
  • Loading branch information
sstanculeanu authored Sep 18, 2024
2 parents b32bde1 + 18af34a commit 3d48d5d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"expect": {
"out": [],
"status": "10",
"message": "str:err blsSignatureDeserialize 0032a2ddf341c08d1eb7232f05dc34e4454155e676b58c40fddf9a036562ac2c01533d2d557cb49d73aa9d7a89744696",
"message": "str:signature is invalid",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"expect": {
"out": [],
"status": "10",
"message": "str:err blsSignatureDeserialize 0012858363e8caa5b398d3febdd7bc01bc2fae1fef8f486ff4d84a5f3342f2d38085904eb10b73c0879a45d23585ce8f",
"message": "str:signature is invalid",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"expect": {
"out": [],
"status": "10",
"message": "str:err blsSignatureDeserialize ff725db195e37aa237cdbbda76270d4a229b6e7a3651104dc58c4349c0388e8546976fe54a04240530b99064e434c90f",
"message": "str:signature is invalid",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"expect": {
"out": [],
"status": "10",
"message": "str:signature verification failed",
"message": "str:signature is invalid",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
3 changes: 3 additions & 0 deletions vmhost/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,6 @@ var ErrNilMapOpcodeAddress = errors.New("nil map opcode address")

// ErrOpcodeIsNotAllowed signals that opcode is not allowed for the address
var ErrOpcodeIsNotAllowed = errors.New("opcode is not allowed")

// ErrInvalidSignature signals that a signature verification failed
var ErrInvalidSignature = errors.New("signature is invalid")
5 changes: 3 additions & 2 deletions vmhost/vmhooks/cryptoei.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vmhooks

import (
"crypto/elliptic"

"github.com/multiversx/mx-chain-vm-go/crypto/signing/secp256"
"github.com/multiversx/mx-chain-vm-go/executor"
"github.com/multiversx/mx-chain-vm-go/math"
Expand Down Expand Up @@ -401,7 +402,7 @@ func ManagedVerifyBLSWithHost(
}

if invalidSigErr != nil {
WithFaultAndHost(host, invalidSigErr, runtime.CryptoAPIErrorShouldFailExecution())
WithFaultAndHost(host, vmhost.ErrInvalidSignature, runtime.CryptoAPIErrorShouldFailExecution())
return -1
}

Expand Down Expand Up @@ -659,7 +660,7 @@ func ManagedVerifyCustomSecp256k1WithHost(
}

if invalidSigErr != nil {
WithFaultAndHost(host, invalidSigErr, runtime.CryptoAPIErrorShouldFailExecution())
WithFaultAndHost(host, vmhost.ErrInvalidSignature, runtime.CryptoAPIErrorShouldFailExecution())
return -1
}

Expand Down

0 comments on commit 3d48d5d

Please sign in to comment.