mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Directory Restructure (#1163)
* Move tests -> testing * Directory restructure * Update Cargo.toml during restructure * Update Makefile during restructure * Fix arbitrary path
This commit is contained in:
35
testing/ef_tests/src/cases/bls_verify_msg.rs
Normal file
35
testing/ef_tests/src/cases/bls_verify_msg.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_result;
|
||||
use crate::cases::common::BlsCase;
|
||||
use bls::{PublicKey, Signature, SignatureBytes};
|
||||
use serde_derive::Deserialize;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct BlsVerifyInput {
|
||||
pub pubkey: PublicKey,
|
||||
pub message: String,
|
||||
pub signature: SignatureBytes,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct BlsVerify {
|
||||
pub input: BlsVerifyInput,
|
||||
pub output: bool,
|
||||
}
|
||||
|
||||
impl BlsCase for BlsVerify {}
|
||||
|
||||
impl Case for BlsVerify {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let message = hex::decode(&self.input.message[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||
|
||||
let signature_ok = (&self.input.signature)
|
||||
.try_into()
|
||||
.map(|signature: Signature| signature.verify(&message, &self.input.pubkey))
|
||||
.unwrap_or(false);
|
||||
|
||||
compare_result::<bool, ()>(&Ok(signature_ok), &Some(self.output))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user