inclusion

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Overview

Package inclusion contains functions to generate the blob share commitment from a given blob.

Index

Constants

This section is empty.

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 total shares used and share indexes for each blob.

func CreateCommitment

func CreateCommitment(blob *blob.Blob, merkleRootFn MerkleRootFn, subtreeRootThreshold int) ([]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, merkleRootFn MerkleRootFn, subtreeRootThreshold int) ([][]byte, error)

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 RoundUpByMultipleOf

func RoundUpByMultipleOf(cursor, v int) int

RoundUpByMultipleOf rounds cursor up to the next multiple of v. If cursor is divisible by v, then it returns cursor.

func SubTreeWidth

func SubTreeWidth(shareCount, subtreeRootThreshold int) int

SubTreeWidth returns 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. See ADR-013.

Types

type MerkleRootFn

type MerkleRootFn func([][]byte) []byte

Jump to

Keyboard shortcuts

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