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
- func InitMap(ctx context.Context, tree *trillian.Tree, mapClient trillian.TrillianMapClient) error
- type LogClient
- func (c *LogClient) AddLeaf(ctx context.Context, data []byte) error
- func (c *LogClient) GetAndVerifyInclusionAtIndex(ctx context.Context, data []byte, index int64) 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) UpdateRoot(ctx context.Context) (*types.LogRootV1, error)
- func (c *LogClient) VerifyInclusion(ctx context.Context, data []byte) error
- func (c *LogClient) WaitForInclusion(ctx context.Context, data []byte) error
- func (c *LogClient) WaitForRootUpdate(ctx context.Context, waitForTreeSize uint64) (*types.LogRootV1, error)
- type LogVerifier
- func (c *LogVerifier) BuildLeaf(data []byte) (*trillian.LogLeaf, error)
- func (c *LogVerifier) VerifyInclusionAtIndex(trusted *types.LogRootV1, data []byte, leafIndex int64, proof [][]byte) error
- func (c *LogVerifier) VerifyInclusionByHash(trusted *types.LogRootV1, leafHash []byte, proof *trillian.Proof) error
- func (c *LogVerifier) VerifyRoot(trusted *types.LogRootV1, newRoot *trillian.SignedLogRoot, ...) (*types.LogRootV1, error)
- type MapVerifier
- func (m *MapVerifier) VerifyMapLeafInclusion(smr *trillian.SignedMapRoot, leafProof *trillian.MapLeafInclusion) error
- func (m *MapVerifier) VerifyMapLeafInclusionHash(rootHash []byte, leafProof *trillian.MapLeafInclusion) error
- func (m *MapVerifier) VerifySignedMapRoot(smr *trillian.SignedMapRoot) (*types.MapRootV1, error)
- type MockLogClient
- func (c *MockLogClient) AddSequencedLeaf(ctx context.Context, in *trillian.AddSequencedLeafRequest, ...) (*trillian.AddSequencedLeafResponse, error)
- func (c *MockLogClient) AddSequencedLeaves(ctx context.Context, in *trillian.AddSequencedLeavesRequest, ...) (*trillian.AddSequencedLeavesResponse, error)
- 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) GetLeavesByRange(ctx context.Context, in *trillian.GetLeavesByRangeRequest, ...) (*trillian.GetLeavesByRangeResponse, error)
- func (c *MockLogClient) GetSequencedLeafCount(ctx context.Context, in *trillian.GetSequencedLeafCountRequest, ...) (*trillian.GetSequencedLeafCountResponse, error)
- func (c *MockLogClient) InitLog(ctx context.Context, in *trillian.InitLogRequest, opts ...grpc.CallOption) (*trillian.InitLogResponse, 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)
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, mapClient trillian.TrillianMapClient, logClient trillian.TrillianLogClient) (*trillian.Tree, error)
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.
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 ¶ added in v1.0.7
NewFromTree creates a new LogClient given a tree config.
func (*LogClient) AddLeaf ¶
AddLeaf adds leaf to the append only log. Blocks until it gets a verifiable response.
func (*LogClient) GetAndVerifyInclusionAtIndex ¶ added in v1.0.7
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 ¶
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) 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.
func (*LogClient) VerifyInclusion ¶
VerifyInclusion updates the log root and ensures that the given leaf data has been included in the log.
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 struct { // Hasher is the hash strategy used to compute nodes in the Merkle tree. Hasher hashers.LogHasher // PubKey verifies the signature on the digest of LogRoot. PubKey crypto.PublicKey // SigHash computes the digest of LogRoot for signing. SigHash crypto.Hash // 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, sigHash crypto.Hash) *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 *trillian.Tree.
func (*LogVerifier) BuildLeaf ¶ added in v1.0.7
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 *types.LogRootV1, 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 *types.LogRootV1, leafHash []byte, proof *trillian.Proof) error
VerifyInclusionByHash verifies the inclusion proof for data
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.
type MapVerifier ¶ added in v1.0.7
type MapVerifier struct { MapID int64 // Hasher is the hash strategy used to compute nodes in the Merkle tree. Hasher hashers.MapHasher // PubKey verifies the signature on the digest of MapRoot. PubKey crypto.PublicKey // SigHash computes the digest of MapRoot for signing. SigHash crypto.Hash }
MapVerifier verifies protos produced by the Trillian Map.
func NewMapVerifierFromTree ¶ added in v1.0.7
func NewMapVerifierFromTree(config *trillian.Tree) (*MapVerifier, error)
NewMapVerifierFromTree creates a new MapVerifier.
func (*MapVerifier) VerifyMapLeafInclusion ¶ added in v1.0.7
func (m *MapVerifier) VerifyMapLeafInclusion(smr *trillian.SignedMapRoot, leafProof *trillian.MapLeafInclusion) error
VerifyMapLeafInclusion verifies a MapLeafInclusion response against a signed map root.
func (*MapVerifier) VerifyMapLeafInclusionHash ¶ added in v1.1.1
func (m *MapVerifier) VerifyMapLeafInclusionHash(rootHash []byte, leafProof *trillian.MapLeafInclusion) error
VerifyMapLeafInclusionHash verifies a MapLeafInclusion response against a root hash.
func (*MapVerifier) VerifySignedMapRoot ¶ added in v1.0.7
func (m *MapVerifier) VerifySignedMapRoot(smr *trillian.SignedMapRoot) (*types.MapRootV1, 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 ¶ added in v1.0.7
func (c *MockLogClient) AddSequencedLeaf(ctx context.Context, in *trillian.AddSequencedLeafRequest, opts ...grpc.CallOption) (*trillian.AddSequencedLeafResponse, error)
AddSequencedLeaf forwards requests.
func (*MockLogClient) AddSequencedLeaves ¶ added in v1.0.7
func (c *MockLogClient) AddSequencedLeaves(ctx context.Context, in *trillian.AddSequencedLeavesRequest, opts ...grpc.CallOption) (*trillian.AddSequencedLeavesResponse, error)
AddSequencedLeaves forwards requests.
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) GetLeavesByRange ¶ added in v1.0.6
func (c *MockLogClient) GetLeavesByRange(ctx context.Context, in *trillian.GetLeavesByRangeRequest, opts ...grpc.CallOption) (*trillian.GetLeavesByRangeResponse, error)
GetLeavesByRange 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) InitLog ¶ added in v1.0.7
func (c *MockLogClient) InitLog(ctx context.Context, in *trillian.InitLogRequest, opts ...grpc.CallOption) (*trillian.InitLogResponse, error)
InitLog 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.