Documentation ¶
Overview ¶
Package client verifies responses from the Trillian log.
Index ¶
- func CreateAndInitTree(ctx context.Context, req *trillian.CreateTreeRequest, ...) (*trillian.Tree, error)
- func InitLog(ctx context.Context, tree *trillian.Tree, logClient trillian.TrillianLogClient) error
- type LogClient
- func (c *LogClient) AddLeaf(ctx context.Context, data []byte) error
- func (c *LogClient) AddSequencedLeaves(ctx context.Context, dataByIndex map[int64][]byte) error
- func (c *LogClient) GetRoot() *types.LogRootV1
- func (c *LogClient) ListByIndex(ctx context.Context, start, count int64) ([]*trillian.LogLeaf, error)
- func (c *LogClient) QueueLeaf(ctx context.Context, data []byte) error
- func (c *LogClient) UpdateRoot(ctx context.Context) (*types.LogRootV1, error)
- func (c *LogClient) WaitForInclusion(ctx context.Context, data []byte) error
- func (c *LogClient) WaitForRootUpdate(ctx context.Context) (*types.LogRootV1, error)
- type LogVerifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAndInitTree ¶ added in v1.0.7
func CreateAndInitTree( ctx context.Context, req *trillian.CreateTreeRequest, adminClient trillian.TrillianAdminClient, logClient trillian.TrillianLogClient) (*trillian.Tree, error)
CreateAndInitTree uses the adminClient and logClient to create the tree described by req. If req describes a LOG tree, then this function will also call the InitLog function using logClient. Internally, the function will continue to retry failed requests until either the tree is created (and if necessary, initialised) successfully, or ctx is cancelled.
Types ¶
type LogClient ¶
type LogClient struct { *LogVerifier LogID int64 MinMergeDelay time.Duration // 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, root types.LogRootV1) *LogClient
New returns a new LogClient.
func NewFromTree ¶ added in v1.0.7
func NewFromTree(client trillian.TrillianLogClient, config *trillian.Tree, root types.LogRootV1) (*LogClient, error)
NewFromTree creates a new LogClient given a tree config.
func (*LogClient) AddLeaf ¶
AddLeaf adds leaf to the append only log. Blocks and continuously updates the trusted root until a successful inclusion proof can be retrieved.
func (*LogClient) AddSequencedLeaves ¶ added in v1.3.0
AddSequencedLeaves adds any number of pre-sequenced leaves to the log. Indexes must be contiguous.
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 ¶
QueueLeaf adds a leaf to a Trillian log without blocking. AlreadyExists is considered a success case by this function.
func (*LogClient) UpdateRoot ¶
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, and is newer than the currently trusted root.
func (*LogClient) WaitForInclusion ¶
WaitForInclusion blocks until the requested data has been verified with an inclusion proof.
It will continuously update the root to the latest one available until the data is found, or an error is returned.
It is best to call this method with a context that will timeout to avoid waiting forever.
type LogVerifier ¶
type LogVerifier struct {
// contains filtered or unexported fields
}
LogVerifier allows verification of output from Trillian Logs, both regular and pre-ordered; it is safe for concurrent use (as its contents are fixed after construction).
func NewLogVerifier ¶
func NewLogVerifier(hasher merkle.LogHasher) *LogVerifier
NewLogVerifier returns an object that can verify output from Trillian Logs.
func NewLogVerifierFromTree ¶ added in v1.0.7
func NewLogVerifierFromTree(config *trillian.Tree) (*LogVerifier, error)
NewLogVerifierFromTree creates a new LogVerifier using the algorithms specified by a Trillian Tree object.
func (*LogVerifier) VerifyInclusionByHash ¶
func (c *LogVerifier) VerifyInclusionByHash(trusted *types.LogRootV1, leafHash []byte, pf *trillian.Proof) error
VerifyInclusionByHash verifies that the inclusion proof for the given Merkle leafHash matches the given trusted root.
func (*LogVerifier) VerifyRoot ¶
func (c *LogVerifier) VerifyRoot(trusted *types.LogRootV1, newRoot *trillian.SignedLogRoot, consistency [][]byte) (*types.LogRootV1, error)
VerifyRoot verifies that newRoot is a valid append-only operation from trusted. If trusted.TreeSize is zero, a consistency proof is not needed.