forked from sigp/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to v1.1.0-beta.4 (squash of sigp#2548)
- Loading branch information
1 parent
56082be
commit 1ec13cb
Showing
22 changed files
with
231 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
testing/ef_tests/eth2.0-spec-tests | ||
testing/ef_tests/consensus-spec-tests | ||
target/ | ||
*.data | ||
*.tar.gz |
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
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,2 @@ | ||
/eth2.0-spec-tests | ||
/consensus-spec-tests | ||
.accessed_file_log.txt |
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
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,48 @@ | ||
use super::*; | ||
use crate::case_result::compare_result; | ||
use crate::cases::common::BlsCase; | ||
use bls::{AggregatePublicKey, PublicKeyBytes}; | ||
use serde_derive::Deserialize; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct BlsEthAggregatePubkeys { | ||
pub input: Vec<PublicKeyBytes>, | ||
pub output: Option<PublicKeyBytes>, | ||
} | ||
|
||
impl BlsCase for BlsEthAggregatePubkeys {} | ||
|
||
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) | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
testing/ef_tests/src/cases/bls_eth_fast_aggregate_verify.rs
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,61 @@ | ||
use super::*; | ||
use crate::case_result::compare_result; | ||
use crate::cases::common::BlsCase; | ||
use bls::{AggregateSignature, PublicKeyBytes}; | ||
use serde_derive::Deserialize; | ||
use std::convert::TryInto; | ||
use types::Hash256; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct BlsEthFastAggregateVerifyInput { | ||
pub pubkeys: Vec<PublicKeyBytes>, | ||
#[serde(alias = "messages")] | ||
pub message: String, | ||
pub signature: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct BlsEthFastAggregateVerify { | ||
pub input: BlsEthFastAggregateVerifyInput, | ||
pub output: bool, | ||
} | ||
|
||
impl BlsCase for BlsEthFastAggregateVerify {} | ||
|
||
impl Case for BlsEthFastAggregateVerify { | ||
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 message = Hash256::from_slice( | ||
&hex::decode(&self.input.message[2..]) | ||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?, | ||
); | ||
|
||
let pubkeys_result = self | ||
.input | ||
.pubkeys | ||
.iter() | ||
.map(|pkb| pkb.try_into()) | ||
.collect::<Result<Vec<_>, _>>(); | ||
|
||
let pubkeys = match pubkeys_result { | ||
Ok(pubkeys) => pubkeys, | ||
Err(bls::Error::InvalidInfinityPublicKey) if !self.output => { | ||
return Ok(()); | ||
} | ||
Err(e) => return Err(Error::FailedToParseTest(format!("{:?}", e))), | ||
}; | ||
|
||
let pubkey_refs = pubkeys.iter().collect::<Vec<_>>(); | ||
|
||
let signature_ok = hex::decode(&self.input.signature[2..]) | ||
.ok() | ||
.and_then(|bytes: Vec<u8>| AggregateSignature::deserialize(&bytes).ok()) | ||
.map(|signature| signature.eth_fast_aggregate_verify(message, &pubkey_refs)) | ||
.unwrap_or(false); | ||
|
||
compare_result::<bool, ()>(&Ok(signature_ok), &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
Oops, something went wrong.