Documentation ¶
Index ¶
- func VerifyBTCProof(proofSteps []ProofStep, targetHash []byte, merkleRoot []byte) bool
- func VerifyProof(proofSteps []ProofStep, targetHash []byte, merkleRoot []byte) bool
- type MerkleTree
- func (mt *MerkleTree) AddLeaf(hash []byte)
- func (mt *MerkleTree) AddLeaves(hashes [][]byte)
- func (mt *MerkleTree) GetLeaf(index int) *Node
- func (mt *MerkleTree) GetLeafCount() int
- func (mt *MerkleTree) GetMerkleRoot() []byte
- func (mt *MerkleTree) GetProof(index int) []ProofStep
- func (mt *MerkleTree) MakeBTCTree()
- func (mt *MerkleTree) MakeTree()
- func (mt *MerkleTree) Reset()
- type Node
- type ProofStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyBTCProof ¶
VerifyBTCProof : Checks the validity of the proof generated with MakeBTCTree and returns true or false
Types ¶
type MerkleTree ¶
MerkleTree : The complete tree structure
func (*MerkleTree) AddLeaf ¶
func (mt *MerkleTree) AddLeaf(hash []byte)
AddLeaf : Adds one leaf to the tree
func (*MerkleTree) AddLeaves ¶
func (mt *MerkleTree) AddLeaves(hashes [][]byte)
AddLeaves : Adds multiple leaves to the tree
func (*MerkleTree) GetLeaf ¶
func (mt *MerkleTree) GetLeaf(index int) *Node
GetLeaf : Gets the Leaf node at a given index
func (*MerkleTree) GetLeafCount ¶
func (mt *MerkleTree) GetLeafCount() int
GetLeafCount : Returns the total number of leaves
func (*MerkleTree) GetMerkleRoot ¶
func (mt *MerkleTree) GetMerkleRoot() []byte
GetMerkleRoot : Returns the Root for this Tree
func (*MerkleTree) GetProof ¶
func (mt *MerkleTree) GetProof(index int) []ProofStep
GetProof : Returns the proof for a leaf at the given index
func (*MerkleTree) MakeBTCTree ¶
func (mt *MerkleTree) MakeBTCTree()
MakeBTCTree : Builds the tree using the given Leaves These tree will duplicate odd nodes to enforce even number on each level This is for compatability with how Bitcoin builds Merkle trees Hash operations are performed twice
func (*MerkleTree) MakeTree ¶
func (mt *MerkleTree) MakeTree()
MakeTree : Builds the tree using the given Leaves