Documentation ¶
Index ¶
- type Builder
- type File
- type Hash
- type Leaf
- type Path
- type Proof
- type Tree
- func (t *Tree) AddPathToProof(proof *anchor.AnchorProof, key string, label string) (*anchor.AnchorProof, error)
- func (t *Tree) AddProof(proof *anchor.AnchorProof)
- func (t *Tree) Export(path string) error
- func (t *Tree) GetAlgorithm() Hash
- func (t *Tree) GetLeaf(key string) *Leaf
- func (t *Tree) GetLeaves() []*Leaf
- func (t *Tree) GetLevel(level int) []string
- func (t *Tree) GetLevels() [][]string
- func (t *Tree) GetPath(key string) []*Path
- func (t *Tree) GetRoot() string
- func (t *Tree) NDepth() int
- func (t *Tree) NLeaves() int
- func (t *Tree) NLevels() int
- func (t *Tree) NNodes() int
- func (t *Tree) Verify(expected string) bool
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder represents a merkle tree builder.
func NewBuilder ¶
NewBuilder creates a new merkle tree builder.
func (*Builder) Add ¶
Add adds data to the builder. Whatever data is passed here will be hashed with the algorithm specified in the builder.
func (*Builder) Description ¶
Description sets the description to the final tree.
type File ¶
type File struct { Algorithm string `json:"algorithm"` // algorithm used to construct tree Proofs []*anchor.AnchorProof `json:"proofs"` // any associated tree proofs Data [][]string `json:"data"` // the tree data }
File is a complete representation of a merkle tree and it's related data.
type Path ¶
type Path struct { L string `json:"l,omitempty"` // the left leaf R string `json:"r,omitempty"` // the right leaf }
Path represents a merkle path. Either L or R will be populated so the final hash can be recalculated.
type Proof ¶
type Proof interface { // Metadata provides information about the anchoring. Metadata() map[string]interface{} // Data is the actual receipt. Data() interface{} }
func FromAnchorProof ¶
type Tree ¶
type Tree struct { // Algorithm used to perform tree hashing functions. Algorithm Hash // An array of proofs submitted for this tree. Proofs []*anchor.AnchorProof // The two-dimensional array of tree data, starting from the leaves (tree[0]) all the way // to the root (tree[tree.length - 1]) Layers [][]string }
Tree represents a single Merkle tree.
func NewTree ¶
func NewTree(algorithm Hash, proofs []*anchor.AnchorProof, layers [][]string) *Tree
NewTree creates a new Merkle Tree.
func NewTreeFromFile ¶
NewTreeFromFile creates a new tree from an existing file.
func (*Tree) AddPathToProof ¶
func (t *Tree) AddPathToProof(proof *anchor.AnchorProof, key string, label string) (*anchor.AnchorProof, error)
func (*Tree) AddProof ¶
func (t *Tree) AddProof(proof *anchor.AnchorProof)
AddProof adds a proof for this tree.
func (*Tree) GetAlgorithm ¶
GetAlgorithm returns the tree's hashing algorithm.
func (*Tree) GetPath ¶
GetPath returns the path from a specific leaf all the way to the root hash. leaf must be the matching leaf value (hashed).