Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrIndexOutOfBounds = errors.New("merkle tree data index out of bounds")
View Source
var ErrNilData = errors.New("merkle tree input data is nil")
Functions ¶
func EvalMerklePath ¶
EvalMerklePath returns root hash calculated from the given leaf and path items
func SecondaryHash ¶ added in v0.1.1
SecondaryHash returns root merkle hash calculated from given txs
Types ¶
type ByteHasher ¶
type ByteHasher struct {
Val []byte
}
ByteHasher helper struct to satisfy Data interface
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
func New ¶
func New(hashAlgorithm crypto.Hash, data []Data) (*MerkleTree, error)
New creates a new canonical Merkle Tree.
func (*MerkleTree) GetMerklePath ¶
func (s *MerkleTree) GetMerklePath(leafIdx int) ([]*PathItem, error)
GetMerklePath extracts the merkle path from the given leaf to root.
func (*MerkleTree) GetRootHash ¶
func (s *MerkleTree) GetRootHash() []byte
GetRootHash returns the root Hash of the Merkle Tree.
func (*MerkleTree) PrettyPrint ¶
func (s *MerkleTree) PrettyPrint() string
PrettyPrint returns human readable string representation of the Merkle Tree.
type PathItem ¶
type PathItem struct { Hash []byte DirectionLeft bool // true - left from parent, false - right from parent }
PathItem helper struct for proof extraction, contains Hash and Direction from parent node
func SecondaryChain ¶ added in v0.1.1
func SecondaryChain(txs []txsystem.GenericTransaction, txIdx int, hashAlgorithm crypto.Hash) ([]*PathItem, error)
SecondaryChain returns hash chain for a secondary transaction based on list of secondary transactions
Click to show internal directories.
Click to hide internal directories.