Ejemplo n.º 1
0
def validate_proof_of_possession(state: BeaconState, pubkey: BLSPubkey,
                                 proof_of_possession: BLSSignature,
                                 withdrawal_credentials: Hash32,
                                 randao_commitment: Hash32) -> None:
    deposit_input = DepositInput(
        pubkey=pubkey,
        withdrawal_credentials=withdrawal_credentials,
        randao_commitment=randao_commitment,
        proof_of_possession=EMPTY_SIGNATURE,
    )

    is_valid_signature = bls.verify(
        pubkey=pubkey,
        # TODO: change to hash_tree_root(deposit_input) when we have SSZ tree hashing
        message=deposit_input.root,
        signature=proof_of_possession,
        domain=get_domain(
            state.fork_data,
            state.slot,
            SignatureDomain.DOMAIN_DEPOSIT,
        ),
    )

    if not is_valid_signature:
        raise ValidationError("BLS signature verification error")
Ejemplo n.º 2
0
def make_deposit_input(pubkey, withdrawal_credentials, randao_commitment):
    return DepositInput(
        pubkey=pubkey,
        withdrawal_credentials=withdrawal_credentials,
        randao_commitment=randao_commitment,
        proof_of_possession=EMPTY_SIGNATURE,
    )
Ejemplo n.º 3
0
def test_defaults(sample_deposit_input_params):
    deposit_input = DepositInput(**sample_deposit_input_params)

    assert deposit_input.pubkey == sample_deposit_input_params['pubkey']
Ejemplo n.º 4
0
def sample_deposit_data_params(sample_deposit_input_params):
    return {
        'deposit_input': DepositInput(**sample_deposit_input_params),
        'value': 56,
        'timestamp': 1501851927,
    }