mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +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.
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
use super::*;
|
|
use crate::case_result::compare_result;
|
|
use crate::impl_bls_load_case;
|
|
use bls::{AggregatePublicKey, PublicKeyBytes};
|
|
use serde_derive::Deserialize;
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct BlsEthAggregatePubkeys {
|
|
pub input: Vec<PublicKeyBytes>,
|
|
pub output: Option<PublicKeyBytes>,
|
|
}
|
|
|
|
impl_bls_load_case!(BlsEthAggregatePubkeys, "data.yaml");
|
|
|
|
impl Case for BlsEthAggregatePubkeys {
|
|
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
|
|
fork_name == ForkName::Altair
|
|
}
|
|
|
|
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
|
let pubkeys_result = self
|
|
.input
|
|
.iter()
|
|
.map(|pkb| pkb.decompress())
|
|
.collect::<Result<Vec<_>, _>>();
|
|
|
|
let pubkeys = match pubkeys_result {
|
|
Ok(pubkeys) => pubkeys,
|
|
Err(bls::Error::InvalidInfinityPublicKey | bls::Error::BlstError(_))
|
|
if self.output.is_none() =>
|
|
{
|
|
return Ok(());
|
|
}
|
|
#[cfg(feature = "milagro")]
|
|
Err(bls::Error::MilagroError(_)) if self.output.is_none() => {
|
|
return Ok(());
|
|
}
|
|
Err(e) => return Err(Error::FailedToParseTest(format!("{:?}", e))),
|
|
};
|
|
|
|
let aggregate_pubkey =
|
|
AggregatePublicKey::aggregate(&pubkeys).map(|agg| agg.to_public_key());
|
|
|
|
let expected = self.output.as_ref().map(|pk| pk.decompress().unwrap());
|
|
|
|
compare_result::<_, bls::Error>(&aggregate_pubkey, &expected)
|
|
}
|
|
}
|