signing

package
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: GPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const DomainByteLength = 4

DomainByteLength length of domain byte array.

View Source
const ForkVersionByteLength = 4

ForkVersionByteLength length of fork version byte array.

Variables

View Source
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 BlockSignatureSet

func BlockSignatureSet(pub, signature, domain []byte, rootFunc func() ([32]byte, error)) (*bls.SignatureSet, error)

BlockSignatureSet retrieves the relevant signature, message and pubkey data from a block and collating it into a signature set 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

func ComputeForkDigest(version, genesisValidatorsRoot []byte) ([4]byte, error)

ComputeForkDigest returns the fork for the current version and genesis validator 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

func ComputeSigningRoot(object fssz.HashRoot, domain []byte) ([32]byte, error)

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

func VerifyBlockSigningRoot(pub, signature, domain []byte, rootFunc func() ([32]byte, error)) error

VerifyBlockSigningRoot verifies the signing root of a block given its public key, signature and domain.

func VerifySigningRoot

func VerifySigningRoot(obj fssz.HashRoot, pub, signature, domain []byte) error

VerifySigningRoot verifies the signing root of an object given its public key, signature and domain.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL