Skip to content

Commit

Permalink
fix error validation on ed25519
Browse files Browse the repository at this point in the history
  • Loading branch information
1garo committed Dec 1, 2021
1 parent f223d65 commit 1ee5e82
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/crypto/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto/ed25519/ed25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 1ee5e82

Please sign in to comment.