package logverifier

import "github.com/google/trillian/merkle/logverifier"

Package logverifier implements proof verificaion helpers for Merkle trees.

Deprecated: This package is superseded by the corresponding functionality in https://github.com/transparency-dev/merkle. It will be removed in future releases of Trillian.

Index

Types

type LogVerifier

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

LogVerifier verifies inclusion and consistency proofs for append only logs.

func New

func New(hasher hashers.LogHasher) LogVerifier

New returns a new LogVerifier for a tree.

func (LogVerifier) RootFromInclusionProof

func (v LogVerifier) RootFromInclusionProof(leafIndex, treeSize int64, proof [][]byte, leafHash []byte) ([]byte, error)

RootFromInclusionProof calculates the expected tree root given the proof and leaf. leafIndex starts at 0. treeSize is the number of nodes in the tree. proof is an array of neighbor nodes from the bottom to the root.

func (LogVerifier) VerifiedPrefixHashFromInclusionProof

func (v LogVerifier) VerifiedPrefixHashFromInclusionProof(
	subSize, size int64,
	proof [][]byte, root []byte, leafHash []byte,
) ([]byte, error)

VerifiedPrefixHashFromInclusionProof calculates a root hash over leaves [0..subSize), based on the inclusion |proof| and |leafHash| for a leaf at index |subSize-1| in a tree of the specified |size| with the passed in |root| hash. Returns an error if the |proof| verification fails. The resulting smaller tree's root hash is trusted iff the bigger tree's |root| hash is trusted.

func (LogVerifier) VerifyConsistencyProof

func (v LogVerifier) VerifyConsistencyProof(snapshot1, snapshot2 int64, root1, root2 []byte, proof [][]byte) error

VerifyConsistencyProof checks that the passed in consistency proof is valid between the passed in tree snapshots. Snapshots are the respective tree sizes. Accepts shapshot2 >= snapshot1 >= 0.

func (LogVerifier) VerifyInclusionProof

func (v LogVerifier) VerifyInclusionProof(leafIndex, treeSize int64, proof [][]byte, root []byte, leafHash []byte) error

VerifyInclusionProof verifies the correctness of the proof given the passed in information about the tree and leaf.

type RootMismatchError

type RootMismatchError struct {
	ExpectedRoot   []byte
	CalculatedRoot []byte
}

RootMismatchError occurs when an inclusion proof fails.

func (RootMismatchError) Error

func (e RootMismatchError) Error() string

Source Files

hash_chainer.go log_verifier.go

Version
v1.4.1
Published
May 5, 2022
Platform
js/wasm
Imports
5 packages
Last checked
57 minutes ago

Tools for package owners.