proof

package
v0.0.0-...-3b8f57b Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLocalProofs

func CheckLocalProofs(newHash HashFunc, root hashid.HashId, leaves []hashid.HashId, proofs []Proof) bool

func CheckProof

func CheckProof(newHash HashFunc, root hashid.HashId, leaf hashid.HashId, proof Proof) bool

func MerkleGet

func MerkleGet(suite abstract.Suite, root []byte, path MerklePath,
	ctx hashid.HashGet) ([]byte, error)

Retrieve an object in a Merkle tree, validating the entire path in the process. Returns a slice of a buffer obtained from HashGet.Get(), which might be shared and should be considered read-only.

func PrintProofs

func PrintProofs(proofs []Proof)

Types

type HashFunc

type HashFunc func() hash.Hash

type LevelProof

type LevelProof []hashid.HashId

LevelProof is used for the Big Merkle Tree (computed from server commits) A []LevelProof from root to server is sufficient proof

type MerklePath

type MerklePath struct {
	Ptr []int // Offsets of hash-pointers at each intermediate level
	Ofs int   // Offset of relevant object in last-level blob
	Len int   // Length of relevant object in last-level blob
}

MerklePath represents a downward path from a (root) node in a Merkle tree to a given (interior or leaf) descendant node, including all the data necessary to validate and extract the descendant. It is assumed the caller has a valid hash-pointer to the root/starting node, and that all nodes in the path can be retrieved via self-certifying hash-ID.

type Proof

type Proof []hashid.HashId

Proof is used for Local Merkle Trees (computed based on messages from clients) One Proof sufficient for one leaf in a Local Merkle Tree

func ProofTree

func ProofTree(newHash func() hash.Hash, leaves []hashid.HashId) (hashid.HashId, []Proof)

Generate a Merkle proof tree for the given list of leaves, yielding one output proof per leaf.

func (Proof) Calc

func (p Proof) Calc(newHash HashFunc, leaf []byte) []byte

Given a Proof and the hash of the leaf, compute the hash of the root. If the Proof is of length 0, simply returns leaf.

func (Proof) Check

func (p Proof) Check(newHash HashFunc, root, leaf []byte) bool

Check a purported Proof against given root and leaf hashes.

func (*Proof) PrintProof

func (p *Proof) PrintProof(proofNumber int)

Jump to

Keyboard shortcuts

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