-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Issue Addressed Which issue # does this PR address? #2629 ## Proposed Changes Please list or describe the changes introduced by this PR. 1. ci would dowload the bls test cases from https://github.com/ethereum/bls12-381-tests/ 2. all the bls test cases(except eth ones) would use cases in the archive from step one 3. The bls test cases from https://github.com/ethereum/consensus-spec-tests would stay there and no use . For the future , these bls test cases would be remove suggested from ethereum/consensus-spec-tests#25 . So it would do no harm and compatible for future cases. ## Additional Info Please provide any additional information. For example, future considerations or information useful for reviewers. Question: I am not sure if I should implement tests about `deserialization_G1`, `deserialization_G2` and `hash_to_G2` for the issue.
- Loading branch information
Showing
16 changed files
with
210 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/consensus-spec-tests | ||
.accessed_file_log.txt | ||
/bls12-381-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use super::*; | ||
use crate::case_result::compare_result; | ||
use crate::impl_bls_load_case; | ||
use bls::{verify_signature_sets, BlsWrappedSignature, PublicKeyBytes, Signature, SignatureSet}; | ||
use serde_derive::Deserialize; | ||
use std::borrow::Cow; | ||
use std::str::FromStr; | ||
use types::Hash256; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct BlsBatchVerifyInput { | ||
pubkeys: Vec<PublicKeyBytes>, | ||
messages: Vec<String>, | ||
signatures: Vec<String>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct BlsBatchVerify { | ||
pub input: BlsBatchVerifyInput, | ||
pub output: bool, | ||
} | ||
|
||
impl_bls_load_case!(BlsBatchVerify); | ||
|
||
impl Case for BlsBatchVerify { | ||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> { | ||
let messages = self | ||
.input | ||
.messages | ||
.iter() | ||
.map(|s| Hash256::from_str(s).map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))) | ||
.collect::<Result<Vec<_>, _>>()?; | ||
|
||
let pubkeys = self | ||
.input | ||
.pubkeys | ||
.iter() | ||
.map(|pkb| { | ||
pkb.decompress() | ||
.map_err(|_| Error::FailedToParseTest("pubkeys parse error".to_string())) | ||
}) | ||
.collect::<Result<Vec<_>, _>>()?; | ||
|
||
let signatures = self | ||
.input | ||
.signatures | ||
.iter() | ||
.map(|s| { | ||
Signature::from_str(s).map_err(|e| Error::FailedToParseTest(format!("{:?}", e))) | ||
}) | ||
.collect::<Result<Vec<_>, _>>()?; | ||
|
||
let signature_set = messages | ||
.iter() | ||
.zip(pubkeys.iter()) | ||
.zip(signatures.iter()) | ||
.map(|((&message, pubkey), signature)| { | ||
let wraped_signature = BlsWrappedSignature::from(signature); | ||
SignatureSet::single_pubkey(wraped_signature, Cow::Borrowed(pubkey), message) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
let signature_valid = verify_signature_sets(signature_set.iter()); | ||
|
||
compare_result::<bool, ()>(&Ok(signature_valid), &Some(self.output)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.