verifiers

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 7 Imported by: 0

README

Stateless verification functionality

This package exposes functionality to do stateless checks on new blocks. With stateless checks, we mean anything that is not related to VM execution of the contained transactions.

Exposed functionality

What follows is an outline of each check exposed by this package.

CheckBlockCertificate

Checks the block's certificate for correctness. Since the block certificate contains many fields, there is a list of checks performed by this function:

  • BLS signature verification for the signatures of the first and second step
  • Committee inclusion check for the included voter bitmaps for the first and second step
  • Ensuring that the step number, included in the certificate, corresponds with the provided signatures and bitmaps

It should be noted, that the certificate checks are not performed on the genesis block. Due to the impossibility of the genesis block having an active committee (unless something was completely hardcoded), this block will not be checked. This does not pose a security risk, as the genesis block itself is also hardcoded.

CheckBlockHeader

This function performs a multitude of checks on the correctness of a block header. These checks include:

  • Making sure the block header version is up-to-date with the latest one
  • Ensuring that the block header contains the correct previous block hash, as determined by its height
  • Ensuring that the block height is correct (logically follows the previous block)
  • Checking that the timestamp is not before the previous block timestamp
  • Calculating the transaction merkle root hash, and comparing it to the one on the block for equality
CheckMultiCoinbases

Simply iterates over the transactions in the block, and makes sure there is only one transaction that has the Distribute transaction type. Note that this function does not check whether or not the Distribute transaction is in the right place.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBlockHash = errors.New("invalid block hash")

ErrInvalidBlockHash hashed set of block header fields is not equal to block.header.hash.

View Source
var ErrPrevBlockHash = errors.New("previous block hash does not equal the previous hash in the current block")

ErrPrevBlockHash previous block hash does not equal the previous hash in the current block.

Functions

func CheckBlockCertificate

func CheckBlockCertificate(provisioners user.Provisioners, blk block.Block, seed []byte) error

CheckBlockCertificate ensures that the block certificate is valid.

func CheckBlockHeader

func CheckBlockHeader(prevBlock block.Block, blk block.Block) error

CheckBlockHeader checks whether a block header is malformed. These are stateless and stateful checks. Returns nil, if all checks pass.

func CheckHash added in v0.6.0

func CheckHash(blk *block.Block) error

CheckHash ensures that provided Header.Hash is valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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