Skip to content

Commit

Permalink
Added get_sync_committee_selection proof
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-o committed Aug 26, 2024
1 parent 324474d commit d9c6d83
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/lambda_ethereum_consensus/validator/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ defmodule LambdaEthereumConsensus.Validator.Utils do
end
end

@spec get_sync_committee_selection_proof(
BeaconState.t(),
Types.slot(),
non_neg_integer(),
Bls.privkey()
) ::
Types.bls_signature()
def get_sync_committee_selection_proof(%BeaconState{} = state, slot, subcommittee_i, privkey) do
domain_sc_selection_proof = Constants.domain_sync_committee_selection_proof()
epoch = Misc.compute_epoch_at_slot(slot)
domain = Accessors.get_domain(state, domain_sc_selection_proof, epoch)

signing_data = %Types.SyncAggregatorSelectionData{
slot: slot,
subcommittee_index: subcommittee_i
}

signing_root = Misc.compute_signing_root(signing_data, domain)

{:ok, signature} = Bls.sign(privkey, signing_root)
signature
end

# `is_sync_committee_aggregator` equivalent
@spec sync_committee_aggregator?(Types.bls_signature()) :: boolean()
def sync_committee_aggregator?(signature) do
Expand Down

0 comments on commit d9c6d83

Please sign in to comment.