Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors for invalid signatures in crypto hooks #883

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading