merkle

package
v1.0.0-beta.15....-0de5f12 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package merkle provides functions for creating and validating MAM compatible Merkle trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MerkleBranch

func MerkleBranch(tree Trits, siblings Trits, treeLength, treeDepth, leafIndex, leafCount uint64) (Trits, error)

MerkleBranch creates the Merkle branch to generate back root from index.

tree is the Merkle tree - Must be allocated
siblings is the siblings of the indexed node - Must be allocated
treeLength is the length of the tree
treeDepth is the depth of the tree
leafIndex is the index of the leaf to start the branch from
leafCount is the number of leaves of the tree

func MerkleCreate

func MerkleCreate(baseSize uint64, seed Trytes, offset uint64, security SecurityLevel, spongeFunc ...sponge.SpongeFunction) (Trits, error)

MerkleCreate creates a Merkle tree.

baseSize is the base size of the tree, e.g. the number of leaves
seed is the seed used to generate addresses - Not sent over the network
offset is the offset used to generate addresses
security is the security used to generate addresses
spongeFunc is the optional sponge function to use

func MerkleDepth

func MerkleDepth(nodeCount uint64) (depth uint64)

MerkleDepth computes the depth of a Merkle tree.

nodeCount is the number of nodes of the tree

func MerkleLeafIndex

func MerkleLeafIndex(leafIndex, leafCount uint64) uint64

MerkleLeafIndex computes the actual site index of a leaf.

leafIndex is the leaf index
leafCount is the number of leaves

func MerkleNodeIndex

func MerkleNodeIndex(depth, width, treeDepth uint64) uint64

MerkleNodeIndex indexes a given node in the tree.

depth is the depth of the node, counting from root
width is the width of the node, counting from left
treeDepth is the depth of whole tree

func MerkleRoot

func MerkleRoot(hash Trits, siblings Trits, siblingsNumber uint64, leafIndex uint64, spongeFunc ...sponge.SpongeFunction) (Trits, error)

MerkleRoot generates a Merkle root from a hash and his siblings,

hash is the hash
siblings is the hash siblings
siblingsNumber is the number of siblings
leafIndex is the node index of the hash
spongeFunc is the optional sponge function to use

func MerkleSize

func MerkleSize(leafCount uint64) uint64

MerkleSize computes the size of a Merkle tree, e.g. its node number.

leafCount is the number of leaves of the tree

Types

This section is empty.

Jump to

Keyboard shortcuts

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