diff --git a/Cargo.lock b/Cargo.lock index 8bc526a09b..bcbab646e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -830,12 +830,14 @@ dependencies = [ [[package]] name = "blst" -version = "0.2.0" -source = "git+https://github.com/sigp/blst.git?rev=7cf47864627ca479cad06c2a164f30d0cbaf16ce#7cf47864627ca479cad06c2a164f30d0cbaf16ce" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbf4f6a3ffa04c41ed616749b40dd83431b69db520a18cb60f09db2b7a77c57" dependencies = [ "cc", "glob", "threadpool", + "zeroize", ] [[package]] diff --git a/crypto/bls/Cargo.toml b/crypto/bls/Cargo.toml index 06fe5dd9d3..ce211f893a 100644 --- a/crypto/bls/Cargo.toml +++ b/crypto/bls/Cargo.toml @@ -17,7 +17,7 @@ eth2_hashing = "0.1.0" ethereum-types = "0.9.2" arbitrary = { version = "0.4.6", features = ["derive"], optional = true } zeroize = { version = "1.1.1", features = ["zeroize_derive"] } -blst = { git = "https://github.com/sigp/blst.git", rev = "7cf47864627ca479cad06c2a164f30d0cbaf16ce" } +blst = "0.3.1" [features] default = ["supranational"] diff --git a/crypto/bls/src/impls/blst.rs b/crypto/bls/src/impls/blst.rs index b71fcbc637..70b7c90edf 100644 --- a/crypto/bls/src/impls/blst.rs +++ b/crypto/bls/src/impls/blst.rs @@ -98,13 +98,21 @@ pub fn verify_signature_sets<'a>( .collect::>(); // Aggregate all the public keys. - pks.push(blst_core::AggregatePublicKey::aggregate(&signing_keys).to_public_key()); + // Public keys have already been checked for subgroup and infinity + let agg_pk = match blst_core::AggregatePublicKey::aggregate(&signing_keys, false) { + Ok(agg_pk) => agg_pk, + Err(_) => return false, + }; + pks.push(agg_pk.to_public_key()); } let (sig_refs, pks_refs): (Vec<_>, Vec<_>) = sigs.iter().zip(pks.iter()).unzip(); + // Public keys have already been checked for subgroup and infinity + // Signatures have already been checked for subgroup + // Signature checks above could be done here for convienence as well let err = blst_core::Signature::verify_multiple_aggregate_signatures( - &msgs_refs, DST, &pks_refs, &sig_refs, &rands, RAND_BITS, + &msgs_refs, DST, &pks_refs, false, &sig_refs, false, &rands, RAND_BITS, ); err == blst::BLST_ERROR::BLST_SUCCESS @@ -157,10 +165,9 @@ impl TSignature for blst_core::Signature { } fn verify(&self, pubkey: &blst_core::PublicKey, msg: Hash256) -> bool { - if !self.subgroup_check() { - return false; - } - self.verify(msg.as_bytes(), DST, &[], pubkey) == BLST_ERROR::BLST_SUCCESS + // Public keys have already been checked for subgroup and infinity + // Check Signature inside function for subgroup + self.verify(true, msg.as_bytes(), DST, &[], pubkey, false) == BLST_ERROR::BLST_SUCCESS } } @@ -192,7 +199,8 @@ impl TAggregateSignature bool { let pubkeys = pubkeys.iter().map(|pk| pk.point()).collect::>(); let signature = self.0.clone().to_signature(); - if !signature.subgroup_check() { - return false; - } - signature.fast_aggregate_verify(msg.as_bytes(), DST, &pubkeys) == BLST_ERROR::BLST_SUCCESS + // Public keys are already valid due to PoP + // Check Signature inside function for subgroup + signature.fast_aggregate_verify(true, msg.as_bytes(), DST, &pubkeys) + == BLST_ERROR::BLST_SUCCESS } fn aggregate_verify( @@ -231,10 +239,9 @@ impl TAggregateSignature>(); let msgs = msgs.iter().map(|hash| hash.as_bytes()).collect::>(); let signature = self.0.clone().to_signature(); - if !signature.subgroup_check() { - return false; - } - signature.aggregate_verify(&msgs, DST, &pubkeys) == BLST_ERROR::BLST_SUCCESS + // Public keys have already been checked for subgroup and infinity + // Check Signature inside function for subgroup + signature.aggregate_verify(true, &msgs, DST, &pubkeys, false) == BLST_ERROR::BLST_SUCCESS } }