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 ToProtobuf ¶
func ToProtobuf(srcPathItmes []*PathItem) *proof.BlockMerkleProof
ToProtobuf utility function that converts []mt.PathItem to proof.BlockMerkleProof
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 FromProtobuf ¶
func FromProtobuf(proof *proof.BlockMerkleProof) []*PathItem
FromProtobuf utility function that converts proof.BlockMerkleProof to []mt.PathItem
Click to show internal directories.
Click to hide internal directories.