byzantine

package
v0.18.0-rc37 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BadEncoding fraud.ProofType = "badencoding" + version
)

Variables

This section is empty.

Functions

func CreateBadEncodingProof

func CreateBadEncodingProof(
	hash []byte,
	height uint64,
	errByzantine *ErrByzantine,
) fraud.Proof[*header.ExtendedHeader]

CreateBadEncodingProof creates a new Bad Encoding Fraud Proof that should be propagated through network. The fraud proof will contain shares that did not pass verification and their relevant Merkle proofs.

func NewErrByzantine

func NewErrByzantine(
	ctx context.Context,
	bStore blockstore.Blockstore,
	roots *share.AxisRoots,
	errByz *rsmt2d.ErrByzantineData,
) error

NewErrByzantine creates new ErrByzantine from rsmt2d error. If error happens during proof collection, it terminates the process with os.Exit(1).

func ProtoToProof

func ProtoToProof(protoProof *nmt_pb.Proof) nmt.Proof

Types

type BadEncodingProof

type BadEncodingProof struct {
	BlockHeight uint64
	// ShareWithProof contains all shares from row or col.
	// Shares that did not pass verification in rsmt2d will be nil.
	// For non-nil shares MerkleProofs are computed.
	Shares []*ShareWithProof
	// Index represents the row/col index where ErrByzantineRow/ErrByzantineColl occurred.
	Index uint32
	// Axis represents the axis that verification failed on.
	Axis rsmt2d.Axis
	// contains filtered or unexported fields
}

func (*BadEncodingProof) HeaderHash

func (p *BadEncodingProof) HeaderHash() []byte

HeaderHash returns block hash.

func (*BadEncodingProof) Height

func (p *BadEncodingProof) Height() uint64

Height returns block height.

func (*BadEncodingProof) MarshalBinary

func (p *BadEncodingProof) MarshalBinary() ([]byte, error)

MarshalBinary converts BadEncodingProof to binary.

func (*BadEncodingProof) Type

func (p *BadEncodingProof) Type() fraud.ProofType

Type returns type of fraud proof.

func (*BadEncodingProof) UnmarshalBinary

func (p *BadEncodingProof) UnmarshalBinary(data []byte) error

UnmarshalBinary converts binary to BadEncodingProof.

func (*BadEncodingProof) Validate

func (p *BadEncodingProof) Validate(hdr *header.ExtendedHeader) error

Validate ensures that fraud proof is correct. Validate checks that provided Merkle Proofs correspond to the shares, rebuilds bad row or col from received shares, computes Merkle Root and compares it with block's Merkle Root.

type ErrByzantine

type ErrByzantine struct {
	Index  uint32
	Shares []*ShareWithProof
	Axis   rsmt2d.Axis
}

ErrByzantine is a thrown when recovered data square is not correct (merkle proofs do not match parity erasure-coding data).

It is converted from rsmt2d.ByzantineRow/Col + Merkle Proof for each share.

func (*ErrByzantine) Error

func (e *ErrByzantine) Error() string

type ShareWithProof

type ShareWithProof struct {
	// Share is a full data including namespace
	libshare.Share
	// Proof is a Merkle Proof of current share
	Proof *nmt.Proof
	// Axis is a proof axis
	Axis rsmt2d.Axis
}

ShareWithProof contains data with corresponding Merkle Proof

func GetShareWithProof added in v0.14.0

func GetShareWithProof(
	ctx context.Context,
	bGetter blockservice.BlockGetter,
	roots *share.AxisRoots,
	share libshare.Share,
	axisType rsmt2d.Axis, axisIdx, shrIdx int,
) (*ShareWithProof, error)

GetShareWithProof attempts to get a share with proof for the given share. It first tries to get a row proof and if that fails or proof is invalid, it tries to get a column proof.

func ProtoToShare

func ProtoToShare(protoShares []*pb.Share) ([]*ShareWithProof, error)

func (*ShareWithProof) ShareWithProofToProto

func (s *ShareWithProof) ShareWithProofToProto() *pb.Share

func (*ShareWithProof) Validate

func (s *ShareWithProof) Validate(roots *share.AxisRoots, axisType rsmt2d.Axis, axisIdx, shrIdx int) bool

Validate validates inclusion of the share under the given root CID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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