mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-19 15:11:05 +00:00
Implement @djrtwo's review suggestions
This commit is contained in:
parent
d3f74ea0d9
commit
42a3dd4ab1
@ -591,7 +591,6 @@ Specifically, eth2 uses the `BLS_SIG_BLS12381G2-SHA256-SSWU-RO-_POP_` ciphersuit
|
||||
* `def Sign(SK: int, message: Bytes) -> BLSSignature`
|
||||
* `def Verify(PK: BLSPubkey, message: Bytes, signature: BLSSignature) -> bool`
|
||||
* `def Aggregate(signatures: Sequence[BLSSignature]) -> BLSSignature`
|
||||
* `def bls_aggregate_pubkeys(PKs: Sequence[BLSPubkey]) -> BLSPubkey`
|
||||
* `def FastAggregateVerify(PKs: Sequence[BLSSignature], message: Bytes, signature: BLSSignature) -> bool`
|
||||
|
||||
### Predicates
|
||||
@ -799,9 +798,9 @@ def compute_domain(domain_type: DomainType, fork_version: Version=Version()) ->
|
||||
### `compute_domain_wrapper_root`
|
||||
|
||||
```python
|
||||
def compute_domain_wrapper_root(object: SSZObject, domain: Domain) -> Root:
|
||||
def compute_domain_wrapper_root(ssz_object: SSZObject, domain: Domain) -> Root:
|
||||
domain_wrapped_object = DomainWrapper(
|
||||
root=hash_tree_root(object),
|
||||
root=hash_tree_root(ssz_object),
|
||||
domain=domain,
|
||||
)
|
||||
return hash_tree_root(domain_wrapped_object)
|
||||
@ -1497,10 +1496,8 @@ def process_proposer_slashing(state: BeaconState, proposer_slashing: ProposerSla
|
||||
assert is_slashable_validator(proposer, get_current_epoch(state))
|
||||
# Signatures are valid
|
||||
for signed_header in (proposer_slashing.signed_header_1, proposer_slashing.signed_header_2):
|
||||
message = compute_domain_wrapper_root(
|
||||
object=signed_header.message,
|
||||
domain=get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(signed_header.message.slot)),
|
||||
)
|
||||
domain = get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(signed_header.message.slot))
|
||||
message = compute_domain_wrapper_root(signed_header.message, domain)
|
||||
assert Verify(proposer.pubkey, message, signed_header.signature)
|
||||
|
||||
slash_validator(state, proposer_slashing.proposer_index)
|
||||
|
@ -135,9 +135,10 @@ def update_memory(memory: LightClientMemory, update: LightClientUpdate) -> None:
|
||||
assert 3 * sum(filter(lambda i: update.aggregation_bits[i], balances)) > 2 * sum(balances)
|
||||
|
||||
# Verify shard attestations
|
||||
pubkey = bls_aggregate_pubkeys(filter(lambda i: update.aggregation_bits[i], pubkeys))
|
||||
pubkeys = filter(lambda i: update.aggregation_bits[i], pubkeys)
|
||||
domain = compute_domain(DOMAIN_SHARD_ATTESTER, update.fork_version)
|
||||
assert bls_verify(pubkey, update.shard_block_root, update.signature, domain)
|
||||
message = compute_domain_wrapper_root(update.shard_block_root, domain)
|
||||
assert FastAggregateVerify(pubkey, message, update.signature)
|
||||
|
||||
# Update period committees if entering a new period
|
||||
if next_period == current_period + 1:
|
||||
|
@ -312,7 +312,7 @@ 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_domain_wrapper_root(compute_epoch_at_slot(header), domain)
|
||||
message = compute_domain_wrapper_root(header, domain)
|
||||
return Sign(privkey, message)
|
||||
```
|
||||
|
||||
|
@ -38,11 +38,6 @@ def FastAggregateVerify(PKs, message, signature):
|
||||
return bls.verify(pubkey=aggregate_pubkey, message_hash=message, signature=signature, domain=b'')
|
||||
|
||||
|
||||
# @only_with_bls(alt_return=STUB_PUBKEY)
|
||||
# def bls_aggregate_pubkeys(PKs):
|
||||
# return bls.aggregate_pubkeys(PKs)
|
||||
|
||||
|
||||
@only_with_bls(alt_return=STUB_SIGNATURE)
|
||||
def Aggregate(signatures):
|
||||
return bls.aggregate_signatures(signatures)
|
||||
@ -50,8 +45,7 @@ def Aggregate(signatures):
|
||||
|
||||
@only_with_bls(alt_return=STUB_SIGNATURE)
|
||||
def Sign(SK, message):
|
||||
return bls.sign(message_hash=message, privkey=SK,
|
||||
domain=b'')
|
||||
return bls.sign(message_hash=message, privkey=SK, domain=b'')
|
||||
|
||||
|
||||
@only_with_bls(alt_return=STUB_COORDINATES)
|
||||
|
Loading…
x
Reference in New Issue
Block a user