Add signable_message()
to Attestation
This commit is contained in:
parent
2bda7e3d14
commit
b487db68a1
@ -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)
|
||||
),
|
||||
|
@ -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,
|
12
eth2/types/src/attestation/signing.rs
Normal file
12
eth2/types/src/attestation/signing.rs
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user