From 75a9e0f3de1b6e409762e299b7f316270f7d3ad0 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 11 Feb 2019 17:24:32 +1100 Subject: [PATCH] Add `verify_signature()` to `Attestation` --- eth2/types/src/attestation.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/eth2/types/src/attestation.rs b/eth2/types/src/attestation.rs index 7938ae6574..afffc2e2fd 100644 --- a/eth2/types/src/attestation.rs +++ b/eth2/types/src/attestation.rs @@ -1,6 +1,6 @@ -use super::{AttestationData, Bitfield, Hash256}; +use super::{AggregatePublicKey, AggregateSignature, AttestationData, Bitfield, Hash256}; use crate::test_utils::TestRandom; -use bls::AggregateSignature; +use bls::bls_verify_aggregate; use rand::RngCore; use serde_derive::Serialize; use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash}; @@ -21,6 +21,17 @@ impl Attestation { pub fn signable_message(&self, custody_bit: bool) -> Vec { self.data.signable_message(custody_bit) } + + pub fn verify_signature( + &self, + group_public_key: &AggregatePublicKey, + custody_bit: bool, + // TODO: use domain. + _domain: u64, + ) -> bool { + self.aggregate_signature + .verify(&self.signable_message(custody_bit), group_public_key) + } } impl Encodable for Attestation {