From 24cd652e913949f6fe6ca43bdd9e7db9b7e66715 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 3 Jan 2020 19:46:36 +0100 Subject: [PATCH] Added details to exceptions --- Ed25519/Signer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ed25519/Signer.cs b/Ed25519/Signer.cs index 2bc16b4..a71af50 100644 --- a/Ed25519/Signer.cs +++ b/Ed25519/Signer.cs @@ -11,10 +11,10 @@ namespace Ed25519 public static ReadOnlySpan Sign(ReadOnlySpan message, ReadOnlySpan privateKey, ReadOnlySpan publicKey) { if(privateKey.Length == 0) - throw new ArgumentException("Private key length is wrong"); + throw new ArgumentException("Private key length is wrong. Key must not be empty."); if (publicKey.Length != Constants.BIT_LENGTH / 8) - throw new ArgumentException("Public key length is wrong"); + throw new ArgumentException($"Public key length is wrong. Got {publicKey.Length} instead of {Constants.BIT_LENGTH / 8}."); var privateKeyHash = privateKey.ComputeHash(); var privateKeyBits = Constants.TWO_POW_BIT_LENGTH_MINUS_TWO; @@ -62,10 +62,10 @@ namespace Ed25519 public static bool Validate(ReadOnlySpan signature, ReadOnlySpan message, ReadOnlySpan publicKey) { if (signature.Length != Constants.BIT_LENGTH / 4) - throw new ArgumentException("Signature length is wrong"); + throw new ArgumentException($"Signature length is wrong. Got {signature.Length} instead of {Constants.BIT_LENGTH / 4}."); if (publicKey.Length != Constants.BIT_LENGTH / 8) - throw new ArgumentException("Public key length is wrong"); + throw new ArgumentException($"Public key length is wrong. Got {publicKey.Length} instead of {Constants.BIT_LENGTH / 8}."); var signatureSliceLeft = signature[..(Constants.BIT_LENGTH / 8)]; var pointSignatureLeft = EdPoint.DecodePoint(signatureSliceLeft);