package hasher

import "github.com/google/trillian/merkle/coniks/hasher"

Package hasher provides CONIKS hashing for maps.

Index

Variables

var (

	// Default is the standard CONIKS hasher.
	Default = New(crypto.SHA512_256)
)

Domain separation prefixes

Types

type Hasher

type Hasher struct {
	crypto.Hash
}

Hasher implements the sparse merkle tree hashing algorithm specified in the CONIKS paper.

func New

func New(h crypto.Hash) *Hasher

New creates a new hashers.TreeHasher using the passed in hash function.

func (*Hasher) BitLen

func (m *Hasher) BitLen() int

BitLen returns the number of bits in the hash function.

func (*Hasher) EmptyRoot

func (m *Hasher) EmptyRoot() []byte

EmptyRoot returns the root of an empty tree.

func (*Hasher) HashChildren

func (m *Hasher) 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 H(l || r).

func (*Hasher) HashEmpty

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

HashEmpty returns the hash of an empty subtree of the given height at the position defined by the BitLen()-height most significant bits of the given index. Note that a height of 0 indicates a leaf.

func (*Hasher) HashLeaf

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

HashLeaf calculate the merkle tree leaf value: H(Identifier || treeID || depth || index || dataHash)

Source Files

coniks.go

Version
v1.3.13
Published
Feb 16, 2021
Platform
js/wasm
Imports
5 packages
Last checked
3 hours ago

Tools for package owners.