Resolves make masker sign mask
This commit is contained in:
parent
65bcb8884f
commit
a5b22e13b8
|
@ -204,7 +204,7 @@ class EarlyDerivedSecretReveal(Container):
|
|||
# Index of the validator who revealed (whistleblower)
|
||||
masker_index: ValidatorIndex
|
||||
# Mask used to hide the actual reveal signature (prevent reveal from being stolen)
|
||||
mask: Bytes32
|
||||
mask: Hash
|
||||
```
|
||||
|
||||
### Phase 0 container updates
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from eth2spec.test.helpers.keys import privkeys
|
||||
from eth2spec.utils.bls import bls_sign
|
||||
from eth2spec.utils.bls import bls_sign, bls_aggregate_signatures
|
||||
|
||||
|
||||
def get_valid_early_derived_secret_reveal(spec, state, epoch=None):
|
||||
|
@ -10,6 +10,7 @@ def get_valid_early_derived_secret_reveal(spec, state, epoch=None):
|
|||
if epoch is None:
|
||||
epoch = current_epoch + spec.CUSTODY_PERIOD_TO_RANDAO_PADDING
|
||||
|
||||
# Generate the secret that is being revealed
|
||||
reveal = bls_sign(
|
||||
message_hash=spec.hash_tree_root(epoch),
|
||||
privkey=privkeys[revealed_index],
|
||||
|
@ -19,8 +20,11 @@ def get_valid_early_derived_secret_reveal(spec, state, epoch=None):
|
|||
message_epoch=epoch,
|
||||
),
|
||||
)
|
||||
mask = bls_sign(
|
||||
message_hash=spec.hash_tree_root(epoch),
|
||||
# Generate the mask (any random 32 bytes will do)
|
||||
mask = reveal[:32]
|
||||
# Generate masker's signature on the mask
|
||||
masker_signature = bls_sign(
|
||||
message_hash=mask,
|
||||
privkey=privkeys[masker_index],
|
||||
domain=spec.get_domain(
|
||||
state=state,
|
||||
|
@ -28,11 +32,12 @@ def get_valid_early_derived_secret_reveal(spec, state, epoch=None):
|
|||
message_epoch=epoch,
|
||||
),
|
||||
)
|
||||
masked_reveal = bls_aggregate_signatures([reveal, masker_signature])
|
||||
|
||||
return spec.EarlyDerivedSecretReveal(
|
||||
revealed_index=revealed_index,
|
||||
epoch=epoch,
|
||||
reveal=reveal,
|
||||
reveal=masked_reveal,
|
||||
masker_index=masker_index,
|
||||
mask=mask,
|
||||
)
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
from eth2spec.test.helpers.custody import get_valid_early_derived_secret_reveal
|
||||
from eth2spec.test.helpers.block import apply_empty_block
|
||||
from eth2spec.test.helpers.state import next_epoch, get_balance
|
||||
from eth2spec.test.context import with_all_phases_except, spec_state_test, expect_assertion_error
|
||||
from eth2spec.test.context import (
|
||||
with_all_phases_except,
|
||||
spec_state_test,
|
||||
expect_assertion_error,
|
||||
always_bls,
|
||||
never_bls,
|
||||
)
|
||||
|
||||
|
||||
def run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, valid=True):
|
||||
|
@ -36,6 +42,7 @@ def run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, v
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@always_bls
|
||||
@spec_state_test
|
||||
def test_success(spec, state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(spec, state)
|
||||
|
@ -44,6 +51,7 @@ def test_success(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@never_bls
|
||||
@spec_state_test
|
||||
def test_reveal_from_current_epoch(spec, state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(spec, state, spec.get_current_epoch(state))
|
||||
|
@ -52,6 +60,7 @@ def test_reveal_from_current_epoch(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@never_bls
|
||||
@spec_state_test
|
||||
def test_reveal_from_past_epoch(spec, state):
|
||||
next_epoch(spec, state)
|
||||
|
@ -62,6 +71,7 @@ def test_reveal_from_past_epoch(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@always_bls
|
||||
@spec_state_test
|
||||
def test_reveal_with_custody_padding(spec, state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(
|
||||
|
@ -73,6 +83,7 @@ def test_reveal_with_custody_padding(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@always_bls
|
||||
@spec_state_test
|
||||
def test_reveal_with_custody_padding_minus_one(spec, state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(
|
||||
|
@ -84,6 +95,7 @@ def test_reveal_with_custody_padding_minus_one(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@never_bls
|
||||
@spec_state_test
|
||||
def test_double_reveal(spec, state):
|
||||
randao_key_reveal1 = get_valid_early_derived_secret_reveal(
|
||||
|
@ -108,6 +120,7 @@ def test_double_reveal(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@never_bls
|
||||
@spec_state_test
|
||||
def test_revealer_is_slashed(spec, state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(spec, state, spec.get_current_epoch(state))
|
||||
|
@ -117,6 +130,7 @@ def test_revealer_is_slashed(spec, state):
|
|||
|
||||
|
||||
@with_all_phases_except(['phase0'])
|
||||
@never_bls
|
||||
@spec_state_test
|
||||
def test_far_future_epoch(spec, state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(
|
||||
|
|
Loading…
Reference in New Issue