client

package
v0.0.0-...-36d823c Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0, Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AwaitInclusion

AwaitInclusion waits for the specified statement s to be included into the log and then returns the checkpoint under which it was found to be present, along with valid consistency and inclusion proofs.

Types

type ErrConsistency

type ErrConsistency struct {
	Golden, Latest api.LogCheckpoint
}

ErrConsistency is returned if two logs roots are found which are inconsistent. This allows a motivated client to extract the checkpoints to provide as evidence if needed.

func (ErrConsistency) Error

func (e ErrConsistency) Error() string

type ErrInclusion

type ErrInclusion struct {
	Checkpoint api.LogCheckpoint
	Proof      api.InclusionProof
}

ErrInclusion is returned if a proof of inclusion does not validate. This allows a motivated client to provide evidence if needed.

func (ErrInclusion) Error

func (e ErrInclusion) Error() string

type LogEntry

type LogEntry struct {
	Root  api.LogCheckpoint
	Index uint64
	Value api.SignedStatement
}

LogEntry wraps up a leaf value with its position in the log.

type LogFollower

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

LogFollower follows a log for new data becoming available.

func NewLogFollower

func NewLogFollower(c ReadonlyClient) LogFollower

NewLogFollower creates a LogFollower that uses the given client.

func (*LogFollower) Checkpoints

func (f *LogFollower) Checkpoints(ctx context.Context, pollInterval time.Duration, golden api.LogCheckpoint) (<-chan api.LogCheckpoint, <-chan error)

Checkpoints polls the log according to the configured interval, returning roots consistent with the current golden checkpoint. Should any valid roots be found which are inconsistent then an error is returned. The log being unavailable will just cause a retry, giving it the benefit of the doubt.

func (*LogFollower) Entries

func (f *LogFollower) Entries(ctx context.Context, cpc <-chan api.LogCheckpoint, head uint64) (<-chan LogEntry, <-chan error)

Entries follows the log to output all of the leaves starting from the head index provided. This is intended to be set up to consume the output of #Checkpoints(), and will output new entries each time a Checkpoint becomes available which is larger than the current head. The input channel should be closed in order to clean up the resources used by this method.

type MapClient

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

MapClient is a client that exposes the operations on a remote map.

func NewMapClient

func NewMapClient(mapURL string) (*MapClient, error)

NewMapClient creates a MapClient for a map hosted at the given URL.

func (*MapClient) Aggregation

func (c *MapClient) Aggregation(ctx context.Context, rev uint64, fwIndex uint64) ([]byte, api.MapInclusionProof, error)

Aggregation returns the value committed to by the map under the given key, with an inclusion proof.

func (*MapClient) MapCheckpoint

func (c *MapClient) MapCheckpoint() (api.MapCheckpoint, error)

MapCheckpoint returns the Checkpoint for the latest map revision. This map root needs to be taken on trust that it isn't forked etc. To remove this trust, the map roots should be stored in a log, and this would further return: * A Log Checkpoint for the MapCheckpointLog * An inclusion proof for this checkpoint within it

type ReadonlyClient

type ReadonlyClient struct {
	// LogURL is the base URL for the FT log.
	LogURL *url.URL

	LogSigVerifier note.Verifier
}

ReadonlyClient is an HTTP client for the FT personality.

TODO(al): split this into Client and SubmitClient.

func (ReadonlyClient) GetCheckpoint

func (c ReadonlyClient) GetCheckpoint() (*api.LogCheckpoint, error)

GetCheckpoint returns a new LogCheckPoint from the server.

func (ReadonlyClient) GetConsistencyProof

func (c ReadonlyClient) GetConsistencyProof(request api.GetConsistencyRequest) (*api.ConsistencyProof, error)

GetConsistencyProof returns the Consistency Proof from the server, for the two given snapshots

func (ReadonlyClient) GetFirmwareImage

func (c ReadonlyClient) GetFirmwareImage(hash []byte) ([]byte, error)

GetFirmwareImage returns the firmware image with the corresponding hash from the personality CAS.

func (ReadonlyClient) GetInclusion

func (c ReadonlyClient) GetInclusion(statement []byte, cp api.LogCheckpoint) (api.InclusionProof, error)

GetInclusion returns an inclusion proof for the statement under the given checkpoint.

func (ReadonlyClient) GetManifestEntryAndProof

func (c ReadonlyClient) GetManifestEntryAndProof(request api.GetFirmwareManifestRequest) (*api.InclusionProof, error)

GetManifestEntryAndProof returns the manifest and proof from the server, for given Index and TreeSize TODO(mhutchinson): Rename this as leaf values can also be annotations.

type SubmitClient

type SubmitClient struct {
	*ReadonlyClient
}

SubmitClient extends ReadonlyClient to also know how to submit entries

func (SubmitClient) PublishAnnotationMalware

func (c SubmitClient) PublishAnnotationMalware(stmt []byte) error

PublishAnnotationMalware publishes the serialized annotation to the log.

func (SubmitClient) PublishFirmware

func (c SubmitClient) PublishFirmware(manifest, image []byte) error

PublishFirmware sends a firmware manifest and corresponding image to the log server.

type WitnessClient

type WitnessClient struct {
	// URL is the base URL for the FT witness.
	URL            *url.URL
	LogSigVerifier note.Verifier
}

WitnessClient is an HTTP client for the FT witness.

func (WitnessClient) GetWitnessCheckpoint

func (c WitnessClient) GetWitnessCheckpoint() (*api.LogCheckpoint, error)

GetWitnessCheckpoint returns a checkpoint from witness server

Jump to

Keyboard shortcuts

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