merkle

package
v0.0.0-...-4496321 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyMemProof

func VerifyMemProof(memProof *MemProof, root []byte) bool

func VerifyProof

func VerifyProof(p *Proof, root []byte) bool

Types

type Branch

type Branch [][]byte

type Level

type Level []*Node

type MemProof

type MemProof struct {
	// contains filtered or unexported fields
}

func NewMemProof

func NewMemProof(branch Branch, hash []byte) *MemProof

type MemTree

type MemTree struct {
	// contains filtered or unexported fields
}

func (*MemTree) ComputeMemProof

func (t *MemTree) ComputeMemProof(idx int) *MemProof

func (*MemTree) Construct

func (t *MemTree) Construct(values [][]byte)

func (*MemTree) Empty

func (t *MemTree) Empty() bool

func (*MemTree) HashLevels

func (t *MemTree) HashLevels() []byte

func (*MemTree) Height

func (t *MemTree) Height() int

func (*MemTree) Level

func (t *MemTree) Level(height int) Level

func (*MemTree) Root

func (t *MemTree) Root() *Node

type Node

type Node struct {
	// contains filtered or unexported fields
}

func (*Node) Hash

func (nd *Node) Hash() []byte

func (*Node) IsLeaf

func (nd *Node) IsLeaf() bool

type Proof

type Proof struct {
	Branch [][]byte `json:"branch"`
	Idx    int64    `json:"idx"`
	Pos    int64    `json:"pos"`
	Value  []byte   `json:"value"`
}

func (*Proof) String

func (mp *Proof) String() string

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func NewTree

func NewTree(treeId int) *Tree

func (*Tree) AddLeaf

func (t *Tree) AddLeaf(value []byte) bool

1) Add leaves, set hashes of top-level nodes We are assuming the values are topologically sorted

func (*Tree) ComputeProof

func (t *Tree) ComputeProof(idx int64, sibling, value []byte) *Proof

Get sibling and value from graph

func (*Tree) HashLevels

func (t *Tree) HashLevels()

2) Hash lower-level nodes

func (*Tree) Init

func (t *Tree) Init(numLeaves int64)

func (*Tree) Root

func (t *Tree) Root() []byte

func (*Tree) String

func (t *Tree) String() string

Jump to

Keyboard shortcuts

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