@lodestar/state-transition
Version: 
Beacon Chain state transition function and utils
19 lines • 1.41 kB
JavaScript
import { DOMAIN_BEACON_ATTESTER } from "@lodestar/params";
import { ssz } from "@lodestar/types";
import { computeSigningRoot, computeStartSlotAtEpoch, createAggregateSignatureSetFromComponents, } from "../util/index.js";
export function getAttestationDataSigningRoot(state, data) {
    const slot = computeStartSlotAtEpoch(data.target.epoch);
    const domain = state.config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
    return computeSigningRoot(ssz.phase0.AttestationData, data, domain);
}
export function getAttestationWithIndicesSignatureSet(state, attestation, attestingIndices) {
    return createAggregateSignatureSetFromComponents(attestingIndices.map((i) => state.epochCtx.index2pubkey[i]), getAttestationDataSigningRoot(state, attestation.data), attestation.signature);
}
export function getIndexedAttestationSignatureSet(state, indexedAttestation) {
    return getAttestationWithIndicesSignatureSet(state, indexedAttestation, indexedAttestation.attestingIndices);
}
export function getAttestationsSignatureSets(state, signedBlock) {
    // TODO: figure how to get attesting indices of an attestation once per block processing
    return signedBlock.message.body.attestations.map((attestation) => getIndexedAttestationSignatureSet(state, state.epochCtx.getIndexedAttestation(state.config.getForkSeq(signedBlock.message.slot), attestation)));
}
//# sourceMappingURL=indexedAttestation.js.map