Documentation ¶
Overview ¶
Package rsmt2d implements the two dimensional Reed-Solomon merkle tree data availability scheme.
Index ¶
- Constants
- Variables
- func NewLeoRSCodec() *leoRSCodec
- type Axis
- type Codec
- type DefaultTree
- type ErrByzantineData
- type ExtendedDataSquare
- func (eds *ExtendedDataSquare) Col(y uint) [][]byte
- func (eds *ExtendedDataSquare) ColRoots() [][]byte
- func (ds ExtendedDataSquare) Flattened() [][]byte
- func (ds ExtendedDataSquare) GetCell(x uint, y uint) []byte
- func (eds *ExtendedDataSquare) MarshalJSON() ([]byte, error)
- func (eds *ExtendedDataSquare) Repair(rowRoots [][]byte, colRoots [][]byte) error
- func (eds *ExtendedDataSquare) Row(x uint) [][]byte
- func (eds *ExtendedDataSquare) RowRoots() [][]byte
- func (ds ExtendedDataSquare) SetCell(x uint, y uint, newChunk []byte)
- func (eds *ExtendedDataSquare) UnmarshalJSON(b []byte) error
- func (eds *ExtendedDataSquare) Width() uint
- type SquareIndex
- type Tree
- type TreeConstructorFn
Constants ¶
const ( // Leopard is a codec that was originally implemented in the C++ library // https://github.com/catid/leopard. rsmt2d uses a Go port of the C++ // library in https://github.com/klauspost/reedsolomon. The Leopard codec // uses 8-bit leopard for shards less than or equal to 256. The Leopard // codec uses 16-bit leopard for shards greater than 256. Leopard = "Leopard" )
Variables ¶
var ErrUnevenChunks = errors.New("non-nil chunks not all of equal size")
ErrUnevenChunks is thrown when non-nil chunks are not all of equal size.
var ErrUnrepairableDataSquare = errors.New("failed to solve data square")
ErrUnrepairableDataSquare is thrown when there is insufficient chunks to repair the square.
Functions ¶
func NewLeoRSCodec ¶ added in v0.7.0
func NewLeoRSCodec() *leoRSCodec
Types ¶
type Codec ¶
type Codec interface { // Encode encodes original data, automatically extracting share size. // There must be no missing shares. Only returns parity shares. Encode(data [][]byte) ([][]byte, error) // Decode decodes sparse original + parity data, automatically extracting share size. // Missing shares must be nil. Returns original shares only. Decode(data [][]byte) ([][]byte, error) // contains filtered or unexported methods }
type DefaultTree ¶
type DefaultTree struct { *merkletree.Tree // contains filtered or unexported fields }
func (*DefaultTree) Push ¶
func (d *DefaultTree) Push(data []byte) error
func (*DefaultTree) Root ¶
func (d *DefaultTree) Root() ([]byte, error)
type ErrByzantineData ¶ added in v0.5.0
ErrByzantineData is thrown when a repaired row or column does not match the expected row or column Merkle root.
func (*ErrByzantineData) Error ¶ added in v0.5.0
func (e *ErrByzantineData) Error() string
type ExtendedDataSquare ¶
type ExtendedDataSquare struct {
// contains filtered or unexported fields
}
ExtendedDataSquare represents an extended piece of data.
func ComputeExtendedDataSquare ¶
func ComputeExtendedDataSquare( data [][]byte, codec Codec, treeCreatorFn TreeConstructorFn, ) (*ExtendedDataSquare, error)
ComputeExtendedDataSquare computes the extended data square for some chunks of data.
func ImportExtendedDataSquare ¶
func ImportExtendedDataSquare( data [][]byte, codec Codec, treeCreatorFn TreeConstructorFn, ) (*ExtendedDataSquare, error)
ImportExtendedDataSquare imports an extended data square, represented as flattened chunks of data.
func (*ExtendedDataSquare) Col ¶
func (eds *ExtendedDataSquare) Col(y uint) [][]byte
Col returns a column slice. This slice is a copy of the internal column slice.
func (*ExtendedDataSquare) ColRoots ¶
func (eds *ExtendedDataSquare) ColRoots() [][]byte
ColRoots returns the Merkle roots of all the columns in the square.
func (ExtendedDataSquare) Flattened ¶ added in v0.7.0
func (ds ExtendedDataSquare) Flattened() [][]byte
Flattened returns the concatenated rows of the data square.
func (*ExtendedDataSquare) MarshalJSON ¶ added in v0.8.0
func (eds *ExtendedDataSquare) MarshalJSON() ([]byte, error)
func (*ExtendedDataSquare) Repair ¶ added in v0.5.0
func (eds *ExtendedDataSquare) Repair( rowRoots [][]byte, colRoots [][]byte, ) error
Repair attempts to repair an incomplete extended data square (EDS), comparing repaired rows and columns against expected Merkle roots.
Input ¶
Missing shares must be nil.
Output ¶
The EDS is modified in-place. If repairing is successful, the EDS will be complete. If repairing is unsuccessful, the EDS will be the most-repaired prior to the Byzantine row or column being repaired, and the Byzantine row or column prior to repair is returned in the error with missing shares as nil.
func (*ExtendedDataSquare) Row ¶
func (eds *ExtendedDataSquare) Row(x uint) [][]byte
Row returns a row slice. This slice is a copy of the internal row slice.
func (*ExtendedDataSquare) RowRoots ¶
func (eds *ExtendedDataSquare) RowRoots() [][]byte
RowRoots returns the Merkle roots of all the rows in the square.
func (ExtendedDataSquare) SetCell ¶ added in v0.6.0
SetCell sets a specific cell. Cell to set must be `nil`. Panics if attempting to set a cell that is not `nil`.
func (*ExtendedDataSquare) UnmarshalJSON ¶ added in v0.8.0
func (eds *ExtendedDataSquare) UnmarshalJSON(b []byte) error
func (*ExtendedDataSquare) Width ¶
func (eds *ExtendedDataSquare) Width() uint
Width returns the width of the square.
type SquareIndex ¶
type SquareIndex struct {
Axis, Cell uint
}
SquareIndex contains all information needed to identify the cell that is being pushed
type TreeConstructorFn ¶
TreeConstructorFn creates a fresh Tree instance to be used as the Merkle tree inside of rsmt2d.