maphasher

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package maphasher provides hashing for maps.

Index

Constants

This section is empty.

Variables

View Source
var Default = New(crypto.SHA256)

Default is a SHA256 based MapHasher for maps.

Functions

func New

New creates a new merkle.MapHasher using the passed in hash function.

Types

type MapHasher

type MapHasher struct {
	crypto.Hash
	// contains filtered or unexported fields
}

MapHasher implements a sparse merkle tree hashing algorithm. For testing only. It matches the test vectors generated by other sparse map implementations, but it does not offer the full N bit security of the underlying hash function.

func (*MapHasher) BitLen

func (m *MapHasher) BitLen() int

BitLen returns the number of bits in the hash function.

func (*MapHasher) HashChildren

func (m *MapHasher) HashChildren(l, r []byte) []byte

HashChildren returns the internal Merkle tree node hash of the the two child nodes l and r. The hashed structure is NodeHashPrefix||l||r.

func (*MapHasher) HashEmpty

func (m *MapHasher) HashEmpty(treeID int64, index []byte, height int) []byte

HashEmpty returns the hash of an empty subtree of the given height, e.g. the height of 0 indicates an empty leaf. For this hasher, the result depends only on height. The treeID and index, i.e. the precise position of this subtree, are ignored.

func (*MapHasher) HashLeaf

func (m *MapHasher) HashLeaf(treeID int64, index []byte, leaf []byte) []byte

HashLeaf returns the Merkle tree leaf hash of the data passed in through leaf. The hashed structure is leafHashPrefix||leaf.

func (*MapHasher) String

func (m *MapHasher) String() string

String returns a string representation for debugging.

Jump to

Keyboard shortcuts

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