Files
lighthouse/tests/ef_tests/src/cases/bls_aggregate_verify.rs
Michael Sproul 371e5adcf8 Update to Spec v0.10 (#817)
* Start updating types

* WIP

* Signature hacking

* Existing EF tests passing with fake_crypto

* Updates

* Delete outdated API spec

* The refactor continues

* It compiles

* WIP test fixes

* All release tests passing bar genesis state parsing

* Update and test YamlConfig

* Update to spec v0.10 compatible BLS

* Updates to BLS EF tests

* Add EF test for AggregateVerify

And delete unused hash2curve tests for uncompressed points

* Update EF tests to v0.10.1

* Use optional block root correctly in block proc

* Use genesis fork in deposit domain. All tests pass

* Cargo fmt

* Fast aggregate verify test

* Update REST API docs

* Cargo fmt

* Fix unused import

* Bump spec tags to v0.10.1

* Add `seconds_per_eth1_block` to chainspec

* Update to timestamp based eth1 voting scheme

* Return None from `get_votes_to_consider` if block cache is empty

* Handle overflows in `is_candidate_block`

* Revert to failing tests

* Fix eth1 data sets test

* Choose default vote according to spec

* Fix collect_valid_votes tests

* Fix `get_votes_to_consider` to choose all eligible blocks

* Uncomment winning_vote tests

* Add comments; remove unused code

* Reduce seconds_per_eth1_block for simulation

* Addressed review comments

* Add test for default vote case

* Fix logs

* Remove unused functions

* Meter default eth1 votes

* Fix comments

* Address review comments; remove unused dependency

* Disable/delete two outdated tests

* Bump eth1 default vote warn to error

* Delete outdated eth1 test

Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
2020-02-11 10:19:36 +11:00

60 lines
1.6 KiB
Rust

use super::*;
use crate::case_result::compare_result;
use crate::cases::common::BlsCase;
use bls::{AggregatePublicKey, AggregateSignature};
use serde_derive::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct BlsAggregatePair {
pub pubkey: AggregatePublicKey,
pub message: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BlsAggregateVerifyInput {
pub pairs: Vec<BlsAggregatePair>,
pub signature: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BlsAggregateVerify {
pub input: BlsAggregateVerifyInput,
pub output: bool,
}
impl BlsCase for BlsAggregateVerify {}
impl Case for BlsAggregateVerify {
fn result(&self, _case_index: usize) -> Result<(), Error> {
let messages = self
.input
.pairs
.iter()
.map(|pair| {
hex::decode(&pair.message[2..])
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
})
.collect::<Result<Vec<Vec<_>>, _>>()?;
let message_refs = messages
.iter()
.map(|x| x.as_slice())
.collect::<Vec<&[u8]>>();
let pubkey_refs = self
.input
.pairs
.iter()
.map(|p| &p.pubkey)
.collect::<Vec<_>>();
let signature_ok = hex::decode(&self.input.signature[2..])
.ok()
.and_then(|bytes: Vec<u8>| AggregateSignature::from_bytes(&bytes).ok())
.map(|signature| signature.verify_multiple(&message_refs, &pubkey_refs))
.unwrap_or(false);
compare_result::<bool, ()>(&Ok(signature_ok), &Some(self.output))
}
}