add explicit instrucutions for construction of signed_aggregate_and_proof. add DOMAIN_SELECTION_PROOF and DOMAIN_AGGREGATE_AND_PROOF
This commit is contained in:
parent
8d16d428e0
commit
eec57f29b7
|
@ -143,6 +143,8 @@ DOMAIN_BEACON_ATTESTER: 0x01000000
|
||||||
DOMAIN_RANDAO: 0x02000000
|
DOMAIN_RANDAO: 0x02000000
|
||||||
DOMAIN_DEPOSIT: 0x03000000
|
DOMAIN_DEPOSIT: 0x03000000
|
||||||
DOMAIN_VOLUNTARY_EXIT: 0x04000000
|
DOMAIN_VOLUNTARY_EXIT: 0x04000000
|
||||||
|
DOMAIN_SELECTION_PROOF: 0x05000000
|
||||||
|
DOMAIN_AGGREGATE_AND_PROOF: 0x06000000
|
||||||
# Phase 1
|
# Phase 1
|
||||||
DOMAIN_SHARD_PROPOSAL: 0x80000000
|
DOMAIN_SHARD_PROPOSAL: 0x80000000
|
||||||
DOMAIN_SHARD_COMMITTEE: 0x81000000
|
DOMAIN_SHARD_COMMITTEE: 0x81000000
|
||||||
|
|
|
@ -142,6 +142,8 @@ DOMAIN_BEACON_ATTESTER: 0x01000000
|
||||||
DOMAIN_RANDAO: 0x02000000
|
DOMAIN_RANDAO: 0x02000000
|
||||||
DOMAIN_DEPOSIT: 0x03000000
|
DOMAIN_DEPOSIT: 0x03000000
|
||||||
DOMAIN_VOLUNTARY_EXIT: 0x04000000
|
DOMAIN_VOLUNTARY_EXIT: 0x04000000
|
||||||
|
DOMAIN_SELECTION_PROOF: 0x05000000
|
||||||
|
DOMAIN_AGGREGATE_AND_PROOF: 0x06000000
|
||||||
# Phase 1
|
# Phase 1
|
||||||
DOMAIN_SHARD_PROPOSAL: 0x80000000
|
DOMAIN_SHARD_PROPOSAL: 0x80000000
|
||||||
DOMAIN_SHARD_COMMITTEE: 0x81000000
|
DOMAIN_SHARD_COMMITTEE: 0x81000000
|
||||||
|
|
|
@ -258,6 +258,9 @@ The following values are (non-configurable) constants used throughout the specif
|
||||||
| `DOMAIN_RANDAO` | `DomainType('0x02000000')` |
|
| `DOMAIN_RANDAO` | `DomainType('0x02000000')` |
|
||||||
| `DOMAIN_DEPOSIT` | `DomainType('0x03000000')` |
|
| `DOMAIN_DEPOSIT` | `DomainType('0x03000000')` |
|
||||||
| `DOMAIN_VOLUNTARY_EXIT` | `DomainType('0x04000000')` |
|
| `DOMAIN_VOLUNTARY_EXIT` | `DomainType('0x04000000')` |
|
||||||
|
| `DOMAIN_SELECTION_PROOF` | `DomainType('0x05000000')` |
|
||||||
|
| `DOMAIN_AGGREGATE_AND_PROOF` | `DomainType('0x06000000')` |
|
||||||
|
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
|
|
|
@ -424,7 +424,7 @@ A validator is selected to aggregate based upon the return value of `is_aggregat
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def get_slot_signature(state: BeaconState, slot: Slot, privkey: int) -> BLSSignature:
|
def get_slot_signature(state: BeaconState, slot: Slot, privkey: int) -> BLSSignature:
|
||||||
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, compute_epoch_at_slot(slot))
|
domain = get_domain(state, DOMAIN_SELECTION_PROOF, compute_epoch_at_slot(slot))
|
||||||
signing_root = compute_signing_root(slot, domain)
|
signing_root = compute_signing_root(slot, domain)
|
||||||
return bls.Sign(privkey, signing_root)
|
return bls.Sign(privkey, signing_root)
|
||||||
```
|
```
|
||||||
|
@ -468,6 +468,32 @@ Selection proofs are provided in `AggregateAndProof` to prove to the gossip chan
|
||||||
|
|
||||||
`AggregateAndProof` messages are signed by the aggregator and broadcast inside of `SignedAggregateAndProof` objects to prevent a class of DoS attacks and message forgeries.
|
`AggregateAndProof` messages are signed by the aggregator and broadcast inside of `SignedAggregateAndProof` objects to prevent a class of DoS attacks and message forgeries.
|
||||||
|
|
||||||
|
First, `aggregate_and_proof = get_aggregate_and_proof(state, aggregate_attestation, validator_index, privkey)` is contructed.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def get_aggregate_and_proof(state: BeaconState,
|
||||||
|
aggregate: Attestation,
|
||||||
|
aggregator_index: ValidatorIndex,
|
||||||
|
privkey: int) -> AggregateAndProof:
|
||||||
|
return AggregateAndProof(
|
||||||
|
aggregator_index=aggregator_index,
|
||||||
|
aggregate=aggregate,
|
||||||
|
selection_proof=get_slot_signature(state, aggregate.data.slot, privkey),
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Then `signed_aggregate_and_proof = SignedAggregateAndProof(message=aggregate_and_proof, signature=signature)` is constructed and broadast. Where `signature` is obtained from:
|
||||||
|
|
||||||
|
```python
|
||||||
|
def get_aggregate_and_proof_signature(state: BeaconState,
|
||||||
|
aggregate_and_proof: AggregateAndProof,
|
||||||
|
privkey: int) -> BLSSignature:
|
||||||
|
aggregate = aggregate_and_proof.aggregate
|
||||||
|
domain = get_domain(state, DOMAIN_AGGREGATE_AND_PROOF, compute_epoch_at_slot(aggregate.data.slot))
|
||||||
|
signing_root = compute_signing_root(aggregate_and_proof, domain)
|
||||||
|
return bls.Sign(privkey, signing_root)
|
||||||
|
```
|
||||||
|
|
||||||
##### `AggregateAndProof`
|
##### `AggregateAndProof`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
Loading…
Reference in New Issue