package client

import "github.com/google/trillian/client"

Package client verifies responses from the Trillian log.

Index

Functions

func CreateAndInitTree

CreateAndInitTree uses the adminClient and mapClient to create the tree described by req. If req describes a MAP tree, then this function will also call the InitMap function using mapClient. Internally, the function will continue to retry failed requests until either the tree is created (and if necessary, initialised) successfully, or ctx is cancelled.

func InitLog

func InitLog(ctx context.Context, tree *trillian.Tree, logClient trillian.TrillianLogClient) error

InitLog initialises a freshly created Log tree.

func InitMap

func InitMap(ctx context.Context, tree *trillian.Tree, mapClient trillian.TrillianMapClient) error

InitMap initialises a freshly created Map tree.

Types

type LogClient

type LogClient struct {
	*LogVerifier
	LogID int64
	// contains filtered or unexported fields
}

LogClient represents a client for a given Trillian log instance.

func New

func New(logID int64, client trillian.TrillianLogClient, verifier *LogVerifier) *LogClient

New returns a new LogClient.

func NewFromTree

func NewFromTree(client trillian.TrillianLogClient, config *trillian.Tree) (*LogClient, error)

NewFromTree creates a new LogClient given a tree config.

func (*LogClient) AddLeaf

func (c *LogClient) AddLeaf(ctx context.Context, data []byte) error

AddLeaf adds leaf to the append only log. Blocks until it gets a verifiable response.

func (*LogClient) GetAndVerifyInclusionAtIndex

func (c *LogClient) GetAndVerifyInclusionAtIndex(ctx context.Context, data []byte, index int64) error

GetAndVerifyInclusionAtIndex updates the log root and ensures that the given leaf data has been included in the log at a particular index.

func (*LogClient) GetByIndex

func (c *LogClient) GetByIndex(ctx context.Context, index int64) (*trillian.LogLeaf, error)

GetByIndex returns a single leaf at the requested index.

func (*LogClient) ListByIndex

func (c *LogClient) ListByIndex(ctx context.Context, start, count int64) ([]*trillian.LogLeaf, error)

ListByIndex returns the requested leaves by index.

func (*LogClient) QueueLeaf

func (c *LogClient) QueueLeaf(ctx context.Context, data []byte) error

QueueLeaf adds a leaf to a Trillian log without blocking. AlreadyExists is considered a success case by this function.

func (*LogClient) UpdateRoot

func (c *LogClient) UpdateRoot(ctx context.Context) (*trillian.SignedLogRoot, error)

UpdateRoot retrieves the current SignedLogRoot, verifying it against roots this client has seen in the past, and updating the currently trusted root if the new root verifies.

func (*LogClient) VerifyInclusion

func (c *LogClient) VerifyInclusion(ctx context.Context, data []byte) error

VerifyInclusion updates the log root and ensures that the given leaf data has been included in the log.

func (*LogClient) WaitForInclusion

func (c *LogClient) WaitForInclusion(ctx context.Context, data []byte) error

WaitForInclusion blocks until the requested data has been verified with an inclusion proof. This assumes that the data has already been submitted. Best practice is to call this method with a context that will timeout.

func (*LogClient) WaitForRootUpdate

func (c *LogClient) WaitForRootUpdate(ctx context.Context, waitForTreeSize int64) (*trillian.SignedLogRoot, error)

WaitForRootUpdate repeatedly fetches the Root until the fetched tree size >= waitForTreeSize or until ctx times out.

type LogVerifier

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

LogVerifier contains state needed to verify output from Trillian Logs.

func NewLogVerifier

func NewLogVerifier(hasher hashers.LogHasher, pubKey crypto.PublicKey) *LogVerifier

NewLogVerifier returns an object that can verify output from Trillian Logs.

func NewLogVerifierFromTree

func NewLogVerifierFromTree(config *trillian.Tree) (*LogVerifier, error)

NewLogVerifierFromTree creates a new LogVerifier using the algorithms specified by *trillian.Tree.

func (*LogVerifier) BuildLeaf

func (c *LogVerifier) BuildLeaf(data []byte) (*trillian.LogLeaf, error)

BuildLeaf runs the leaf hasher over data and builds a leaf.

func (*LogVerifier) VerifyInclusionAtIndex

func (c *LogVerifier) VerifyInclusionAtIndex(trusted *trillian.SignedLogRoot, data []byte, leafIndex int64, proof [][]byte) error

VerifyInclusionAtIndex verifies that the inclusion proof for data at index matches the currently trusted root. The inclusion proof must be requested for Root().TreeSize.

func (*LogVerifier) VerifyInclusionByHash

func (c *LogVerifier) VerifyInclusionByHash(trusted *trillian.SignedLogRoot, leafHash []byte, proof *trillian.Proof) error

VerifyInclusionByHash verifies the inclusion proof for data

func (*LogVerifier) VerifyRoot

func (c *LogVerifier) VerifyRoot(trusted, newRoot *trillian.SignedLogRoot,
	consistency [][]byte) error

VerifyRoot verifies that newRoot is a valid append-only operation from trusted. If trusted.TreeSize is zero, a consistency proof is not needed.

type MapVerifier

type MapVerifier struct {
	Hasher hashers.MapHasher
	PubKey crypto.PublicKey
}

MapVerifier verifies protos produced by the Trillian Map.

func NewMapVerifierFromTree

func NewMapVerifierFromTree(config *trillian.Tree) (*MapVerifier, error)

NewMapVerifierFromTree creates a new MapVerifier.

func (*MapVerifier) VerifyMapLeafInclusion

func (m *MapVerifier) VerifyMapLeafInclusion(smr *trillian.SignedMapRoot, leafProof *trillian.MapLeafInclusion) error

VerifyMapLeafInclusion verifies a MapLeafInclusion response.

func (*MapVerifier) VerifySignedMapRoot

func (m *MapVerifier) VerifySignedMapRoot(smr *trillian.SignedMapRoot) error

VerifySignedMapRoot verifies the signature on the SignedMapRoot.

type MockLogClient

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

MockLogClient supports applying mutations to the return values of the TrillianLogClient

func (*MockLogClient) AddSequencedLeaf

AddSequencedLeaf forwards requests.

func (*MockLogClient) AddSequencedLeaves

AddSequencedLeaves forwards requests.

func (*MockLogClient) GetConsistencyProof

GetConsistencyProof forwards requests and optionally corrupts responses.

func (*MockLogClient) GetEntryAndProof

GetEntryAndProof forwards requests.

func (*MockLogClient) GetInclusionProof

GetInclusionProof forwards requests and optionally corrupts the response.

func (*MockLogClient) GetInclusionProofByHash

GetInclusionProofByHash forwards requests and optionaly corrupts responses.

func (*MockLogClient) GetLatestSignedLogRoot

GetLatestSignedLogRoot forwards requests.

func (*MockLogClient) GetLeavesByHash

GetLeavesByHash forwards requests.

func (*MockLogClient) GetLeavesByIndex

GetLeavesByIndex forwards requests.

func (*MockLogClient) GetLeavesByRange

GetLeavesByRange forwards requests.

func (*MockLogClient) GetSequencedLeafCount

GetSequencedLeafCount forwards requests.

func (*MockLogClient) InitLog

InitLog forwards requests.

func (*MockLogClient) QueueLeaf

QueueLeaf forwards requests.

func (*MockLogClient) QueueLeaves

QueueLeaves forwards requests.

Source Files

admin.go log_client.go log_verifier.go map_verifier.go mock_log_client.go

Directories

PathSynopsis
client/backoffPackage backoff allows retrying an operation with backoff.
Version
v1.0.8
Published
Mar 8, 2018
Platform
js/wasm
Imports
18 packages
Last checked
4 hours ago

Tools for package owners.