eth2.0-specs/test_libs/pyspec/eth2spec/test/helpers/block_header.py

15 lines
432 B
Python
Raw Normal View History

2019-05-15 17:31:02 +00:00
from eth2spec.utils.bls import bls_sign
2019-11-21 22:13:45 +00:00
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
2019-05-15 17:31:02 +00:00
2019-05-30 20:57:18 +00:00
def sign_block_header(spec, state, header, privkey):
domain = spec.get_domain(
2019-05-15 17:31:02 +00:00
state=state,
domain_type=spec.DOMAIN_BEACON_PROPOSER,
)
2019-11-21 22:13:45 +00:00
return spec.SignedBeaconBlockHeader(message=header, signature=bls_sign(
message_hash=hash_tree_root(header),
2019-05-15 17:31:02 +00:00
privkey=privkey,
domain=domain,
2019-11-21 22:13:45 +00:00
))