fix: check malefactor custody key

This commit is contained in:
protolambda 2019-11-20 04:48:00 +01:00 committed by Danny Ryan
parent 41be2ed3ce
commit 1623d40b6d
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A

View File

@ -378,13 +378,21 @@ def process_custody_slashing(state: BeaconState, custody_slashing: CustodySlashi
attesters = get_attesting_indices(state, attestation.data, attestation.aggregation_bits)
assert custody_slashing.malefactor_index in attesters
# Verify the malefactor custody key
epoch_to_sign = get_randao_epoch_for_custody_period(
get_custody_period_for_validator(state, custody_slashing.malefactor_index, attestation.data.target.epoch),
custody_slashing.malefactor_index,
)
domain = get_domain(state, DOMAIN_RANDAO, epoch_to_sign)
assert bls_verify(malefactor.pubkey, hash_tree_root(epoch_to_sign), custody_slashing.malefactor_key, domain)
# Get the custody bit
custody_bits = attestation.custody_bits[custody_slashing.data_index]
committee = get_beacon_committee(state, attestation.data.slot, attestation.data.index)
claimed_custody_bit = custody_bits[committee.index(custody_slashing.malefactor_index)]
# Compute the custody bit
computed_custody_bit = compute_custody_bit(custody_slashing.data)
computed_custody_bit = compute_custody_bit(custody_slashing.malefactor_key, custody_slashing.data)
# Verify the claim
if claimed_custody_bit != computed_custody_bit: