mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-20 22:38:11 +00:00
Remove references to BLS messages
This commit is contained in:
parent
8580ec33f2
commit
8948393e76
@ -799,6 +799,9 @@ def compute_domain(domain_type: DomainType, fork_version: Version=Version()) ->
|
||||
|
||||
```python
|
||||
def compute_signing_root(ssz_object: SSZObject, domain: Domain) -> Root:
|
||||
"""
|
||||
Return the signing root of an object by calculating the root of the object-domain tree.
|
||||
"""
|
||||
domain_wrapped_object = SigningRoot(
|
||||
object_root=hash_tree_root(ssz_object),
|
||||
domain=domain,
|
||||
@ -959,11 +962,11 @@ def get_total_active_balance(state: BeaconState) -> Gwei:
|
||||
#### `get_domain`
|
||||
|
||||
```python
|
||||
def get_domain(state: BeaconState, domain_type: DomainType, message_epoch: Epoch=None) -> Domain:
|
||||
def get_domain(state: BeaconState, domain_type: DomainType, epoch: Epoch=None) -> Domain:
|
||||
"""
|
||||
Return the signature domain (fork version concatenated with domain type) of a message.
|
||||
"""
|
||||
epoch = get_current_epoch(state) if message_epoch is None else message_epoch
|
||||
epoch = get_current_epoch(state) if epoch is None else epoch
|
||||
fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version
|
||||
return compute_domain(domain_type, fork_version)
|
||||
```
|
||||
|
@ -482,10 +482,8 @@ def process_early_derived_secret_reveal(state: BeaconState, reveal: EarlyDerived
|
||||
pubkeys = [revealed_validator.pubkey, masker.pubkey]
|
||||
|
||||
domain = get_domain(state, DOMAIN_RANDAO, reveal.epoch)
|
||||
messages = [compute_signing_root(message, domain)
|
||||
for message in [hash_tree_root(reveal.epoch), reveal.mask]]
|
||||
|
||||
assert bls.AggregateVerify(pubkeys, messages, reveal.reveal)
|
||||
signing_roots = [compute_signing_root(root, domain) for root in [hash_tree_root(reveal.epoch), reveal.mask]]
|
||||
assert bls.AggregateVerify(pubkeys, signing_roots, reveal.reveal)
|
||||
|
||||
if reveal.epoch >= get_current_epoch(state) + CUSTODY_PERIOD_TO_RANDAO_PADDING:
|
||||
# Full slashing when the secret was revealed so early it may be a valid custody
|
||||
|
@ -97,8 +97,8 @@ def sign_attestation(spec, state, attestation):
|
||||
|
||||
def get_attestation_signature(spec, state, attestation_data, privkey):
|
||||
domain = spec.get_domain(state, spec.DOMAIN_BEACON_ATTESTER, attestation_data.target.epoch)
|
||||
message = spec.compute_signing_root(attestation_data, domain)
|
||||
return bls.Sign(privkey, message)
|
||||
signing_root = spec.compute_signing_root(attestation_data, domain)
|
||||
return bls.Sign(privkey, signing_root)
|
||||
|
||||
|
||||
def fill_aggregate_attestation(spec, state, attestation, signed=False):
|
||||
|
@ -30,8 +30,8 @@ def apply_randao_reveal(spec, state, block, proposer_index=None):
|
||||
privkey = privkeys[proposer_index]
|
||||
|
||||
domain = spec.get_domain(state, spec.DOMAIN_RANDAO, spec.compute_epoch_at_slot(block.slot))
|
||||
message = spec.compute_signing_root(spec.compute_epoch_at_slot(block.slot), domain)
|
||||
block.body.randao_reveal = bls.Sign(privkey, message)
|
||||
signing_root = spec.compute_signing_root(spec.compute_epoch_at_slot(block.slot), domain)
|
||||
block.body.randao_reveal = bls.Sign(privkey, signing_root)
|
||||
|
||||
|
||||
# Fully ignore the function if BLS is off, beacon-proposer index calculation is slow.
|
||||
@ -42,9 +42,9 @@ def apply_sig(spec, state, signed_block, proposer_index=None):
|
||||
proposer_index = get_proposer_index_maybe(spec, state, block.slot, proposer_index)
|
||||
privkey = privkeys[proposer_index]
|
||||
domain = spec.get_domain(state, spec.DOMAIN_BEACON_PROPOSER, spec.compute_epoch_at_slot(block.slot))
|
||||
message = spec.compute_signing_root(block, domain)
|
||||
signing_root = spec.compute_signing_root(block, domain)
|
||||
|
||||
signed_block.signature = bls.Sign(privkey, message)
|
||||
signed_block.signature = bls.Sign(privkey, signing_root)
|
||||
|
||||
|
||||
def sign_block(spec, state, block, proposer_index=None):
|
||||
|
@ -6,6 +6,6 @@ def sign_block_header(spec, state, header, privkey):
|
||||
state=state,
|
||||
domain_type=spec.DOMAIN_BEACON_PROPOSER,
|
||||
)
|
||||
message = spec.compute_signing_root(header, domain)
|
||||
signature = bls.Sign(privkey, message)
|
||||
signing_root = spec.compute_signing_root(header, domain)
|
||||
signature = bls.Sign(privkey, signing_root)
|
||||
return spec.SignedBeaconBlockHeader(message=header, signature=signature)
|
||||
|
@ -18,13 +18,13 @@ def get_valid_early_derived_secret_reveal(spec, state, epoch=None):
|
||||
|
||||
# Generate the secret that is being revealed
|
||||
domain = spec.get_domain(state, spec.DOMAIN_RANDAO, epoch)
|
||||
message = spec.compute_signing_root(spec.Epoch(epoch), domain)
|
||||
reveal = bls.Sign(privkeys[revealed_index], message)
|
||||
signing_root = spec.compute_signing_root(spec.Epoch(epoch), domain)
|
||||
reveal = bls.Sign(privkeys[revealed_index], signing_root)
|
||||
# Generate the mask (any random 32 bytes that don't reveal the masker's secret will do)
|
||||
mask = hash(reveal)
|
||||
# Generate masker's signature on the mask
|
||||
message = spec.compute_signing_root(mask, domain)
|
||||
masker_signature = bls.Sign(privkeys[masker_index], message)
|
||||
signing_root = spec.compute_signing_root(mask, domain)
|
||||
masker_signature = bls.Sign(privkeys[masker_index], signing_root)
|
||||
masked_reveal = bls.Aggregate([reveal, masker_signature])
|
||||
|
||||
return spec.EarlyDerivedSecretReveal(
|
||||
@ -48,8 +48,8 @@ def get_valid_custody_key_reveal(spec, state, period=None):
|
||||
|
||||
# Generate the secret that is being revealed
|
||||
domain = spec.get_domain(state, spec.DOMAIN_RANDAO, epoch_to_sign)
|
||||
message = spec.compute_signing_root(spec.Epoch(epoch_to_sign), domain)
|
||||
reveal = bls.Sign(privkeys[revealer_index], message)
|
||||
signing_root = spec.compute_signing_root(spec.Epoch(epoch_to_sign), domain)
|
||||
reveal = bls.Sign(privkeys[revealer_index], signing_root)
|
||||
return spec.CustodyKeyReveal(
|
||||
revealer_index=revealer_index,
|
||||
reveal=reveal,
|
||||
@ -74,8 +74,8 @@ def get_valid_bit_challenge(spec, state, attestation, invalid_custody_bit=False)
|
||||
|
||||
# Generate the responder key
|
||||
domain = spec.get_domain(state, spec.DOMAIN_RANDAO, epoch)
|
||||
message = spec.compute_signing_root(spec.compute_signing_root, domain)
|
||||
responder_key = bls.Sign(privkeys[responder_index], message)
|
||||
signing_root = spec.compute_signing_root(spec.Epoch(epoch), domain)
|
||||
responder_key = bls.Sign(privkeys[responder_index], signing_root)
|
||||
|
||||
chunk_count = spec.get_custody_chunk_count(attestation.data.crosslink)
|
||||
|
||||
|
@ -30,8 +30,8 @@ def sign_deposit_data(spec, deposit_data, privkey, state=None):
|
||||
pubkey=deposit_data.pubkey,
|
||||
withdrawal_credentials=deposit_data.withdrawal_credentials,
|
||||
amount=deposit_data.amount)
|
||||
message = spec.compute_signing_root(deposit_message, domain)
|
||||
deposit_data.signature = bls.Sign(privkey, message)
|
||||
signing_root = spec.compute_signing_root(deposit_message, domain)
|
||||
deposit_data.signature = bls.Sign(privkey, signing_root)
|
||||
|
||||
|
||||
def build_deposit(spec,
|
||||
|
@ -26,5 +26,5 @@ def sign_shard_attestation(spec, beacon_state, shard_state, block, participants)
|
||||
|
||||
def get_attestation_signature(spec, beacon_state, shard_state, message_hash, block_epoch, privkey):
|
||||
domain = spec.get_domain(beacon_state, spec.DOMAIN_SHARD_ATTESTER, block_epoch)
|
||||
message = spec.compute_signing_root(message_hash, domain)
|
||||
return bls.Sign(privkey, message)
|
||||
signing_root = spec.compute_signing_root(message_hash, domain)
|
||||
return bls.Sign(privkey, signing_root)
|
||||
|
@ -19,8 +19,8 @@ def sign_shard_block(spec, beacon_state, shard_state, block, proposer_index=None
|
||||
|
||||
privkey = privkeys[proposer_index]
|
||||
domain = spec.get_domain(beacon_state, spec.DOMAIN_SHARD_PROPOSER, spec.compute_epoch_of_shard_slot(block.slot))
|
||||
message = spec.compute_signing_root(block, domain)
|
||||
block.signature = bls.Sign(privkey, message)
|
||||
signing_root = spec.compute_signing_root(block, domain)
|
||||
block.signature = bls.Sign(privkey, signing_root)
|
||||
|
||||
|
||||
def build_empty_shard_block(spec,
|
||||
|
@ -3,8 +3,8 @@ from eth2spec.utils import bls
|
||||
|
||||
def sign_voluntary_exit(spec, state, voluntary_exit, privkey):
|
||||
domain = spec.get_domain(state, spec.DOMAIN_VOLUNTARY_EXIT, voluntary_exit.epoch)
|
||||
message = spec.compute_signing_root(voluntary_exit, domain)
|
||||
signing_root = spec.compute_signing_root(voluntary_exit, domain)
|
||||
return spec.SignedVoluntaryExit(
|
||||
message=voluntary_exit,
|
||||
signature=bls.Sign(privkey, message)
|
||||
signature=bls.Sign(privkey, signing_root)
|
||||
)
|
||||
|
@ -108,10 +108,10 @@ def test_invalid_block_sig(spec, state):
|
||||
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
domain = spec.get_domain(state, spec.DOMAIN_BEACON_PROPOSER, spec.compute_epoch_at_slot(block.slot))
|
||||
message = spec.compute_signing_root(block, domain)
|
||||
signing_root = spec.compute_signing_root(block, domain)
|
||||
invalid_signed_block = spec.SignedBeaconBlock(
|
||||
message=block,
|
||||
signature=bls.Sign(123456, message)
|
||||
signature=bls.Sign(123456, signing_root)
|
||||
)
|
||||
expect_assertion_error(lambda: spec.state_transition(state, invalid_signed_block))
|
||||
|
||||
@ -417,10 +417,10 @@ def test_voluntary_exit(spec, state):
|
||||
validator_index=validator_index,
|
||||
)
|
||||
domain = spec.get_domain(state, spec.DOMAIN_VOLUNTARY_EXIT)
|
||||
message = spec.compute_signing_root(voluntary_exit, domain)
|
||||
signing_root = spec.compute_signing_root(voluntary_exit, domain)
|
||||
signed_voluntary_exit = spec.SignedVoluntaryExit(
|
||||
message=voluntary_exit,
|
||||
signature=bls.Sign(privkeys[validator_index], message)
|
||||
signature=bls.Sign(privkeys[validator_index], signing_root)
|
||||
)
|
||||
|
||||
# Add to state via block transition
|
||||
|
Loading…
x
Reference in New Issue
Block a user