certificate

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyCommitters = errors.New("too many committers in certificate")
	ErrTooManyAbsentees  = errors.New("too many absentees in certificate")
)
View Source
var Required1FP1Power = func(totalPower int64) int64 {
	f := faultyPower(totalPower)
	p := (1 * f) + 1

	return p
}
View Source
var Required2FP1Power = func(power int64) int64 {
	f := faultyPower(power)
	p := (2 * f) + 1

	return p
}
View Source
var Required3FP1Power = func(power int64) int64 {
	f := faultyPower(power)
	p := (3 * f) + 1

	return p
}

Functions

func Has1FP1Power added in v1.10.0

func Has1FP1Power(totalPower, signedPower int64) bool

Has1FP1Power checks whether the signed power is greater than or equal to f+1, where f is the maximum faulty power.

func Has2FP1Power added in v1.10.0

func Has2FP1Power(totalPower, signedPower int64) bool

Has2FP1Power checks whether the signed power is greater than or equal to 2f+1, where f is the maximum faulty power.

func Has3FP1Power added in v1.10.0

func Has3FP1Power(totalPower, signedPower int64) bool

Has3FP1Power checks whether the signed power is greater than or equal to 3f+1, where f is the maximum faulty power.

Types

type BasicCheckError

type BasicCheckError struct {
	Reason string
}

BasicCheckError is returned when the basic check on the certificate fails.

func (BasicCheckError) Error

func (e BasicCheckError) Error() string

type Certificate

type Certificate struct {
	// contains filtered or unexported fields
}

Certificate represents a base structure for both Certificate and Certificate. As a Certificate, it verifies if a block is signed by a majority of validators. As a Certificate, it checks whether a majority of validators have voted in the consensus step.

func NewCertificate

func NewCertificate(height uint32, round int16) *Certificate

NewCertificate creates a new Certificate instance.

func (*Certificate) Absentees

func (cert *Certificate) Absentees() []int32

func (*Certificate) AddSignature

func (cert *Certificate) AddSignature(valNum int32, sig *bls.Signature)

AddSignature adds a new signature to the certificate. It does not check the validity of the signature. The caller should ensure that the signature is valid.

func (*Certificate) BasicCheck

func (cert *Certificate) BasicCheck() error

func (*Certificate) Clone

func (cert *Certificate) Clone() *Certificate

func (*Certificate) Committers

func (cert *Certificate) Committers() []int32

func (*Certificate) Decode

func (cert *Certificate) Decode(r io.Reader) error

func (*Certificate) Encode

func (cert *Certificate) Encode(w io.Writer) error

func (*Certificate) Hash

func (cert *Certificate) Hash() hash.Hash

func (*Certificate) Height

func (cert *Certificate) Height() uint32

func (*Certificate) MarshalCBOR

func (cert *Certificate) MarshalCBOR() ([]byte, error)

func (*Certificate) Round

func (cert *Certificate) Round() int16

func (*Certificate) SerializeSize

func (cert *Certificate) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the block.

func (*Certificate) SetSignature added in v1.10.0

func (cert *Certificate) SetSignature(committers, absentees []int32, signature *bls.Signature)

func (*Certificate) SignBytesCPDecided added in v1.10.0

func (cert *Certificate) SignBytesCPDecided(blockHash hash.Hash, cpRound int16, cpValue byte) []byte

func (*Certificate) SignBytesCPMainVote added in v1.10.0

func (cert *Certificate) SignBytesCPMainVote(blockHash hash.Hash, cpRound int16, cpValue byte) []byte

func (*Certificate) SignBytesCPPreVote added in v1.10.0

func (cert *Certificate) SignBytesCPPreVote(blockHash hash.Hash, cpRound int16, cpValue byte) []byte

func (*Certificate) SignBytesPrecommit added in v1.10.0

func (cert *Certificate) SignBytesPrecommit(blockHash hash.Hash) []byte

func (*Certificate) SignBytesPrepare added in v1.10.0

func (cert *Certificate) SignBytesPrepare(blockHash hash.Hash) []byte

func (*Certificate) Signature

func (cert *Certificate) Signature() *bls.Signature

func (*Certificate) UnmarshalCBOR

func (cert *Certificate) UnmarshalCBOR(bs []byte) error

func (*Certificate) ValidateCPMainVote added in v1.10.0

func (cert *Certificate) ValidateCPMainVote(validators []*validator.Validator,
	blockHash hash.Hash, cpRound int16, cpValue byte,
) error

func (*Certificate) ValidateCPPreVote added in v1.10.0

func (cert *Certificate) ValidateCPPreVote(validators []*validator.Validator,
	blockHash hash.Hash, cpRound int16, cpValue byte,
) error

func (*Certificate) ValidatePrecommit added in v1.10.0

func (cert *Certificate) ValidatePrecommit(validators []*validator.Validator,
	blockHash hash.Hash,
) error

func (*Certificate) ValidatePrepare added in v1.10.0

func (cert *Certificate) ValidatePrepare(validators []*validator.Validator,
	blockHash hash.Hash,
) error

type InsufficientPowerError

type InsufficientPowerError struct {
	SignedPower   int64
	RequiredPower int64
}

InsufficientPowerError is returned when the accumulated power does not meet the required threshold.

func (InsufficientPowerError) Error

func (e InsufficientPowerError) Error() string

type RequiredPowerFn added in v1.10.0

type RequiredPowerFn func(int64) int64

type UnexpectedCommittersError

type UnexpectedCommittersError struct {
	Committers []int32
}

UnexpectedCommittersError is returned when the list of committers does not match the expectations.

func (UnexpectedCommittersError) Error

func (UnexpectedCommittersError) Is

func (e UnexpectedCommittersError) Is(target error) bool

Jump to

Keyboard shortcuts

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