share

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Size is a system-wide size of a share, including both data and namespace GetNamespace
	Size = appconsts.ShareSize
)

Variables

View Source
var (
	MaxReservedNamespace     = Namespace(appns.MaxReservedNamespace.Bytes())
	ParitySharesNamespace    = Namespace(appns.ParitySharesNamespace.Bytes())
	TailPaddingNamespace     = Namespace(appns.TailPaddingNamespace.Bytes())
	ReservedPaddingNamespace = Namespace(appns.ReservedPaddingNamespace.Bytes())
	TxNamespace              = Namespace(appns.TxNamespace.Bytes())
	PayForBlobNamespace      = Namespace(appns.PayForBlobNamespace.Bytes())
)

Various reserved namespaces.

View Source
var (
	// DefaultRSMT2DCodec sets the default rsmt2d.Codec for shares.
	DefaultRSMT2DCodec = appconsts.DefaultCodec
)
View Source
var (
	// ErrNotAvailable is returned whenever DA sampling fails.
	ErrNotAvailable = errors.New("share: data not available")
)

Functions

func GetData

func GetData(s Share) []byte

GetData slices out data of the Share.

Types

type DataHash

type DataHash []byte

DataHash is a representation of the Root hash.

func (DataHash) String

func (dh DataHash) String() string

func (DataHash) Validate

func (dh DataHash) Validate() error

type Namespace

type Namespace []byte

Namespace represents namespace of a Share. Consists of version byte and namespace ID.

func GetNamespace

func GetNamespace(s Share) Namespace

GetNamespace slices Namespace out of the Share.

func NamespaceFromBytes

func NamespaceFromBytes(b []byte) (Namespace, error)

NamespaceFromBytes converts bytes into Namespace and validates it.

func NewBlobNamespaceV0

func NewBlobNamespaceV0(id []byte) (Namespace, error)

NewBlobNamespaceV0 takes a variable size byte slice and creates a valid version 0 Blob Namespace. The byte slice must be <= 10 bytes. If it is less than 10 bytes, it will be left padded to size 10 with 0s. Use predefined namespaces above, if non-blob namespace is needed.

func (Namespace) Equals

func (n Namespace) Equals(target Namespace) bool

Equals compares two Namespaces.

func (Namespace) ID

func (n Namespace) ID() namespace.ID

ID reports ID of the Namespace.

func (Namespace) IsAboveMax

func (n Namespace) IsAboveMax(nodeHash []byte) bool

IsAboveMax checks if the namespace is above the maximum namespace of the given hash.

func (Namespace) IsBelowMin

func (n Namespace) IsBelowMin(nodeHash []byte) bool

IsBelowMin checks if the target namespace is below the minimum namespace of the given hash.

func (Namespace) IsGreater

func (n Namespace) IsGreater(target Namespace) bool

IsGreater reports if the Namespace is greater than the target.

func (Namespace) IsGreaterOrEqualThan

func (n Namespace) IsGreaterOrEqualThan(target Namespace) bool

IsGreaterOrEqualThan reports if the Namespace is greater or equal than the target.

func (Namespace) IsLess

func (n Namespace) IsLess(target Namespace) bool

IsLess reports if the Namespace is less than the target.

func (Namespace) IsLessOrEqual

func (n Namespace) IsLessOrEqual(target Namespace) bool

IsLessOrEqual reports if the Namespace is less than the target.

func (Namespace) IsOutsideRange

func (n Namespace) IsOutsideRange(leftNodeHash, rightNodeHash []byte) bool

IsOutsideRange checks if the namespace is outside the min-max range of the given hashes.

func (Namespace) Len

func (n Namespace) Len() int

Len reports the total length of the namespace.

func (Namespace) Repeat

func (n Namespace) Repeat(t int) []Namespace

Repeat copies the Namespace t times.

func (Namespace) String

func (n Namespace) String() string

String stringifies the Namespace.

func (Namespace) ToAppNamespace

func (n Namespace) ToAppNamespace() appns.Namespace

ToAppNamespace converts the Namespace to App's definition of Namespace. TODO: Unify types between node and app

func (Namespace) ToNMT

func (n Namespace) ToNMT() namespace.ID

ToNMT converts the whole Namespace(both Version and ID parts) into NMT's namespace.ID NOTE: Once https://github.com/celestiaorg/nmt/issues/206 is closed Namespace should become NNT's type.

func (Namespace) Validate

func (n Namespace) Validate() error

Validate checks if the namespace is correct.

func (Namespace) ValidateForBlob

func (n Namespace) ValidateForBlob() error

ValidateForBlob checks if the Namespace is valid blob namespace.

func (Namespace) ValidateForData

func (n Namespace) ValidateForData() error

ValidateForData checks if the Namespace is of real/useful data.

func (Namespace) Version

func (n Namespace) Version() byte

Version reports version of the Namespace.

type NamespacedRow

type NamespacedRow struct {
	Shares []Share
	Proof  *nmt.Proof
}

NamespacedRow represents all shares with proofs within a specific namespace of a single EDS row.

type NamespacedShares

type NamespacedShares []NamespacedRow

NamespacedShares represents all shares with proofs within a specific namespace of an EDS.

type Root

Root represents root commitment to multiple Shares. In practice, it is a commitment to all the Data in a square.

type Share

type Share = []byte

Share contains the raw share data without the corresponding namespace. NOTE: Alias for the byte is chosen to keep maximal compatibility, especially with rsmt2d. Ideally, we should define reusable type elsewhere and make everyone(Core, rsmt2d, ipld) to rely on it.

Jump to

Keyboard shortcuts

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