def compute_domain(signature_domain: SignatureDomain, fork_version: Version = default_version) -> Domain: """ NOTE: we deviate from the spec here by taking the enum ``SignatureDomain`` and converting before creating the domain. """ domain_type = signature_domain_to_domain_type(signature_domain) return Domain(domain_type + fork_version)
def sign(duty: Duty, operation: Operation, private_key_provider: PrivateKeyProvider) -> BLSSignature: message = operation.hash_tree_root private_key = private_key_provider(duty.validator_public_key) # TODO use correct ``domain`` value # NOTE currently only uses part of the domain value # need to get fork from the state and compute the full domain value locally domain = Domain(b"\x00" * 4 + signature_domain_to_domain_type(duty.signature_domain)) return bls.sign(message, private_key, domain)
def _randao_provider_of_epoch_signature( public_key: BLSPubkey, epoch: Epoch ) -> BLSSignature: private_key = private_key_provider(public_key) # TODO: fix how we get the signing root message = Hash32(epoch.to_bytes(32, byteorder="big")) domain = Domain( b"\x00" * 4 + signature_domain_to_domain_type(SignatureDomain.DOMAIN_RANDAO) ) sig = bls.sign(message, private_key, domain) return sig