More idiomatic error handling
MODIFY
WalletWasabi/WabiSabi/Crypto/CredentialIssuer.cs
WalletWasabi/WabiSabi/Crypto/CredentialIssuer.cs
@@ -213,16 +213,20 @@ namespace WalletWasabi.WabiSabi.Crypto
var transcript = BuildTransnscript(registrationRequest.IsNullRequest);
- // Verify all statements.
+ bool areProofsValid = false;
+
try
{
- var areProofsValid = ProofSystem.Verify(transcript, statements, registrationRequest.Proofs);
+ // Verify all statements.
+ areProofsValid = ProofSystem.Verify(transcript, statements, registrationRequest.Proofs);
if (!areProofsValid)
{
throw new WabiSabiCryptoException(WabiSabiCryptoErrorCode.CoordinatorReceivedInvalidProofs);
}
}
- catch
+ finally
+ {
+ if (!areProofsValid)
{
// Request was invalid, but all serial numbers were unused.
// Ensure nullifier set can't be clogged with invalid serial
@@ -238,8 +242,7 @@ namespace WalletWasabi.WabiSabi.Crypto
SerialNumbers.Remove(serialNumber);
}
}
-
- throw;
+ }
}
// After this point serial numbers are committed irrevocably, even

More idiomatic error handling

Co-authored-by: Kiminuo <kiminuo@protonmail.com>