merkle

package
v0.0.0-...-c8e9c26 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EMPTY_HASH = common.Uint256{}

Functions

This section is empty.

Types

type CompactMerkleTree

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

func NewTree

func NewTree(tree_size uint32, hashes []common.Uint256, store HashStore) *CompactMerkleTree

func (*CompactMerkleTree) Append

func (self *CompactMerkleTree) Append(leafv []byte) []common.Uint256

func (*CompactMerkleTree) AppendHash

func (self *CompactMerkleTree) AppendHash(leaf common.Uint256) []common.Uint256

func (*CompactMerkleTree) ConsistencyProof

func (self *CompactMerkleTree) ConsistencyProof(m, n uint32) []common.Uint256

func (*CompactMerkleTree) DumpStatus

func (self *CompactMerkleTree) DumpStatus()

func (*CompactMerkleTree) GetRootWithNewLeaf

func (self *CompactMerkleTree) GetRootWithNewLeaf(newLeaf common.Uint256) common.Uint256

func (*CompactMerkleTree) Hashes

func (self *CompactMerkleTree) Hashes() []common.Uint256

func (*CompactMerkleTree) InclusionProof

func (self *CompactMerkleTree) InclusionProof(m, n uint32) []common.Uint256

proof d[m] in D[0:n] m zero based index, n size 1-based

func (*CompactMerkleTree) Marshal

func (self *CompactMerkleTree) Marshal() ([]byte, error)

func (*CompactMerkleTree) Root

func (self *CompactMerkleTree) Root() common.Uint256

func (*CompactMerkleTree) TreeSize

func (self *CompactMerkleTree) TreeSize() uint32

func (*CompactMerkleTree) UnMarshal

func (self *CompactMerkleTree) UnMarshal(buf []byte) error

type FileHashStore

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

func NewFileHashStore

func NewFileHashStore(name string, tree_size uint32) (*FileHashStore, error)

func (*FileHashStore) Append

func (self *FileHashStore) Append(hash []common.Uint256) error

func (*FileHashStore) Close

func (self *FileHashStore) Close()

func (*FileHashStore) Flush

func (self *FileHashStore) Flush() error

func (*FileHashStore) GetHash

func (self *FileHashStore) GetHash(pos uint32) (common.Uint256, error)

type HashStore

type HashStore interface {
	Append(hash []common.Uint256) error
	Flush() error
	Close()
	GetHash(pos uint32) (common.Uint256, error)
}

type MemHashStore

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

func (*MemHashStore) Append

func (self *MemHashStore) Append(hash []common.Uint256) error

func (*MemHashStore) Close

func (self *MemHashStore) Close()

func (*MemHashStore) Flush

func (self *MemHashStore) Flush() error

func (*MemHashStore) GetHash

func (self *MemHashStore) GetHash(pos uint32) (common.Uint256, error)

type MerkleVerifier

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

func NewMerkleVerifier

func NewMerkleVerifier() *MerkleVerifier

func (*MerkleVerifier) VerifyConsistency

func (self *MerkleVerifier) VerifyConsistency(old_tree_size,
	new_tree_size uint32, old_root, new_root common.Uint256, proof []common.Uint256) error

func (*MerkleVerifier) VerifyLeafHashInclusion

func (self *MerkleVerifier) VerifyLeafHashInclusion(leaf_hash common.Uint256,
	leaf_index uint32, proof []common.Uint256, root_hash common.Uint256, tree_size uint32) error

func (*MerkleVerifier) VerifyLeafInclusion

func (self *MerkleVerifier) VerifyLeafInclusion(leaf []byte,
	leaf_index uint32, proof []common.Uint256, root_hash common.Uint256, tree_size uint32) error

Verify a Merkle Audit PATH.

leaf: The leaf for which the proof is provided leaf_index: Index of the leaf in the tree. proof: A list of SHA-256 hashes representing the Merkle audit path. tree_size: The size of the tree root_hash: The root hash of the tree

Returns:

nil when the proof is valid

type TreeHasher

type TreeHasher struct {
}

func (TreeHasher) HashFullTree

func (self TreeHasher) HashFullTree(leaves [][]byte) common.Uint256

func (TreeHasher) HashFullTreeWithLeafHash

func (self TreeHasher) HashFullTreeWithLeafHash(leaves []common.Uint256) common.Uint256

Jump to

Keyboard shortcuts

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