From 1ee5e82ef016cbc4212d467fb0c1fc8f871629bc Mon Sep 17 00:00:00 2001 From: 1garo Date: Wed, 1 Dec 2021 10:32:41 -0300 Subject: [PATCH] fix error validation on ed25519 --- lib/crypto/ed25519/ed25519.go | 6 ++---- lib/crypto/ed25519/ed25519_test.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/crypto/ed25519/ed25519.go b/lib/crypto/ed25519/ed25519.go index 0ae2fdc5d2..28ab6c34d2 100644 --- a/lib/crypto/ed25519/ed25519.go +++ b/lib/crypto/ed25519/ed25519.go @@ -53,10 +53,8 @@ func VerifySignature(publicKey, signature, message []byte) error { ok, err := pubKey.Verify(message, signature) if err != nil { - return fmt.Errorf("ed25519: %w: %s", crypto.ErrSignatureVerificationFailed, err) - } - - if !ok { + return fmt.Errorf("ed25519: %w", err) + } else if !ok { return fmt.Errorf("ed25519: %w: for message 0x%x, signature 0x%x and public key 0x%x", crypto.ErrSignatureVerificationFailed, message, signature, publicKey) } diff --git a/lib/crypto/ed25519/ed25519_test.go b/lib/crypto/ed25519/ed25519_test.go index bc29284719..481929216a 100644 --- a/lib/crypto/ed25519/ed25519_test.go +++ b/lib/crypto/ed25519/ed25519_test.go @@ -131,7 +131,7 @@ func TestVerifySignature(t *testing.T) { publicKey: keypair.public.Encode(), signature: []byte{}, message: message, - err: fmt.Errorf("ed25519: %w: invalid signature length", crypto.ErrSignatureVerificationFailed), + err: fmt.Errorf("ed25519: invalid signature length"), }, "verification failed": { publicKey: keypair.public.Encode(),