mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
## 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 https://github.com/ethereum/consensus-spec-tests/issues/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.
42 lines
1.5 KiB
Rust
42 lines
1.5 KiB
Rust
use super::*;
|
|
use crate::case_result::compare_result;
|
|
use crate::impl_bls_load_case;
|
|
use bls::{AggregateSignature, Signature};
|
|
use serde_derive::Deserialize;
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct BlsAggregateSigs {
|
|
pub input: Vec<String>,
|
|
pub output: String,
|
|
}
|
|
|
|
impl_bls_load_case!(BlsAggregateSigs);
|
|
|
|
impl Case for BlsAggregateSigs {
|
|
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
|
let mut aggregate_signature = AggregateSignature::infinity();
|
|
|
|
for key_str in &self.input {
|
|
let sig = hex::decode(&key_str[2..])
|
|
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
|
let sig = Signature::deserialize(&sig)
|
|
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
|
|
|
aggregate_signature.add_assign(&sig);
|
|
}
|
|
|
|
// Check for YAML null value, indicating invalid input. This is a bit of a hack,
|
|
// as our mutating `aggregate_signature.add` API doesn't play nicely with aggregating 0
|
|
// inputs.
|
|
let output_bytes = if self.output == "~" {
|
|
AggregateSignature::infinity().serialize().to_vec()
|
|
} else {
|
|
hex::decode(&self.output[2..])
|
|
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?
|
|
};
|
|
let aggregate_signature = Ok(aggregate_signature.serialize().to_vec());
|
|
|
|
compare_result::<Vec<u8>, Vec<u8>>(&aggregate_signature, &Some(output_bytes))
|
|
}
|
|
}
|