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 types.Epoch, obj fssz.HashRoot, ...) ([]byte, error)
- func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index types.ValidatorIndex, epoch types.Epoch, ...) error
- func ComputeForkDigest(version, genesisValidatorsRoot []byte) ([4]byte, error)
- func ComputeSigningRoot(object fssz.HashRoot, domain []byte) ([32]byte, error)
- func Domain(fork *eth.Fork, epoch types.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 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 types.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 ComputeDomainVerifySigningRoot ¶
func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index types.ValidatorIndex, epoch types.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 Domain ¶
func Domain(fork *eth.Fork, epoch types.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.