-
Notifications
You must be signed in to change notification settings - Fork 149
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
Use FastCryptoError for batched verification #243
Conversation
The changes to BLS12381 seem very large, but it's a result of cargo fmt changing the indention after I removed a long string. It might be related to this. But I've only changed the error type in the two methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree w the PR's goal. Some small comments re meaningful error returns.
if sigs.is_empty() { | ||
return Err(eyre!("Critical Error! This behaviour can signal something dangerous, and that someone may be trying to bypass signature verification through providing empty batches.")); | ||
return Err(FastCryptoError::InvalidInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd create a new Error type for empty invalid Inputs (or better instantiate this error with a message)
@@ -160,7 +155,7 @@ impl VerifyingKey for Ed25519PublicKey { | |||
} | |||
batch | |||
.verify(OsRng) | |||
.map_err(|_| eyre!("Signature verification failed")) | |||
.map_err(|_| FastCryptoError::GeneralError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GeneralError is very broad, let's create SigVerificationError or GeneralError should be instantiated with a message)
if sigs.is_empty() { | ||
return Err(eyre!("Critical Error! This behaviour can signal something dangerous, and that someone may be trying to bypass signature verification through providing empty batches.")); | ||
return Err(FastCryptoError::InvalidInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
if pks.len() != sigs.len() { | ||
return Err(eyre!("Mismatch between number of signatures and public keys provided")); | ||
return Err(FastCryptoError::InvalidInput); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
} | ||
pks.iter() | ||
.zip(sigs) | ||
.try_for_each(|(pk, sig)| pk.verify(msg, sig)) | ||
.map_err(|_| eyre!("Signature verification failed")) | ||
.map_err(|_| FastCryptoError::GeneralError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
Great. I totally agree with your comments regarding the errors. But since it'll require a lot more changes than what I suggest here, I'll postpone it to until after PR #240 is merged where I'll clean up the error handling. I'll add an issue. |
No description provided.