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
Closed
Show file tree
Hide file tree
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
12 changes: 5 additions & 7 deletions fastcrypto/src/bls12377.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ use ark_ff::{
One, Zero,
};
use celo_bls::{hash_to_curve::try_and_increment, HashToCurve, PublicKey};
use eyre::eyre;
use once_cell::sync::OnceCell;
use serde::{de, Deserialize, Serialize};
use serde_with::serde_as;
use signature::{Signer, Verifier};

use crate::error::FastCryptoError;
use crate::traits::{Authenticator, KeyPair, SigningKey, VerifyingKey};
use serde_with::{DeserializeAs, SerializeAs};
use zeroize::Zeroize;
Expand Down Expand Up @@ -362,14 +362,12 @@ impl VerifyingKey for BLS12377PublicKey {
msg: &[u8],
pks: &[Self],
sigs: &[Self::Sig],
) -> Result<(), eyre::Report> {
) -> Result<(), FastCryptoError> {
if sigs.is_empty() {
return Err(eyre!("Critical Error! This behavious can signal something dangerous, and that someone may be trying to bypass signature verification through providing empty batches."));
return Err(FastCryptoError::InvalidInput);
}
if sigs.len() != pks.len() {
return Err(eyre!(
"Mismatch between number of signatures and public keys provided"
));
return Err(FastCryptoError::InvalidInput);
}
let mut batch = celo_bls::bls::Batch::new(msg, &[]);
pks.iter()
Expand All @@ -378,7 +376,7 @@ impl VerifyingKey for BLS12377PublicKey {
let hash_to_g1 = &*try_and_increment::COMPOSITE_HASH_TO_G1;
batch
.verify(hash_to_g1)
.map_err(|_| eyre!("Signature verification failed"))
.map_err(|_| FastCryptoError::GeneralError)
}
}

Expand Down
Loading