Documentation ¶
Overview ¶
Package client verifies responses from the Trillian log.
Index ¶
- type LogClient
- func (c *LogClient) AddLeaf(ctx context.Context, data []byte) error
- func (c *LogClient) GetByIndex(ctx context.Context, index int64) (*trillian.LogLeaf, error)
- 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) Root() trillian.SignedLogRoot
- func (c *LogClient) UpdateRoot(ctx context.Context) error
- func (c *LogClient) VerifyInclusion(ctx context.Context, data []byte) error
- func (c *LogClient) VerifyInclusionAtIndex(ctx context.Context, data []byte, index int64) error
- func (c LogClient) VerifyInclusionByHash(trusted *trillian.SignedLogRoot, leafHash []byte, proof *trillian.Proof) error
- func (c LogClient) VerifyRoot(trusted, newRoot *trillian.SignedLogRoot, consistency [][]byte) error
- func (c *LogClient) WaitForInclusion(ctx context.Context, data []byte) error
- type LogVerifier
- type MockLogClient
- func (c *MockLogClient) GetConsistencyProof(ctx context.Context, in *trillian.GetConsistencyProofRequest, ...) (*trillian.GetConsistencyProofResponse, error)
- func (c *MockLogClient) GetEntryAndProof(ctx context.Context, in *trillian.GetEntryAndProofRequest, ...) (*trillian.GetEntryAndProofResponse, error)
- func (c *MockLogClient) GetInclusionProof(ctx context.Context, in *trillian.GetInclusionProofRequest, ...) (*trillian.GetInclusionProofResponse, error)
- func (c *MockLogClient) GetInclusionProofByHash(ctx context.Context, in *trillian.GetInclusionProofByHashRequest, ...) (*trillian.GetInclusionProofByHashResponse, error)
- func (c *MockLogClient) GetLatestSignedLogRoot(ctx context.Context, in *trillian.GetLatestSignedLogRootRequest, ...) (*trillian.GetLatestSignedLogRootResponse, error)
- func (c *MockLogClient) GetLeavesByHash(ctx context.Context, in *trillian.GetLeavesByHashRequest, ...) (*trillian.GetLeavesByHashResponse, error)
- func (c *MockLogClient) GetLeavesByIndex(ctx context.Context, in *trillian.GetLeavesByIndexRequest, ...) (*trillian.GetLeavesByIndexResponse, error)
- func (c *MockLogClient) GetSequencedLeafCount(ctx context.Context, in *trillian.GetSequencedLeafCountRequest, ...) (*trillian.GetSequencedLeafCountResponse, error)
- func (c *MockLogClient) QueueLeaf(ctx context.Context, in *trillian.QueueLeafRequest, opts ...grpc.CallOption) (*trillian.QueueLeafResponse, error)
- func (c *MockLogClient) QueueLeaves(ctx context.Context, in *trillian.QueueLeavesRequest, opts ...grpc.CallOption) (*trillian.QueueLeavesResponse, error)
- type VerifyingLogClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogClient ¶
type LogClient struct { 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, hasher hashers.LogHasher, pubKey crypto.PublicKey) *LogClient
New returns a new LogClient.
func (*LogClient) AddLeaf ¶
AddLeaf adds leaf to the append only log. Blocks until it gets a verifiable response.
func (*LogClient) GetByIndex ¶
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 ¶
QueueLeaf adds a leaf to a Trillian log without blocking. AlreadyExists is considered a success case by this function.
func (*LogClient) Root ¶
func (c *LogClient) Root() trillian.SignedLogRoot
Root returns the last valid root seen by UpdateRoot. Returns an empty SignedLogRoot if UpdateRoot has not been called.
func (*LogClient) UpdateRoot ¶
UpdateRoot retrieves the current SignedLogRoot. Verifies the signature, and the consistency proof if this is not the first root this client has seen.
func (*LogClient) VerifyInclusion ¶
VerifyInclusion updates the log root and ensures that the given leaf data has been included in the log.
func (*LogClient) VerifyInclusionAtIndex ¶
VerifyInclusionAtIndex updates the log root and ensures that the given leaf data has been included in the log at a particular index.
func (LogClient) VerifyInclusionByHash ¶
func (c LogClient) VerifyInclusionByHash(trusted *trillian.SignedLogRoot, leafHash []byte, proof *trillian.Proof) error
VerifyInclusionByHash verifies the inclusion proof for data
func (LogClient) VerifyRoot ¶
func (c LogClient) 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.
func (*LogClient) WaitForInclusion ¶
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.
type LogVerifier ¶
type LogVerifier interface { // VerifyRoot verifies that newRoot is a valid append-only operation from trusted. // If trusted.TreeSize is zero, an append-only proof is not needed. VerifyRoot(trusted, newRoot *trillian.SignedLogRoot, consistency [][]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. VerifyInclusionAtIndex(trusted *trillian.SignedLogRoot, data []byte, leafIndex int64, proof [][]byte) error // VerifyInclusionByHash verifies the inclusion proof for data VerifyInclusionByHash(trusted *trillian.SignedLogRoot, leafHash []byte, proof *trillian.Proof) error }
LogVerifier verifies responses from a Trillian Log.
func NewLogVerifier ¶
func NewLogVerifier(hasher hashers.LogHasher, pubKey crypto.PublicKey) LogVerifier
NewLogVerifier returns an object that can verify output from Trillian Logs.
type MockLogClient ¶
type MockLogClient struct {
// contains filtered or unexported fields
}
MockLogClient supports applying mutations to the return values of the TrillianLogClient
func (*MockLogClient) GetConsistencyProof ¶
func (c *MockLogClient) GetConsistencyProof(ctx context.Context, in *trillian.GetConsistencyProofRequest, opts ...grpc.CallOption) (*trillian.GetConsistencyProofResponse, error)
GetConsistencyProof forwards requests and optionally corrupts responses.
func (*MockLogClient) GetEntryAndProof ¶
func (c *MockLogClient) GetEntryAndProof(ctx context.Context, in *trillian.GetEntryAndProofRequest, opts ...grpc.CallOption) (*trillian.GetEntryAndProofResponse, error)
GetEntryAndProof forwards requests.
func (*MockLogClient) GetInclusionProof ¶
func (c *MockLogClient) GetInclusionProof(ctx context.Context, in *trillian.GetInclusionProofRequest, opts ...grpc.CallOption) (*trillian.GetInclusionProofResponse, error)
GetInclusionProof forwards requests and optionally corrupts the response.
func (*MockLogClient) GetInclusionProofByHash ¶
func (c *MockLogClient) GetInclusionProofByHash(ctx context.Context, in *trillian.GetInclusionProofByHashRequest, opts ...grpc.CallOption) (*trillian.GetInclusionProofByHashResponse, error)
GetInclusionProofByHash forwards requests and optionaly corrupts responses.
func (*MockLogClient) GetLatestSignedLogRoot ¶
func (c *MockLogClient) GetLatestSignedLogRoot(ctx context.Context, in *trillian.GetLatestSignedLogRootRequest, opts ...grpc.CallOption) (*trillian.GetLatestSignedLogRootResponse, error)
GetLatestSignedLogRoot forwards requests.
func (*MockLogClient) GetLeavesByHash ¶
func (c *MockLogClient) GetLeavesByHash(ctx context.Context, in *trillian.GetLeavesByHashRequest, opts ...grpc.CallOption) (*trillian.GetLeavesByHashResponse, error)
GetLeavesByHash forwards requests.
func (*MockLogClient) GetLeavesByIndex ¶
func (c *MockLogClient) GetLeavesByIndex(ctx context.Context, in *trillian.GetLeavesByIndexRequest, opts ...grpc.CallOption) (*trillian.GetLeavesByIndexResponse, error)
GetLeavesByIndex forwards requests.
func (*MockLogClient) GetSequencedLeafCount ¶
func (c *MockLogClient) GetSequencedLeafCount(ctx context.Context, in *trillian.GetSequencedLeafCountRequest, opts ...grpc.CallOption) (*trillian.GetSequencedLeafCountResponse, error)
GetSequencedLeafCount forwards requests.
func (*MockLogClient) QueueLeaf ¶
func (c *MockLogClient) QueueLeaf(ctx context.Context, in *trillian.QueueLeafRequest, opts ...grpc.CallOption) (*trillian.QueueLeafResponse, error)
QueueLeaf forwards requests.
func (*MockLogClient) QueueLeaves ¶
func (c *MockLogClient) QueueLeaves(ctx context.Context, in *trillian.QueueLeavesRequest, opts ...grpc.CallOption) (*trillian.QueueLeavesResponse, error)
QueueLeaves forwards requests.
type VerifyingLogClient ¶
type VerifyingLogClient interface { // AddLeaf adds data to the Trillian Log and blocks until an inclusion proof // is available. If no proof is available within the ctx deadline, DeadlineExceeded // is returned. AddLeaf(ctx context.Context, data []byte) error // VerifyInclusion ensures that data has been included in the log // via an inclusion proof. VerifyInclusion(ctx context.Context, data []byte) error // VerifyInclusionAtIndex ensures that data has been included in the log // via in inclusion proof for a particular index. VerifyInclusionAtIndex(ctx context.Context, data []byte, index int64) error // UpdateRoot fetches and verifies the current SignedTreeRoot. // It checks signatures as well as consistency proofs from the last-seen root. UpdateRoot(ctx context.Context) error // Root provides the last root obtained by UpdateRoot. Root() trillian.SignedLogRoot // GetByIndex returns a single leaf. Does not verify the leaf's inclusion proof. GetByIndex(ctx context.Context, index int64) (*trillian.LogLeaf, error) // ListByIndex returns a contiguous range. Does not verify the leaf's inclusion proof. ListByIndex(ctx context.Context, start, count int64) ([]*trillian.LogLeaf, error) }
VerifyingLogClient is a client that verifies output from Trillian.