Add signable_message() to Attestation

This commit is contained in:
Paul Hauner 2019-01-27 17:27:53 +11:00
parent 2bda7e3d14
commit b487db68a1
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
3 changed files with 15 additions and 8 deletions

View File

@ -265,18 +265,11 @@ where
.as_raw(),
)
}
let attestation_message = {
let attestation_data_and_custody_bit = AttestationDataAndCustodyBit {
data: attestation.data.clone(),
custody_bit: false,
};
&attestation_data_and_custody_bit.hash_tree_root()
};
// Signature verification.
ensure!(
bls_verify_aggregate(
&group_public_key,
&attestation_message[..],
&attestation.signable_message(),
&attestation.aggregate_signature,
get_domain(&state.fork_data, attestation.data.slot, DOMAIN_ATTESTATION)
),

View File

@ -5,6 +5,8 @@ use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
mod signing;
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct Attestation {
pub data: AttestationData,

View File

@ -0,0 +1,12 @@
use crate::{Attestation, AttestationDataAndCustodyBit};
use ssz::TreeHash;
impl Attestation {
pub fn signable_message(&self) -> Vec<u8> {
let attestation_data_and_custody_bit = AttestationDataAndCustodyBit {
data: self.data.clone(),
custody_bit: false,
};
attestation_data_and_custody_bit.hash_tree_root()
}
}