merkle

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: BSD-2-Clause Imports: 4 Imported by: 1

Documentation

Overview

package merkle provides hashing operations that can be used to verify a Sigsum log's Merkle tree. The exact hash strategy is defined in RFC 6962.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashInteriorNode

func HashInteriorNode(left, right *crypto.Hash) crypto.Hash

func HashLeafNode

func HashLeafNode(leaf []byte) crypto.Hash

func VerifyConsistency

func VerifyConsistency(oldSize, newSize uint64, oldRoot, newRoot *crypto.Hash, path []crypto.Hash) error

VerifyConsistency verifies that a Merkle tree is consistent. The algorithm used is in RFC 9162, §2.1.4.2. It is the same proof technique as RFC 6962.

func VerifyInclusion

func VerifyInclusion(leaf *crypto.Hash, index, size uint64, root *crypto.Hash, path []crypto.Hash) error

VerifyInclusion verifies that something is in a Merkle tree. The algorithm used is in RFC 9162, §2.1.3.2. It is the same proof technique as RFC 6962.

Types

type Prefix

type Prefix uint8
const (
	PrefixLeafNode Prefix = iota
	PrefixInteriorNode
)

type Tree added in v0.1.8

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

Represents a tree of leaf hashes. Not concurrency safe; needs external synchronization.

func NewTree added in v0.1.8

func NewTree() Tree

func (*Tree) AddLeafHash added in v0.1.8

func (t *Tree) AddLeafHash(leafHash *crypto.Hash) bool

Returns true if added, false for duplicates.

func (*Tree) GetLeafIndex added in v0.1.8

func (t *Tree) GetLeafIndex(leafHash *crypto.Hash) (uint64, error)

func (*Tree) GetRootHash added in v0.1.8

func (t *Tree) GetRootHash() crypto.Hash

func (*Tree) ProveConsistency added in v0.1.8

func (t *Tree) ProveConsistency(m, n uint64) ([]crypto.Hash, error)

func (*Tree) ProveInclusion added in v0.1.8

func (t *Tree) ProveInclusion(index, size uint64) ([]crypto.Hash, error)

func (*Tree) Size added in v0.1.8

func (t *Tree) Size() uint64

Jump to

Keyboard shortcuts

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