witness

package
v0.0.0-...-0ca6a70 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package witness is designed to make sure the checkpoints of verifiable logs are consistent and store/serve/sign them if so. It is expected that a separate feeder component would be responsible for the actual interaction with logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogInfo

type LogInfo struct {
	// The verifier for signatures from the log.
	SigV note.Verifier
	// The expected Origin string in the checkpoints.
	Origin string
	// The hash strategy that should be used in verifying consistency.
	Hasher merkle.LogHasher
	// An indicator of whether the log should be verified using consistency
	// proofs or compact ranges.
	UseCompact bool
}

LogInfo contains the information needed to verify log checkpoints.

type Opts

type Opts struct {
	Persistence persistence.LogStatePersistence
	Signers     []note.Signer
	KnownLogs   map[string]LogInfo
}

Opts is the options passed to a witness.

type Proof

type Proof [][]byte

Proof represents a common format proof.

Interpretation of the proof bytes is ecosystem dependent.

func (Proof) Marshal

func (p Proof) Marshal() string

Marshal returns the common format representation of this proof.

func (*Proof) Unmarshal

func (p *Proof) Unmarshal(data []byte) error

Unmarshal parses common proof format data and stores the result in the Proof struct.

type Witness

type Witness struct {
	Signers []note.Signer
	// At some point we might want to store this information in a table in
	// the database too but as I imagine it being populated from a static
	// config file it doesn't seem very urgent to do that.
	Logs map[string]LogInfo
	// contains filtered or unexported fields
}

Witness consists of a database for storing checkpoints, a signer, and a list of logs for which it stores and verifies checkpoints.

func New

func New(wo Opts) (*Witness, error)

New creates a new witness, which initially has no logs to follow.

func (*Witness) GetCheckpoint

func (w *Witness) GetCheckpoint(logID string) ([]byte, error)

GetCheckpoint gets a checkpoint for a given log, which is consistent with all other checkpoints for the same log signed by this witness.

func (*Witness) GetLogs

func (w *Witness) GetLogs() ([]string, error)

GetLogs returns a list of all logs the witness is aware of.

func (*Witness) Update

func (w *Witness) Update(ctx context.Context, logID string, nextRaw []byte, cProof [][]byte) ([]byte, error)

Update updates the latest checkpoint if nextRaw is consistent with the current latest one for this log.

It returns the latest cosigned checkpoint held by the witness, which is a signed version of nextRaw if the update was applied.

If an error occurs, this method will generally return an error with a status code: - codes.NotFound if the log is unknown - codes.InvalidArgument for general bad requests - codes.AlreadyExists if the checkpoint is smaller than the one the witness knows - codes.FailedPrecondition if the checkpoint is inconsistent with the one the witness knows

Jump to

Keyboard shortcuts

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