2020-06-16 05:45:04 +00:00
|
|
|
# beacon_chain
|
2021-02-25 13:37:22 +00:00
|
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
2020-06-16 05:45:04 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
|
|
|
import
|
2021-09-27 14:22:58 +00:00
|
|
|
./datatypes/[phase0, altair, merge], ./helpers, ./eth2_merkleization
|
2021-08-12 13:08:20 +00:00
|
|
|
|
|
|
|
export phase0, altair
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-06-25 10:23:10 +00:00
|
|
|
template withTrust(sig: SomeSig, body: untyped): bool =
|
|
|
|
when sig is TrustedSig:
|
|
|
|
true
|
|
|
|
else:
|
|
|
|
body
|
|
|
|
|
2021-03-29 19:17:48 +00:00
|
|
|
func getDepositMessage(depositData: DepositData): DepositMessage =
|
|
|
|
DepositMessage(
|
|
|
|
pubkey: depositData.pubkey,
|
|
|
|
amount: depositData.amount,
|
|
|
|
withdrawal_credentials: depositData.withdrawal_credentials)
|
|
|
|
|
2020-09-01 13:44:40 +00:00
|
|
|
func compute_slot_root*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot
|
|
|
|
): Eth2Digest =
|
2020-06-16 05:45:04 +00:00
|
|
|
let
|
|
|
|
epoch = compute_epoch_at_slot(slot)
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_SELECTION_PROOF, epoch, genesis_validators_root)
|
2021-08-17 08:07:17 +00:00
|
|
|
compute_signing_root(slot, domain)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#aggregation-selection
|
2020-09-01 13:44:40 +00:00
|
|
|
func get_slot_signature*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
2021-04-26 20:39:44 +00:00
|
|
|
privkey: ValidatorPrivKey): CookedSig =
|
2020-09-01 13:44:40 +00:00
|
|
|
blsSign(privKey, compute_slot_root(fork, genesis_validators_root, slot).data)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-07-23 14:38:28 +00:00
|
|
|
proc verify_slot_signature*(
|
2020-07-02 16:15:27 +00:00
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
2021-06-01 11:13:40 +00:00
|
|
|
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
|
2020-07-02 16:15:27 +00:00
|
|
|
withTrust(signature):
|
|
|
|
let
|
|
|
|
epoch = compute_epoch_at_slot(slot)
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_SELECTION_PROOF, epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(slot, domain)
|
|
|
|
|
|
|
|
blsVerify(pubkey, signing_root.data, signature)
|
|
|
|
|
2020-09-01 13:44:40 +00:00
|
|
|
func compute_epoch_root*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, epoch: Epoch
|
|
|
|
): Eth2Digest =
|
2021-08-17 08:07:17 +00:00
|
|
|
let domain = get_domain(fork, DOMAIN_RANDAO, epoch, genesis_validators_root)
|
|
|
|
compute_signing_root(epoch, domain)
|
2020-09-01 13:44:40 +00:00
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#randao-reveal
|
2020-06-16 05:45:04 +00:00
|
|
|
func get_epoch_signature*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, epoch: Epoch,
|
2021-04-26 20:39:44 +00:00
|
|
|
privkey: ValidatorPrivKey): CookedSig =
|
2020-09-01 13:44:40 +00:00
|
|
|
blsSign(privKey, compute_epoch_root(fork, genesis_validators_root, epoch).data)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-07-23 14:38:28 +00:00
|
|
|
proc verify_epoch_signature*(
|
2020-06-16 05:45:04 +00:00
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, epoch: Epoch,
|
2021-06-01 11:13:40 +00:00
|
|
|
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
|
2020-06-25 10:23:10 +00:00
|
|
|
withTrust(signature):
|
|
|
|
let
|
|
|
|
domain = get_domain(fork, DOMAIN_RANDAO, epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(epoch, domain)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-06-25 10:23:10 +00:00
|
|
|
blsVerify(pubkey, signing_root.data, signature)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-09-01 13:44:40 +00:00
|
|
|
func compute_block_root*(
|
2020-06-16 05:45:04 +00:00
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
2020-09-01 13:44:40 +00:00
|
|
|
root: Eth2Digest): Eth2Digest =
|
2020-06-16 05:45:04 +00:00
|
|
|
let
|
|
|
|
epoch = compute_epoch_at_slot(slot)
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_BEACON_PROPOSER, epoch, genesis_validators_root)
|
2021-08-17 08:07:17 +00:00
|
|
|
compute_signing_root(root, domain)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#signature
|
2020-09-01 13:44:40 +00:00
|
|
|
func get_block_signature*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
2021-04-26 20:39:44 +00:00
|
|
|
root: Eth2Digest, privkey: ValidatorPrivKey): CookedSig =
|
2020-09-01 13:44:40 +00:00
|
|
|
blsSign(privKey, compute_block_root(fork, genesis_validators_root, slot, root).data)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-07-23 14:38:28 +00:00
|
|
|
proc verify_block_signature*(
|
2020-06-16 05:45:04 +00:00
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
2021-05-28 15:25:58 +00:00
|
|
|
blck: Eth2Digest | SomeSomeBeaconBlock | BeaconBlockHeader,
|
2021-06-01 11:13:40 +00:00
|
|
|
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
|
2020-06-25 10:23:10 +00:00
|
|
|
withTrust(signature):
|
|
|
|
let
|
|
|
|
epoch = compute_epoch_at_slot(slot)
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_BEACON_PROPOSER, epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(blck, domain)
|
|
|
|
|
|
|
|
blsVerify(pubKey, signing_root.data, signature)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-09-01 13:44:40 +00:00
|
|
|
func compute_aggregate_and_proof_root*(fork: Fork, genesis_validators_root: Eth2Digest,
|
|
|
|
aggregate_and_proof: AggregateAndProof,
|
|
|
|
): Eth2Digest =
|
2020-06-16 05:45:04 +00:00
|
|
|
let
|
|
|
|
epoch = compute_epoch_at_slot(aggregate_and_proof.aggregate.data.slot)
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_AGGREGATE_AND_PROOF, epoch, genesis_validators_root)
|
2021-08-17 08:07:17 +00:00
|
|
|
compute_signing_root(aggregate_and_proof, domain)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#broadcast-aggregate
|
2020-09-01 13:44:40 +00:00
|
|
|
func get_aggregate_and_proof_signature*(fork: Fork, genesis_validators_root: Eth2Digest,
|
|
|
|
aggregate_and_proof: AggregateAndProof,
|
2021-04-26 20:39:44 +00:00
|
|
|
privKey: ValidatorPrivKey): CookedSig =
|
2020-09-01 13:44:40 +00:00
|
|
|
blsSign(privKey, compute_aggregate_and_proof_root(fork, genesis_validators_root,
|
|
|
|
aggregate_and_proof).data)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2021-06-01 11:13:40 +00:00
|
|
|
proc verify_aggregate_and_proof_signature*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
|
|
|
aggregate_and_proof: AggregateAndProof,
|
|
|
|
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
|
2020-07-02 16:15:27 +00:00
|
|
|
withTrust(signature):
|
|
|
|
let
|
|
|
|
epoch = compute_epoch_at_slot(aggregate_and_proof.aggregate.data.slot)
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_AGGREGATE_AND_PROOF, epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(aggregate_and_proof, domain)
|
|
|
|
|
|
|
|
blsVerify(pubKey, signing_root.data, signature)
|
|
|
|
|
2020-09-01 13:44:40 +00:00
|
|
|
func compute_attestation_root*(
|
2020-06-16 05:45:04 +00:00
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
2020-09-01 13:44:40 +00:00
|
|
|
attestation_data: AttestationData
|
|
|
|
): Eth2Digest =
|
2020-06-16 05:45:04 +00:00
|
|
|
let
|
|
|
|
epoch = attestation_data.target.epoch
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_BEACON_ATTESTER, epoch, genesis_validators_root)
|
2021-08-17 08:07:17 +00:00
|
|
|
compute_signing_root(attestation_data, domain)
|
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#prepare-sync-committee-message
|
2021-08-17 08:07:17 +00:00
|
|
|
func sync_committee_msg_signing_root*(
|
|
|
|
fork: Fork, epoch: Epoch,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
block_root: Eth2Digest): Eth2Digest =
|
|
|
|
let domain = get_domain(fork, DOMAIN_SYNC_COMMITTEE, epoch, genesis_validators_root)
|
|
|
|
compute_signing_root(block_root, domain)
|
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#signature
|
2021-08-17 08:07:17 +00:00
|
|
|
func contribution_and_proof_signing_root*(
|
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
msg: ContributionAndProof): Eth2Digest =
|
|
|
|
let domain = get_domain(fork, DOMAIN_CONTRIBUTION_AND_PROOF,
|
|
|
|
msg.contribution.slot.epoch,
|
|
|
|
genesis_validators_root)
|
|
|
|
compute_signing_root(msg, domain)
|
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#aggregation-selection
|
2021-08-17 08:07:17 +00:00
|
|
|
proc sync_committee_selection_proof_signing_root*(
|
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
slot: Slot,
|
|
|
|
subcommittee_index: uint64): Eth2Digest =
|
|
|
|
let
|
|
|
|
domain = get_domain(fork, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF,
|
|
|
|
slot.epoch, genesis_validators_root)
|
|
|
|
signing_data = SyncAggregatorSelectionData(
|
|
|
|
slot: slot,
|
|
|
|
subcommittee_index: subcommittee_index)
|
|
|
|
compute_signing_root(signing_data, domain)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#aggregate-signature
|
2020-09-01 13:44:40 +00:00
|
|
|
func get_attestation_signature*(
|
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
|
|
|
attestation_data: AttestationData,
|
2021-04-26 20:39:44 +00:00
|
|
|
privkey: ValidatorPrivKey): CookedSig =
|
2020-09-01 13:44:40 +00:00
|
|
|
blsSign(privKey, compute_attestation_root(fork, genesis_validators_root,
|
|
|
|
attestation_data).data)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-07-23 14:38:28 +00:00
|
|
|
proc verify_attestation_signature*(
|
2020-06-16 05:45:04 +00:00
|
|
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
|
|
|
attestation_data: AttestationData,
|
2021-06-01 11:13:40 +00:00
|
|
|
pubkeys: auto,
|
2020-06-25 10:23:10 +00:00
|
|
|
signature: SomeSig): bool =
|
|
|
|
withTrust(signature):
|
|
|
|
let
|
|
|
|
epoch = attestation_data.target.epoch
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_BEACON_ATTESTER, epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(attestation_data, domain)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2020-06-25 10:23:10 +00:00
|
|
|
blsFastAggregateVerify(pubkeys, signing_root.data, signature)
|
2020-06-16 05:45:04 +00:00
|
|
|
|
2021-08-20 23:37:45 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#deposits
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
func get_deposit_signature*(preset: RuntimeConfig,
|
2020-07-07 23:02:14 +00:00
|
|
|
deposit: DepositData,
|
2021-04-26 20:39:44 +00:00
|
|
|
privkey: ValidatorPrivKey): CookedSig =
|
2020-06-16 05:45:04 +00:00
|
|
|
let
|
|
|
|
deposit_message = deposit.getDepositMessage()
|
|
|
|
# Fork-agnostic domain since deposits are valid across forks
|
2020-07-07 23:02:14 +00:00
|
|
|
domain = compute_domain(DOMAIN_DEPOSIT, preset.GENESIS_FORK_VERSION)
|
2020-06-16 05:45:04 +00:00
|
|
|
signing_root = compute_signing_root(deposit_message, domain)
|
|
|
|
|
|
|
|
blsSign(privKey, signing_root.data)
|
|
|
|
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
proc verify_deposit_signature*(preset: RuntimeConfig,
|
2020-07-07 23:02:14 +00:00
|
|
|
deposit: DepositData): bool =
|
2020-06-16 05:45:04 +00:00
|
|
|
let
|
|
|
|
deposit_message = deposit.getDepositMessage()
|
|
|
|
# Fork-agnostic domain since deposits are valid across forks
|
2020-07-07 23:02:14 +00:00
|
|
|
domain = compute_domain(DOMAIN_DEPOSIT, preset.GENESIS_FORK_VERSION)
|
2020-06-16 05:45:04 +00:00
|
|
|
signing_root = compute_signing_root(deposit_message, domain)
|
|
|
|
|
|
|
|
blsVerify(deposit.pubkey, signing_root.data, deposit.signature)
|
|
|
|
|
2020-11-27 19:48:33 +00:00
|
|
|
func get_voluntary_exit_signature*(
|
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
voluntary_exit: VoluntaryExit,
|
2021-04-26 20:39:44 +00:00
|
|
|
privkey: ValidatorPrivKey): CookedSig =
|
2020-11-27 19:48:33 +00:00
|
|
|
let
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_VOLUNTARY_EXIT, voluntary_exit.epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(voluntary_exit, domain)
|
|
|
|
|
|
|
|
blsSign(privKey, signing_root.data)
|
|
|
|
|
2020-07-23 14:38:28 +00:00
|
|
|
proc verify_voluntary_exit_signature*(
|
2020-11-27 19:48:33 +00:00
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
2020-06-16 05:45:04 +00:00
|
|
|
voluntary_exit: VoluntaryExit,
|
2020-11-27 19:48:33 +00:00
|
|
|
pubkey: ValidatorPubKey,
|
|
|
|
signature: SomeSig): bool =
|
2020-06-25 10:23:10 +00:00
|
|
|
withTrust(signature):
|
|
|
|
let
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_VOLUNTARY_EXIT, voluntary_exit.epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(voluntary_exit, domain)
|
|
|
|
|
|
|
|
blsVerify(pubkey, signing_root.data, signature)
|
2021-08-17 08:07:17 +00:00
|
|
|
|
|
|
|
proc verify_sync_committee_message_signature*(
|
|
|
|
epoch: Epoch,
|
|
|
|
beacon_block_root: Eth2Digest,
|
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
pubkey: CookedPubKey,
|
|
|
|
signature: CookedSig): bool =
|
|
|
|
let
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_SYNC_COMMITTEE, epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(beacon_block_root, domain)
|
|
|
|
|
|
|
|
blsVerify(pubkey, signing_root.data, signature)
|
|
|
|
|
2021-09-10 18:56:03 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/altair/validator.md#aggregation-selection
|
2021-08-17 08:07:17 +00:00
|
|
|
proc is_sync_committee_aggregator*(signature: ValidatorSig): bool =
|
|
|
|
let
|
|
|
|
signatureDigest = eth2digest(signature.blob)
|
|
|
|
modulo = max(1'u64, (SYNC_COMMITTEE_SIZE div SYNC_COMMITTEE_SUBNET_COUNT) div TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)
|
|
|
|
bytes_to_uint64(signatureDigest.data.toOpenArray(0, 7)) mod modulo == 0
|
|
|
|
|
|
|
|
proc verify_signed_contribution_and_proof_signature*(
|
|
|
|
msg: SignedContributionAndProof,
|
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
pubkey: ValidatorPubKey | CookedPubKey): bool =
|
|
|
|
let
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_CONTRIBUTION_AND_PROOF, msg.message.contribution.slot.epoch, genesis_validators_root)
|
|
|
|
signing_root = compute_signing_root(msg.message, domain)
|
|
|
|
|
|
|
|
blsVerify(pubkey, signing_root.data, msg.signature)
|
|
|
|
|
|
|
|
proc verify_selection_proof_signature*(
|
|
|
|
msg: ContributionAndProof,
|
|
|
|
fork: Fork,
|
|
|
|
genesis_validators_root: Eth2Digest,
|
|
|
|
pubkey: ValidatorPubKey | CookedPubKey): bool =
|
|
|
|
let
|
|
|
|
slot = msg.contribution.slot
|
|
|
|
domain = get_domain(
|
|
|
|
fork, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, slot.epoch, genesis_validators_root)
|
|
|
|
signing_data = SyncAggregatorSelectionData(
|
|
|
|
slot: slot,
|
|
|
|
subcommittee_index: msg.contribution.subcommittee_index)
|
|
|
|
signing_root = compute_signing_root(signing_data, domain)
|
|
|
|
|
|
|
|
blsVerify(pubkey, signing_root.data, msg.selection_proof)
|