import { DOMAIN_SELECTION_PROOF } from "@lodestar/params";
import { SignatureSetType, computeSigningRoot } from "@lodestar/state-transition";
import { ssz } from "@lodestar/types";
export function getSelectionProofSigningRoot(config, slot) {
    // previously, we call `const selectionProofDomain = config.getDomain(state.slot, DOMAIN_SELECTION_PROOF, slot)`
    // at fork boundary, it's required to dial to target epoch https://github.com/ChainSafe/lodestar/blob/v1.11.3/packages/beacon-node/src/chain/validation/attestation.ts#L573
    // instead of that, just use the fork of slot in the attestation data
    const fork = config.getForkName(slot);
    const selectionProofDomain = config.getDomainAtFork(fork, DOMAIN_SELECTION_PROOF);
    return computeSigningRoot(ssz.Slot, slot, selectionProofDomain);
}
export function getSelectionProofSignatureSet(config, slot, aggregatorIndex, aggregateAndProof) {
    return {
        type: SignatureSetType.indexed,
        index: aggregatorIndex,
        signingRoot: getSelectionProofSigningRoot(config, slot),
        signature: aggregateAndProof.message.selectionProof,
    };
}
//# sourceMappingURL=selectionProof.js.map