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

Use FastCryptoError for batched verification #243

Closed
wants to merge 3 commits into from

Conversation

jonas-lj
Copy link
Contributor

No description provided.

@jonas-lj
Copy link
Contributor Author

jonas-lj commented Nov 22, 2022

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.

@jonas-lj jonas-lj marked this pull request as ready for review November 22, 2022 13:46
Copy link
Collaborator

@kchalkias kchalkias left a 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);
Copy link
Collaborator

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)
Copy link
Collaborator

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);
Copy link
Collaborator

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);
}
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@jonas-lj
Copy link
Contributor Author

Totally agree w the PR's goal. Some small comments re meaningful error returns.

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.

@jonas-lj jonas-lj closed this Nov 22, 2022
@jonas-lj jonas-lj mentioned this pull request Nov 22, 2022
@jonas-lj jonas-lj deleted the use_fastcrypto_error branch December 12, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants