Documentation ¶
Index ¶
- Constants
- func SplitTile(hashes []byte, height int) [][]byte
- type Database
- func (d *Database) GetHead() (int64, error)
- func (d *Database) GetLeaves(start int64, count int) ([][]byte, error)
- func (d *Database) GetTile(height, level, offset int) ([][]byte, error)
- func (d *Database) Init() error
- func (d *Database) SetLeafMetadata(ctx context.Context, start int64, metadata []Metadata) error
- func (d *Database) SetTile(height, level, offset int, hashes []byte) error
- func (d *Database) WriteLeaves(ctx context.Context, start int64, leaves [][]byte) error
- type Fetcher
- type HTTPFetcher
- type Metadata
- type Service
- func (s *Service) CheckRootHash(ctx context.Context, checkpoint *tlog.Tree) error
- func (s *Service) CloneLeafTiles(ctx context.Context, checkpoint *tlog.Tree) error
- func (s *Service) HashTiles(ctx context.Context, checkpoint *tlog.Tree) error
- func (s *Service) ProcessMetadata(ctx context.Context, checkpoint *tlog.Tree) error
- func (s *Service) VerifyTiles(ctx context.Context, checkpoint *tlog.Tree) error
- type SumDBClient
Constants ¶
const HashLenBytes = 32
HashLenBytes is the number of bytes in the SumDB hashes.
Variables ¶
This section is empty.
Functions ¶
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 ¶
NewDatabase creates a Database using the contents of the given filepath.NewDatabase. If the file doesn't exist it will be created.
func (*Database) SetLeafMetadata ¶
SetLeafMetadata sets the metadata for a contiguous batch of leaves.
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).
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 ¶
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 ¶
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 ¶
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 ¶
ProcessMetadata parses the leaf data and writes the semantic data into the DB.
func (*Service) VerifyTiles ¶
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.