UNPKG

@lodestar/state-transition

Version:

Beacon Chain state transition function and utils

27 lines 1.59 kB
import { PublicKey } from "@chainsafe/blst"; import { DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName } from "@lodestar/params"; import { ssz } from "@lodestar/types"; import { SignatureSetType, computeSigningRoot, verifySignatureSet } from "../util/index.js"; export function verifyBlsToExecutionChangeSignature(state, signedBLSToExecutionChange) { return verifySignatureSet(getBlsToExecutionChangeSignatureSet(state.config, signedBLSToExecutionChange)); } /** * Extract signatures to allow validating all block signatures at once */ export function getBlsToExecutionChangeSignatureSet(config, signedBLSToExecutionChange) { // signatureFork for signing domain is fixed const signatureFork = ForkName.phase0; const domain = config.getDomainAtFork(signatureFork, DOMAIN_BLS_TO_EXECUTION_CHANGE); return { type: SignatureSetType.single, // The withdrawal pubkey is the same as signedBLSToExecutionChange's fromBlsPubkey as it should // be validated against the withdrawal credentials digest pubkey: PublicKey.fromBytes(signedBLSToExecutionChange.message.fromBlsPubkey, true), signingRoot: computeSigningRoot(ssz.capella.BLSToExecutionChange, signedBLSToExecutionChange.message, domain), signature: signedBLSToExecutionChange.signature, }; } export function getBlsToExecutionChangeSignatureSets(config, signedBlock) { return signedBlock.message.body.blsToExecutionChanges.map((blsToExecutionChange) => getBlsToExecutionChangeSignatureSet(config, blsToExecutionChange)); } //# sourceMappingURL=blsToExecutionChange.js.map