csmt

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirLeft  = 1
	DirRight = 2
)

directions

Variables

This section is empty.

Functions

This section is empty.

Types

type CSMT

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

CSMT is Compact Sparse Merkle Tree It implements interface SMT

func (*CSMT) GetProof

func (tree *CSMT) GetProof(key *Key) Proof

GetProof gets the proof for key

func (*CSMT) GetRootHash

func (tree *CSMT) GetRootHash() *Hash

GetRootHash implements interface SMT

func (*CSMT) Insert

func (tree *CSMT) Insert(leafHash *Hash) error

Insert implements interface SMT

type Hash

type Hash = Key

Hash is the hash type of a CSMT

type InnerNode

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

InnerNode is the non-leaf node

func NewInnerNode

func NewInnerNode(hash Hash, left Node, right Node) InnerNode

NewInnerNode constructs a new InnerNode

func (InnerNode) GetHash

func (node InnerNode) GetHash() *Hash

GetHash gets the hash of the node.

func (InnerNode) GetKey

func (node InnerNode) GetKey() *Key

GetKey gets the key of the node.

func (InnerNode) GetLeft

func (node InnerNode) GetLeft() Node

GetLeft returns the left child node

func (InnerNode) GetRight

func (node InnerNode) GetRight() Node

GetRight returns the right child node

func (InnerNode) IsLeaf

func (node InnerNode) IsLeaf() bool

IsLeaf implements Node

type Key

type Key = chainhash.Hash

Key is the key type of a CSMT

type LeafNode

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

LeafNode is the leaf node

func NewLeafNode

func NewLeafNode(key *Key, hash *Hash) LeafNode

NewLeafNode constructs a new LeafNode

func (LeafNode) GetHash

func (node LeafNode) GetHash() *Hash

GetHash gets the hash of the node.

func (LeafNode) GetKey

func (node LeafNode) GetKey() *Key

GetKey gets the key of the node.

func (LeafNode) IsLeaf

func (node LeafNode) IsLeaf() bool

IsLeaf implements Node

type MembershipProof

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

MembershipProof is a Proof for membership

func (MembershipProof) IsMembershipProof

func (p MembershipProof) IsMembershipProof() bool

IsMembershipProof implements Proof

func (MembershipProof) VerifyHash

func (p MembershipProof) VerifyHash(hash *Hash, rootHash *Hash, calculator NodeHashFunction) bool

VerifyHash verifies if a hash is valid

func (MembershipProof) VerifyHashInTree

func (p MembershipProof) VerifyHashInTree(hash *Hash, tree *CSMT) bool

VerifyHashInTree verifies if a hash is valid in a CSMT

type MembershipProofEntry

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

MembershipProofEntry is the entry in a MembershipProof

type Node

type Node interface {
	GetKey() *Key
	GetHash() *Hash
	IsLeaf() bool
}

Node is the interface of a node

type NodeHashFunction

type NodeHashFunction func(*Hash, *Hash) Hash

NodeHashFunction computes the hash for the children for a inner node

type NonMembershipProof

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

NonMembershipProof is a Proof for non-membership

func (NonMembershipProof) IsMembershipProof

func (p NonMembershipProof) IsMembershipProof() bool

IsMembershipProof implements Proof

type Proof

type Proof interface {
	IsMembershipProof() bool
}

Proof represents the proof interface

type SMT

type SMT interface {
	GetRootHash() *Hash
	Insert(leafHash *Hash) error
	GetProof(key *Key) Proof
}

SMT is Sparse Merkle Tree

Jump to

Keyboard shortcuts

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