helloworld

package module
v0.0.0-...-07a63da Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

hello-world

This is a very basic example of how to use Trillian to implement the operations needed for a verifiable log. It intentionally avoids defining any interface between the client and personality, leaving only the gRPC interface between the personality and the (Trillian) log. In a real deployment it would be necessary to define an interface between the client and the personality, and thus implement a "real" client on top of the current one.

In order to run the tests, it is necessary to first have a Trillian log running, which itself means it is necessary to have MySQL or MariaDB running (see MySQL setup for more information). In one terminal, run the following commands:

export GO111MODULE=on
go run github.com/google/trillian/cmd/trillian_log_server --rpc_endpoint="localhost:50054" --http_endpoint="localhost:50055" &
go run github.com/google/trillian/cmd/trillian_log_signer --sequencer_interval="1s" --batch_size=500 --rpc_endpoint="localhost:50056" --http_endpoint="localhost:50057" --num_sequencers=1 --force_master &
# Trillian services are now running
go run github.com/google/trillian/cmd/createtree --admin_server=localhost:50054 # Take note of this tree/log ID

export TREE_ID= # Use the tree ID returned by createtree above
go run github.com/google/trillian/cmd/get_tree_public_key --admin_server=localhost:50054 --log_id=${TREE_ID}

Paste the public key returned by this last call into config.go and paste the tree ID into personality.go.

Now, in another terminal run go build and then go test. This runs three tests.

  1. TestAppend ensures that checkpoints update properly on the personality side when new entries are appended to the log.
  2. TestUpdate ensures that these updated checkpoints can be accepted by the client, after they are proved consistent with previous checkpoints.
  3. TestIncl ensures that the client can be convinced about whether or not entries are in the log.

Documentation

Overview

Runs a simple client, designed to interact with a personality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TreeVerifier

func TreeVerifier() (*tc.LogVerifier, error)

TreeVerifier returns a verifier configured for the log.

Types

type Client

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

A client is a verifier that maintains a checkpoint as state.

func NewClient

func NewClient(prsn Personality) Client

NewClient creates a new client with an empty checkpoint and a given personality to talk to.

func (Client) UpdateChkpt

func (c Client) UpdateChkpt(chkptNew p.Chkpt, pf *trillian.Proof) bool

UpdateChkpt allows a client to update its stored checkpoint.

func (Client) VerIncl

func (c Client) VerIncl(entry []byte, pf *trillian.Proof) bool

VerIncl allows the client to check inclusion of a given entry.

type Personality

type Personality interface {
	// Append stores an entry in the log.
	Append(context.Context, []byte) p.Chkpt

	// ProveIncl proves the inclusion of a given entry.
	ProveIncl(context.Context, p.Chkpt, []byte) *trillian.Proof

	// UpdateChkpt provides a new checkpoint and proves it is consistent
	// with an old one.
	UpdateChkpt(context.Context, p.Chkpt) (p.Chkpt, *trillian.Proof)
}

Personality is the interface to the the Trillian log.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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