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

Should not have try-catch that swallow internal exceptions #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
36 changes: 8 additions & 28 deletions sr25519-dotnet.lib/SR25519.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,13 @@ public static byte[] Sign(byte[] message, SR25519Keypair keypair)
/// <param name="signature">The message signature.</param>
/// <param name="publicKey">The public (verification) key.</param>
/// <returns>True/False if the verification passed or failed.</returns>
public static bool Verify(string message, byte[] signature,
public static bool Verify(string message, byte[] signature,
byte[] publicKey)
{
bool result;
try
{
var bytes = Encoding.UTF8.GetBytes(message);
result = Bindings.Verify(
signature, bytes, Convert.ToUInt64(bytes.Length),
publicKey);
}
catch (Exception)
{
return false;
}

return result;
var bytes = Encoding.UTF8.GetBytes(message);
return Bindings.Verify(
signature, bytes, Convert.ToUInt64(bytes.Length),
publicKey);
}

/// <summary>
Expand All @@ -179,19 +169,9 @@ public static bool Verify(string message, byte[] signature,
public static bool Verify(byte[] message, byte[] signature,
byte[] publicKey)
{
bool result;
try
{
result = Bindings.Verify(
signature, message, Convert.ToUInt64(message.Length),
publicKey);
}
catch (Exception)
{
return false;
}

return result;
return Bindings.Verify(
signature, message, Convert.ToUInt64(message.Length),
publicKey);
}
}
}