merkle

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Empty32Bytes = EmptyHash.Bytes()
View Source
var EmptyHash = common.StringToHash("")
View Source
var EmptyNode = NewNode(EmptyHash, nil, nil)
View Source
var EmptySha3Hash = crypto.Keccak256Hash(EmptyHash.Bytes())

Functions

func EmptyMerkleTreeRoot

func EmptyMerkleTreeRoot(depth uint16) common.Hash

Types

type Merkle

type Merkle struct {
	Root   common.Hash
	Depth  uint16
	Leaves Nodes
	Tree   Tree
}

func NewMerkle

func NewMerkle(depth uint16, hashes []common.Hash) (*Merkle, error)

func (*Merkle) CheckMembership

func (m *Merkle) CheckMembership(hash common.Hash, proofByte []byte) error

CheckMembership prove hash exixts in the merkle tree

func (*Merkle) CreateTree

func (m *Merkle) CreateTree(leaves Nodes) common.Hash

func (*Merkle) GenerateProof

func (m *Merkle) GenerateProof(hash common.Hash) (Proof, error)

func (*Merkle) Index

func (m *Merkle) Index(hash common.Hash) int

type Node

type Node struct {
	Data  common.Hash
	Left  *Node
	Right *Node
}

func NewNode

func NewNode(data common.Hash, left, right *Node) *Node

func (*Node) Bytes

func (n *Node) Bytes() []byte

type Nodes

type Nodes []*Node

func NewNodes

func NewNodes(hashes ...common.Hash) Nodes

func (Nodes) Bytes

func (n Nodes) Bytes() (b []byte)

func (Nodes) Hashes

func (n Nodes) Hashes() []common.Hash

type Proof

type Proof []common.Hash

func NewProof

func NewProof(bs ...[]byte) (Proof, error)

func (Proof) Bytes

func (p Proof) Bytes() (b []byte)

type Tree

type Tree [][]*Node

Jump to

Keyboard shortcuts

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