Documentation ¶
Index ¶
- Constants
- Variables
- func BlockSignatureBatch(pub, signature, domain []byte, rootFunc func() ([32]byte, error)) (*bls.SignatureBatch, error)
- func ComputeDomain(domainType [DomainByteLength]byte, forkVersion, genesisValidatorsRoot []byte) ([]byte, error)
- func ComputeDomainAndSign(st state.ReadOnlyBeaconState, epoch primitives.Epoch, obj fssz.HashRoot, ...) ([]byte, error)
- func ComputeDomainAndSignWithoutState(fork *ethpb.Fork, epoch primitives.Epoch, domain [4]byte, vr []byte, ...) ([]byte, error)
- func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitives.ValidatorIndex, ...) error
- func ComputeForkDigest(version, genesisValidatorsRoot []byte) ([4]byte, error)
- func ComputeSigningRoot(object fssz.HashRoot, domain []byte) ([32]byte, error)
- func ComputeSigningRootForRoot(root [32]byte, domain []byte) ([32]byte, error)
- func Data(rootFunc func() ([32]byte, error), domain []byte) ([32]byte, error)
- func Domain(fork *eth.Fork, epoch primitives.Epoch, domainType [bls.DomainByteLength]byte, ...) ([]byte, error)
- func VerifyBlockHeaderSigningRoot(blkHdr *ethpb.BeaconBlockHeader, pub, signature, domain []byte) error
- func VerifyBlockSigningRoot(pub, signature, domain []byte, rootFunc func() ([32]byte, error)) error
- func VerifyRegistrationSignature(sr *ethpb.SignedValidatorRegistrationV1) error
- func VerifySigningRoot(obj fssz.HashRoot, pub, signature, domain []byte) error
Constants ¶
const ( // UnknownSignature represents all signatures other than below types UnknownSignature string = "unknown signature" // BlockSignature represents the block signature from block proposer BlockSignature = "block signature" // RandaoSignature represents randao specific signature RandaoSignature = "randao signature" // SelectionProof represents selection proof SelectionProof = "selection proof" // AggregatorSignature represents aggregator's signature AggregatorSignature = "aggregator signature" // AttestationSignature represents aggregated attestation signature AttestationSignature = "attestation signature" // BlsChangeSignature represents signature to BLSToExecutionChange BlsChangeSignature = "blschange signature" // SyncCommitteeSignature represents sync committee signature SyncCommitteeSignature = "sync committee signature" // SyncSelectionProof represents sync committee selection proof SyncSelectionProof = "sync selection proof" // ContributionSignature represents sync committee contributor's signature ContributionSignature = "sync committee contribution signature" // SyncAggregateSignature represents sync committee aggregator's signature SyncAggregateSignature = "sync committee aggregator signature" )
List of descriptions for different kinds of signatures
const DomainByteLength = 4
DomainByteLength length of domain byte array.
const ForkVersionByteLength = 4
ForkVersionByteLength length of fork version byte array.
Variables ¶
var ErrNilRegistration = errors.New("nil signed registration")
var ErrSigFailedToVerify = errors.New("signature did not verify")
ErrSigFailedToVerify returns when a signature of a block object(ie attestation, slashing, exit... etc) failed to verify.
Functions ¶
func BlockSignatureBatch ¶
func BlockSignatureBatch(pub, signature, domain []byte, rootFunc func() ([32]byte, error)) (*bls.SignatureBatch, error)
BlockSignatureBatch retrieves the relevant signature, message and pubkey data from a block and collating it into a signature batch object.
func ComputeDomain ¶
func ComputeDomain(domainType [DomainByteLength]byte, forkVersion, genesisValidatorsRoot []byte) ([]byte, error)
ComputeDomain returns the domain version for BLS private key to sign and verify with a zeroed 4-byte array as the fork version.
def compute_domain(domain_type: DomainType, fork_version: Version=None, genesis_validators_root: Root=None) -> Domain:
""" Return the domain for the ``domain_type`` and ``fork_version``. """ if fork_version is None: fork_version = GENESIS_FORK_VERSION if genesis_validators_root is None: genesis_validators_root = Root() # all bytes zero by default fork_data_root = compute_fork_data_root(fork_version, genesis_validators_root) return Domain(domain_type + fork_data_root[:28])
func ComputeDomainAndSign ¶
func ComputeDomainAndSign(st state.ReadOnlyBeaconState, epoch primitives.Epoch, obj fssz.HashRoot, domain [4]byte, key bls.SecretKey) ([]byte, error)
ComputeDomainAndSign computes the domain and signing root and sign it using the passed in private key.
func ComputeDomainAndSignWithoutState ¶
func ComputeDomainAndSignWithoutState(fork *ethpb.Fork, epoch primitives.Epoch, domain [4]byte, vr []byte, obj fssz.HashRoot, key bls.SecretKey) ([]byte, error)
ComputeDomainAndSignWithoutState offers the same functionalit as ComputeDomainAndSign without the need to provide a BeaconState. This is particularly helpful for signing values in tests.
func ComputeDomainVerifySigningRoot ¶
func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitives.ValidatorIndex, epoch primitives.Epoch, obj fssz.HashRoot, domain [4]byte, sig []byte) error
ComputeDomainVerifySigningRoot computes domain and verifies signing root of an object given the beacon state, validator index and signature.
func ComputeForkDigest ¶
ComputeForkDigest returns the fork for the current version and genesis validators root
Spec pseudocode definition:
def compute_fork_digest(current_version: Version, genesis_validators_root: Root) -> ForkDigest: """ Return the 4-byte fork digest for the ``current_version`` and ``genesis_validators_root``. This is a digest primarily used for domain separation on the p2p layer. 4-bytes suffices for practical separation of forks/chains. """ return ForkDigest(compute_fork_data_root(current_version, genesis_validators_root)[:4])
func ComputeSigningRoot ¶
ComputeSigningRoot computes the root of the object by calculating the hash tree root of the signing data with the given domain.
Spec pseudocode definition:
def compute_signing_root(ssz_object: SSZObject, domain: Domain) -> Root: """ Return the signing root for the corresponding signing data. """ return hash_tree_root(SigningData( object_root=hash_tree_root(ssz_object), domain=domain, ))
func ComputeSigningRootForRoot ¶
ComputeSigningRootForRoot works the same as ComputeSigningRoot, except that gets the root from an argument instead of a callback.
func Data ¶
Data computes the signing data by utilising the provided root function and then returning the signing data of the container object.
func Domain ¶
func Domain(fork *eth.Fork, epoch primitives.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error)
Domain returns the domain version for BLS private key to sign and verify.
Spec pseudocode definition:
def get_domain(state: BeaconState, domain_type: DomainType, epoch: Epoch=None) -> Domain: """ Return the signature domain (fork version concatenated with domain type) of a message. """ epoch = get_current_epoch(state) if epoch is None else epoch fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version return compute_domain(domain_type, fork_version, state.genesis_validators_root)
func VerifyBlockHeaderSigningRoot ¶
func VerifyBlockHeaderSigningRoot(blkHdr *ethpb.BeaconBlockHeader, pub, signature, domain []byte) error
VerifyBlockHeaderSigningRoot verifies the signing root of a block header given its public key, signature and domain.
func VerifyBlockSigningRoot ¶
VerifyBlockSigningRoot verifies the signing root of a block given its public key, signature and domain.
func VerifyRegistrationSignature ¶
func VerifyRegistrationSignature( sr *ethpb.SignedValidatorRegistrationV1, ) error
VerifyRegistrationSignature verifies the signature of a validator's registration.
Types ¶
This section is empty.