Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConstructor ¶ added in v0.9.0
func NewConstructor(squareSize uint64, opts ...nmt.Option) rsmt2d.TreeConstructorFn
NewConstructor creates a tree constructor function as required by rsmt2d to calculate the data root. It creates that tree using the wrapper.ErasuredNamespacedMerkleTree.
Types ¶
type ErasuredNamespacedMerkleTree ¶
type ErasuredNamespacedMerkleTree struct {
// contains filtered or unexported fields
}
ErasuredNamespacedMerkleTree wraps NamespaceMerkleTree to conform to the rsmt2d.Tree interface while also providing the correct namespaces to the underlying NamespaceMerkleTree. It does this by adding the already included namespace to the first half of the tree, and then uses the parity namespace ID for each share pushed to the second half of the tree. This allows for the namespaces to be included in the erasure data, while also keeping the nmt library sufficiently general
func NewErasuredNamespacedMerkleTree ¶
func NewErasuredNamespacedMerkleTree(squareSize uint64, axisIndex uint, options ...nmt.Option) ErasuredNamespacedMerkleTree
NewErasuredNamespacedMerkleTree creates a new ErasuredNamespacedMerkleTree with an underlying NMT of namespace size `appconsts.NamespaceSize` and with `ignoreMaxNamespace=true`. axisIndex is the index of the row or column that this tree is committing to. squareSize must be greater than zero.
func (*ErasuredNamespacedMerkleTree) ProveRange ¶ added in v1.0.0
func (w *ErasuredNamespacedMerkleTree) ProveRange(start, end int) (nmt.Proof, error)
ProveRange returns a Merkle range proof for the leaf range [start, end] where `end` is non-inclusive.
func (*ErasuredNamespacedMerkleTree) Push ¶
func (w *ErasuredNamespacedMerkleTree) Push(data []byte) error
Push adds the provided data to the underlying NamespaceMerkleTree, and automatically uses the first DefaultNamespaceIDLen number of bytes as the namespace unless the data pushed to the second half of the tree. Fulfills the rsmt.Tree interface. NOTE: panics if an error is encountered while pushing or if the tree size is exceeded.
func (*ErasuredNamespacedMerkleTree) Root ¶
func (w *ErasuredNamespacedMerkleTree) Root() ([]byte, error)
Root fulfills the rsmt.Tree interface by generating and returning the underlying NamespaceMerkleTree Root.
func (*ErasuredNamespacedMerkleTree) SetTree ¶ added in v1.0.0
func (w *ErasuredNamespacedMerkleTree) SetTree(tree Tree)
SetTree sets the underlying tree to the provided tree. This is used for testing purposes only.
type Tree ¶ added in v1.0.0
type Tree interface { Root() ([]byte, error) Push(namespacedData namespace.PrefixedData) error ProveRange(start, end int) (nmt.Proof, error) }
Tree is an interface that wraps the methods of the underlying NamespaceMerkleTree that are used by ErasuredNamespacedMerkleTree. This interface is mainly used for testing. It is not recommended to use this interface by implementing a different implementation.