inclusion

package
v1.0.0-rc52 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WalkLeft  = false
	WalkRight = true
)

Variables

This section is empty.

Functions

func BlobMinSquareSize

func BlobMinSquareSize(shareCount int) int

BlobMinSquareSize returns the minimum square size that can contain shareCount number of shares.

func BlobSharesUsedNonInteractiveDefaults

func BlobSharesUsedNonInteractiveDefaults(cursor, subtreeRootThreshold int, blobShareLens ...int) (sharesUsed int, indexes []uint32)

BlobSharesUsedNonInteractiveDefaults returns the number of shares used by a given set of blobs share lengths. It follows the blob share commitment rules and returns the share indexes for each blob.

func CreateCommitment

func CreateCommitment(blob *blob.Blob) ([]byte, error)

CreateCommitment generates the share commitment for a given blob. See [data square layout rationale] and [blob share commitment rules].

[data square layout rationale]: ../../specs/src/specs/data_square_layout.md [blob share commitment rules]: ../../specs/src/specs/data_square_layout.md#blob-share-commitment-rules

func CreateCommitments

func CreateCommitments(blobs []*blob.Blob) ([][]byte, error)

func FitsInSquare

func FitsInSquare(cursor, squareSize, subtreeRootThreshold int, blobShareLens ...int) (bool, int)

FitsInSquare uses the non interactive default rules to see if blobs of some lengths will fit in a square of squareSize starting at share index cursor. Returns whether the blobs fit in the square and the number of shares used by blobs. See ADR-013 and the blob share commitment rules.

../../specs/src/specs/data_square_layout.md#blob-share-commitment-rules

func GetCommitment added in v0.12.0

func GetCommitment(cacher *EDSSubTreeRootCacher, dah da.DataAvailabilityHeader, start, blobShareLen, subtreeRootThreshold int) ([]byte, error)

GetCommitment gets the share commitment for a blob in the original data square.

func MerkleMountainRangeSizes

func MerkleMountainRangeSizes(totalSize, maxTreeSize uint64) ([]uint64, error)

MerkleMountainRangeSizes returns the sizes (number of leaf nodes) of the trees in a merkle mountain range constructed for a given totalSize and maxTreeSize.

https://docs.grin.mw/wiki/chain-state/merkle-mountain-range/ https://github.com/opentimestamps/opentimestamps-server/blob/master/doc/merkle-mountain-range.md

func NextShareIndex

func NextShareIndex(cursor, blobShareLen, subtreeRootThreshold int) int

NextShareIndex determines the next index in a square that can be used. It follows the blob share commitment rules defined in ADR-013. Assumes that all args are non negative, that squareSize is a power of two and that the blob can fit in the square. The cursor is expected to be the index after the end of the previous blob.

See https://github.com/celestiaorg/celestia-app/blob/main/specs/src/specs/data_square_layout.md for more information.

func SubTreeWidth

func SubTreeWidth(shareCount, subtreeRootThreshold int) int

SubTreeWidth determines the maximum number of leaves per subtree in the share commitment over a given blob. The input should be the total number of shares used by that blob. The reasoning behind this algorithm is discussed in depth in ADR013 (celestia-app/docs/architecture/adr-013-non-interative-default-rules-for-zero-padding).

Types

type EDSSubTreeRootCacher

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

EDSSubTreeRootCacher caches the inner nodes for each row so that we can traverse it later to check for blob inclusion. NOTE: Currently this has to use a leaky abstraction (see docs on counter field below), and is not threadsafe, but with a future refactor, we could simply read from rsmt2d and not use the tree constructor which would fix both of these issues.

func NewSubtreeCacher

func NewSubtreeCacher(squareSize uint64) *EDSSubTreeRootCacher

func (*EDSSubTreeRootCacher) Constructor

func (stc *EDSSubTreeRootCacher) Constructor(axis rsmt2d.Axis, axisIndex uint) rsmt2d.Tree

Constructor fullfills the rsmt2d.TreeCreatorFn by keeping a pointer to the cache and embedding it as a nmt.NodeVisitor into a new wrapped nmt.

type WalkInstruction

type WalkInstruction bool

WalkInstruction wraps the bool type to indicate the direction that should be used while traversing a binary tree

Jump to

Keyboard shortcuts

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