separates out domain

This commit is contained in:
Carl Beekhuizen 2019-07-01 01:22:58 +02:00
parent 7ef98f7478
commit 4f47e30144
No known key found for this signature in database
GPG Key ID: D05CA176D0020646

View File

@ -214,11 +214,8 @@ Set `block.randao_reveal = epoch_signature` where `epoch_signature` is obtained
```python ```python
def get_epoch_signature(state: BeaconState, block: BeaconBlock, privkey: int) -> BLSSignature: def get_epoch_signature(state: BeaconState, block: BeaconBlock, privkey: int) -> BLSSignature:
return bls_sign( domain = get_domain(state, DOMAIN_RANDAO, slot_to_epoch(block.slot))
privkey=privkey, # privkey stored locally return bls_sign(privkey, hash_tree_root(slot_to_epoch(block.slot)), domain)
message_hash=hash_tree_root(slot_to_epoch(block.slot)),
domain=get_domain(state, DOMAIN_RANDAO, slot_to_epoch(block.slot))
)
``` ```
##### Eth1 Data ##### Eth1 Data
@ -251,11 +248,8 @@ Set `header.signature = block_signature` where `block_signature` is obtained fro
```python ```python
def get_block_signature(state: BeaconState, header: BeaconBlockHeader, privkey: int) -> BLSSignature: def get_block_signature(state: BeaconState, header: BeaconBlockHeader, privkey: int) -> BLSSignature:
return bls_sign( domain = get_domain(state, DOMAIN_BEACON_PROPOSER, slot_to_epoch(header.slot))
privkey=privkey, # privkey stored locally return bls_sign(privkey, signing_root(header), domain)
message_hash=signing_root(header),
domain=get_domain(state, DOMAIN_BEACON_PROPOSER, slot_to_epoch(header.slot))
)
``` ```
#### Block body #### Block body
@ -353,11 +347,8 @@ def get_signed_attestation_data(state: BeaconState, attestation: IndexedAttestat
custody_bit=0b0, custody_bit=0b0,
) )
return bls_sign( domain = get_domain(state, DOMAIN_ATTESTATION, attestation.data.target.epoch)
privkey=privkey, # privkey stored locally return bls_sign(privkey, hash_tree_root(attestation_data_and_custody_bit), domain)
message_hash=hash_tree_root(attestation_data_and_custody_bit),
domain=get_domain(state, DOMAIN_ATTESTATION, attestation.data.target.epoch)
)
``` ```
## How to avoid slashing ## How to avoid slashing