'message' -> 'signing_root'

This commit is contained in:
Carl Beekhuizen 2020-01-03 08:18:34 +01:00
parent 51bcb29e28
commit 8580ec33f2
No known key found for this signature in database
GPG Key ID: 8F29E54F49E7AAB5
5 changed files with 26 additions and 26 deletions

View File

@ -676,8 +676,8 @@ def is_valid_indexed_attestation(state: BeaconState, indexed_attestation: Indexe
# Verify aggregate signature
pubkeys = [state.validators[i].pubkey for i in indices]
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, indexed_attestation.data.target.epoch)
message = compute_signing_root(indexed_attestation.data, domain)
return bls.FastAggregateVerify(pubkeys, message, indexed_attestation.signature)
signing_root = compute_signing_root(indexed_attestation.data, domain)
return bls.FastAggregateVerify(pubkeys, signing_root, indexed_attestation.signature)
```
#### `is_valid_merkle_branch`
@ -1148,8 +1148,8 @@ def state_transition(state: BeaconState, signed_block: SignedBeaconBlock, valida
```python
def verify_block_signature(state: BeaconState, signed_block: SignedBeaconBlock) -> bool:
proposer = state.validators[get_beacon_proposer_index(state)]
message = compute_signing_root(signed_block.message, get_domain(state, DOMAIN_BEACON_PROPOSER))
return bls.Verify(proposer.pubkey, message, signed_block.signature)
signing_root = compute_signing_root(signed_block.message, get_domain(state, DOMAIN_BEACON_PROPOSER))
return bls.Verify(proposer.pubkey, signing_root, signed_block.signature)
```
```python
@ -1448,8 +1448,8 @@ def process_randao(state: BeaconState, body: BeaconBlockBody) -> None:
epoch = get_current_epoch(state)
# Verify RANDAO reveal
proposer = state.validators[get_beacon_proposer_index(state)]
message = compute_signing_root(epoch, get_domain(state, DOMAIN_RANDAO))
assert bls.Verify(proposer.pubkey, message, body.randao_reveal)
signing_root = compute_signing_root(epoch, get_domain(state, DOMAIN_RANDAO))
assert bls.Verify(proposer.pubkey, signing_root, body.randao_reveal)
# Mix in RANDAO reveal
mix = xor(get_randao_mix(state, epoch), hash(body.randao_reveal))
state.randao_mixes[epoch % EPOCHS_PER_HISTORICAL_VECTOR] = mix
@ -1497,8 +1497,8 @@ def process_proposer_slashing(state: BeaconState, proposer_slashing: ProposerSla
# Signatures are valid
for signed_header in (proposer_slashing.signed_header_1, proposer_slashing.signed_header_2):
domain = get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(signed_header.message.slot))
message = compute_signing_root(signed_header.message, domain)
assert bls.Verify(proposer.pubkey, message, signed_header.signature)
signing_root = compute_signing_root(signed_header.message, domain)
assert bls.Verify(proposer.pubkey, signing_root, signed_header.signature)
slash_validator(state, proposer_slashing.proposer_index)
```
@ -1580,8 +1580,8 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
pubkey=deposit.data.pubkey,
withdrawal_credentials=deposit.data.withdrawal_credentials,
amount=deposit.data.amount)
message = compute_signing_root(deposit_message, compute_domain(DOMAIN_DEPOSIT))
if not bls.Verify(pubkey, message, deposit.data.signature):
signing_root = compute_signing_root(deposit_message, compute_domain(DOMAIN_DEPOSIT))
if not bls.Verify(pubkey, signing_root, deposit.data.signature):
return
# Add validator and balance entries
@ -1617,8 +1617,8 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
assert get_current_epoch(state) >= validator.activation_epoch + PERSISTENT_COMMITTEE_PERIOD
# Verify signature
domain = get_domain(state, DOMAIN_VOLUNTARY_EXIT, voluntary_exit.epoch)
message = compute_signing_root(voluntary_exit, domain)
assert bls.Verify(validator.pubkey, message, signed_voluntary_exit.signature)
signing_root = compute_signing_root(voluntary_exit, domain)
assert bls.Verify(validator.pubkey, signing_root, signed_voluntary_exit.signature)
# Initiate exit
initiate_validator_exit(state, voluntary_exit.validator_index)
```

View File

@ -430,8 +430,8 @@ def process_custody_key_reveal(state: BeaconState, reveal: CustodyKeyReveal) ->
# Verify signature
domain = get_domain(state, DOMAIN_RANDAO, epoch_to_sign)
message = compute_signing_root(epoch_to_sign, domain)
assert bls.Verify(revealer.pubkey, message, reveal.reveal)
signing_root = compute_signing_root(epoch_to_sign, domain)
assert bls.Verify(revealer.pubkey, signing_root, reveal.reveal)
# Decrement max reveal lateness if response is timely
if epoch_to_sign + EPOCHS_PER_CUSTODY_PERIOD >= get_current_epoch(state):

View File

@ -407,8 +407,8 @@ def process_shard_attestations(beacon_state: BeaconState, shard_state: ShardStat
# Verify attester aggregate signature
domain = get_domain(beacon_state, DOMAIN_SHARD_ATTESTER, compute_epoch_of_shard_slot(block.slot))
shard_attestation_data = ShardAttestationData(slot=shard_state.slot, parent_root=block.parent_root)
message = compute_signing_root(shard_attestation_data, domain)
assert bls.FastAggregateVerify(pubkeys, message, block.attestations)
signing_root = compute_signing_root(shard_attestation_data, domain)
assert bls.FastAggregateVerify(pubkeys, signing_root, block.attestations)
# Proposer micro-reward
proposer_index = get_shard_proposer_index(beacon_state, shard_state.shard, block.slot)
reward = attestation_count * get_base_reward(beacon_state, proposer_index) // PROPOSER_REWARD_QUOTIENT

View File

@ -137,8 +137,8 @@ def update_memory(memory: LightClientMemory, update: LightClientUpdate) -> None:
# Verify shard attestations
pubkeys = filter(lambda i: update.aggregation_bits[i], pubkeys)
domain = compute_domain(DOMAIN_SHARD_ATTESTER, update.fork_version)
message = compute_signing_root(update.shard_block_root, domain)
assert bls.FastAggregateVerify(pubkeys, message, update.signature)
signing_root = compute_signing_root(update.shard_block_root, domain)
assert bls.FastAggregateVerify(pubkeys, signing_root, update.signature)
# Update period committees if entering a new period
if next_period == current_period + 1:

View File

@ -234,8 +234,8 @@ Set `block.body.randao_reveal = epoch_signature` where `epoch_signature` is obta
```python
def get_epoch_signature(state: BeaconState, block: BeaconBlock, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_RANDAO, compute_epoch_at_slot(block.slot))
message = compute_signing_root(compute_epoch_at_slot(block.slot), domain)
return bls.Sign(privkey, message)
signing_root = compute_signing_root(compute_epoch_at_slot(block.slot), domain)
return bls.Sign(privkey, signing_root)
```
##### Eth1 Data
@ -312,8 +312,8 @@ def compute_new_state_root(state: BeaconState, block: BeaconBlock) -> Root:
```python
def get_block_signature(state: BeaconState, header: BeaconBlockHeader, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(header.slot))
message = compute_signing_root(header, domain)
return bls.Sign(privkey, message)
signing_root = compute_signing_root(header, domain)
return bls.Sign(privkey, signing_root)
```
### Attesting
@ -371,8 +371,8 @@ Set `attestation.signature = signed_attestation_data` where `signed_attestation_
```python
def get_signed_attestation_data(state: BeaconState, attestation: IndexedAttestation, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, attestation.data.target.epoch)
message = compute_signing_root(attestation.data, domain)
return bls.Sign(privkey, message)
signing_root = compute_signing_root(attestation.data, domain)
return bls.Sign(privkey, signing_root)
```
#### Broadcast attestation
@ -390,8 +390,8 @@ A validator is selected to aggregate based upon the return value of `is_aggregat
```python
def get_slot_signature(state: BeaconState, slot: Slot, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, compute_epoch_at_slot(slot))
message = compute_signing_root(slot, domain)
return bls.Sign(privkey, message)
signing_root = compute_signing_root(slot, domain)
return bls.Sign(privkey, signing_root)
```
```python