audit

package
v0.0.0-...-15a2749 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const HashLenBytes = 32

HashLenBytes is the number of bytes in the SumDB hashes.

Variables

This section is empty.

Functions

func SplitTile

func SplitTile(hashes []byte, height int) [][]byte

SplitTile turns the blob that is the leaf hashes in a tile into separate hashes.

Types

type Database

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

Database provides read/write access to the local copy of the SumDB.

func NewDatabase

func NewDatabase(location string) (*Database, error)

NewDatabase creates a Database using the contents of the given filepath.NewDatabase. If the file doesn't exist it will be created.

func (*Database) GetHead

func (d *Database) GetHead() (int64, error)

GetHead returns the largest leaf index written.

func (*Database) GetLeaves

func (d *Database) GetLeaves(start int64, count int) ([][]byte, error)

GetLeaves gets a contiguous block of leaves.

func (*Database) GetTile

func (d *Database) GetTile(height, level, offset int) ([][]byte, error)

GetTile gets the leaf hashes for the given tile, or returns an error.

func (*Database) Init

func (d *Database) Init() error

Init creates the database tables if needed.

func (*Database) SetLeafMetadata

func (d *Database) SetLeafMetadata(ctx context.Context, start int64, metadata []Metadata) error

SetLeafMetadata sets the metadata for a contiguous batch of leaves.

func (*Database) SetTile

func (d *Database) SetTile(height, level, offset int, hashes []byte) error

SetTile sets the leaf hash data for the given tile. The leaf hashes should be 2^height * HashLenBytes long.

func (*Database) WriteLeaves

func (d *Database) WriteLeaves(ctx context.Context, start int64, leaves [][]byte) error

WriteLeaves writes the contiguous chunk of leaves, starting at the stated index.

type Fetcher

type Fetcher interface {
	// GetData gets the data at the given path, or returns an error.
	GetData(path string) ([]byte, error)
}

Fetcher gets data paths. This allows impl to be swapped for tests.

type HTTPFetcher

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

HTTPFetcher gets the data over HTTP(S).

func (*HTTPFetcher) GetData

func (f *HTTPFetcher) GetData(path string) ([]byte, error)

GetData gets the data.

type Metadata

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

Metadata is the semantic data that is contained within the leaves of the log.

type Service

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

Service has all the operations required for an auditor to verifiably clone the remote SumDB.

func NewService

func NewService(localDB *Database, sumDB *SumDBClient, height int) *Service

NewService constructs a new Service which is ready to go.

func (*Service) CheckRootHash

func (s *Service) CheckRootHash(ctx context.Context, checkpoint *tlog.Tree) error

CheckRootHash calculates the root hash from the locally generated tiles, and then appends any stragglers from the SumDB, returning an error if this calculation fails or the result does not match that in the checkpoint provided.

func (*Service) CloneLeafTiles

func (s *Service) CloneLeafTiles(ctx context.Context, checkpoint *tlog.Tree) error

CloneLeafTiles copies the leaf data from the SumDB into the local database. It only copies whole tiles, which means that some stragglers may not be copied locally.

func (*Service) HashTiles

func (s *Service) HashTiles(ctx context.Context, checkpoint *tlog.Tree) error

HashTiles performs a full recalculation of all the tiles using the data from the leaves table. Any hashes that no longer match what was previously stored will cause an error. Any new hashes will be filled in. This could be replaced by something more incremental if the performance is unnacceptable. While the SumDB is still reasonably small, this is fine as is.

func (*Service) ProcessMetadata

func (s *Service) ProcessMetadata(ctx context.Context, checkpoint *tlog.Tree) error

ProcessMetadata parses the leaf data and writes the semantic data into the DB.

func (*Service) VerifyTiles

func (s *Service) VerifyTiles(ctx context.Context, checkpoint *tlog.Tree) error

VerifyTiles checks that every tile calculated locally matches the result returned by SumDB. This shouldn't be possible if CheckRootHash is working, but this may be useful to determine where any corruption has happened in the tree.

type SumDBClient

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

SumDBClient provides access to information from the Sum DB.

func NewSumDB

func NewSumDB(height int, vkey string) *SumDBClient

NewSumDB creates a new client that fetches tiles of the given height.

func (*SumDBClient) FullLeavesAtOffset

func (c *SumDBClient) FullLeavesAtOffset(offset int) ([][]byte, error)

FullLeavesAtOffset gets the Nth chunk of 2**height leaves.

func (*SumDBClient) LatestCheckpoint

func (c *SumDBClient) LatestCheckpoint() (*tlog.Tree, error)

LatestCheckpoint gets the freshest Checkpoint.

func (*SumDBClient) PartialLeavesAtOffset

func (c *SumDBClient) PartialLeavesAtOffset(offset, count int) ([][]byte, error)

PartialLeavesAtOffset gets the final tile of incomplete leaves.

func (*SumDBClient) TileHashes

func (c *SumDBClient) TileHashes(level, offset int) ([]tlog.Hash, error)

TileHashes gets the hashes at the given level and offset.

Jump to

Keyboard shortcuts

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