Documentation
¶
Overview ¶
Package torchwood implements a tlog client and various c2sp.org/signed-note, c2sp.org/tlog-cosignature, c2sp.org/tlog-checkpoint, and c2sp.org/tlog-tiles functions, including extensions to the golang.org/x/mod/sumdb/tlog and golang.org/x/mod/sumdb/note packages.
Index ¶
- Constants
- func AppendTileEntry(tile []byte, entry []byte) ([]byte, error)
- func CheckHash(p HashProof, t int64, th tlog.Hash, i int64, h tlog.Hash) error
- func CheckRecordInSubtree(p RecordInSubtreeProof, start, end int64, sh tlog.Hash, n int64, h tlog.Hash) error
- func CheckSubtree(p SubtreeProof, t int64, th tlog.Hash, start, end int64, sh tlog.Hash) error
- func CosignatureTimestamp(sig note.Signature) (int64, error)
- func CoverInterval(start, end int64) (leftStart, mid int64, err error)
- func FormatProof(idx int64, p tlog.RecordProof, signedCheckpoint []byte) []byte
- func FormatProofWithExtraData(idx int64, extra []byte, p tlog.RecordProof, signedCheckpoint []byte) []byte
- func NewLogVerifier(vkey string) (note.Verifier, error)
- func NewVerifierFromSigner(skey string) (note.Verifier, error)
- func ParseTilePath(path string) (tlog.Tile, error)
- func ProofExtraData(proof []byte) ([]byte, error)
- func ReadSumDBEntry(tile []byte) (entry []byte, rh tlog.Hash, rest []byte, err error)
- func ReadTileEntry(tile []byte) (entry, rest []byte, err error)
- func RightEdge(n int64) []int64
- func SubtreeHash(start, end int64, r tlog.HashReader) (tlog.Hash, error)
- func TileHashReaderWithContext(ctx context.Context, tree tlog.Tree, tr TileReader) tlog.HashReader
- func TilePath(t tlog.Tile) string
- func ValidSubtree(start, end int64) bool
- func VerifyProof(policy Policy, rh tlog.Hash, proof []byte) error
- type Checkpoint
- type Client
- func (c *Client) AllEntries(ctx context.Context, tree tlog.Tree, start int64) iter.Seq2[int64, []byte]
- func (c *Client) Entries(ctx context.Context, tree tlog.Tree, start int64) iter.Seq2[int64, []byte]
- func (c *Client) Entry(ctx context.Context, tree tlog.Tree, index int64) ([]byte, tlog.RecordProof, error)
- func (c *Client) Err() error
- type ClientOption
- type CosignatureSigner
- func (s *CosignatureSigner) KeyHash() uint32
- func (s *CosignatureSigner) Name() string
- func (s *CosignatureSigner) Sign(msg []byte) ([]byte, error)
- func (s *CosignatureSigner) SignSubtree(origin string, start, end int64, hash tlog.Hash) ([]byte, error)
- func (s *CosignatureSigner) Verifier() *CosignatureVerifier
- type CosignatureVerifier
- func (v *CosignatureVerifier) KeyHash() uint32
- func (v *CosignatureVerifier) Name() string
- func (v *CosignatureVerifier) PublicKey() crypto.PublicKey
- func (v *CosignatureVerifier) String() string
- func (v *CosignatureVerifier) Verify(msg, sig []byte) bool
- func (v *CosignatureVerifier) VerifySubtree(origin string, start, end int64, hash tlog.Hash, signature []byte) bool
- type HashProof
- type HashReaderOverlay
- type PermanentCache
- type PermanentCacheOption
- type Policy
- type RecordInSubtreeProof
- type SubtreeProof
- type TileArchiveFS
- type TileFS
- type TileFSOption
- type TileFetcher
- type TileFetcherOption
- type TileReader
- type TileReaderWithContextdeprecated
- type VerifyRecordError
Constants ¶
const TileHeight = 8
const TileWidth = 1 << TileHeight
Variables ¶
This section is empty.
Functions ¶
func AppendTileEntry ¶ added in v0.6.0
AppendTileEntry appends the given entry to the entry bundle, according to c2sp.org/tlog-tiles.
func CheckHash ¶ added in v0.6.0
CheckHash verifies that p is a valid proof that the tree of size t with hash th has an i'th hash with hash h.
func CheckRecordInSubtree ¶ added in v0.10.0
func CheckRecordInSubtree(p RecordInSubtreeProof, start, end int64, sh tlog.Hash, n int64, h tlog.Hash) error
CheckRecordInSubtree verifies that p is a valid proof that the subtree [start, end) with hash sh contains the record with index n and hash h.
func CheckSubtree ¶ added in v0.10.0
CheckSubtree verifies that p is a valid proof that the tree of size t with hash th contains the subtree [start, end) with hash sh.
func CosignatureTimestamp ¶
CosignatureTimestamp returns the timestamp of the cosignature, which is the time at which the witness signed the checkpoint, in seconds since the Unix epoch.
Witnesses can re-sign a checkpoint, but only if it's for the latest tree they have seen. Thus, the timestamp can be used to determine if a checkpoint is fresh.
func CoverInterval ¶ added in v0.10.0
CoverInterval returns leftStart and mid for the two subtrees [leftStart, mid) and [mid, end) that cover the interval [start, end) as efficiently as possible.
The subtrees are adjacent and the second ends at end, but the first may begin before start. If the interval has size zero or one, the first subtree is the interval itself and the second is empty. If [start, end) is a subtree of size larger than one, the two subtrees are its children. See draft-ietf-plants-merkle-tree-certs, Section 4.5.
It is an error if start < 0 or end < start.
func FormatProof ¶ added in v0.9.0
func FormatProof(idx int64, p tlog.RecordProof, signedCheckpoint []byte) []byte
FormatProof formats a tlog record inclusion proof (a "spicy signature") for the record at index idx with proof p and signed checkpoint signedCheckpoint.
The returned byte slice is encoded according to c2sp.org/tlog-proof@v1.
func FormatProofWithExtraData ¶ added in v0.9.0
func FormatProofWithExtraData(idx int64, extra []byte, p tlog.RecordProof, signedCheckpoint []byte) []byte
FormatProofWithExtraData formats a tlog record inclusion proof (a "spicy signature") for the record at index idx with proof p and signed checkpoint signedCheckpoint, including extra data.
The returned byte slice is encoded according to c2sp.org/tlog-proof@v1.
func NewLogVerifier ¶ added in v0.10.0
NewLogVerifier parses a log vkey, which may use the Ed25519 signature algorithm or the ML-DSA-44 (sub)tree cosignature algorithm.
func NewVerifierFromSigner ¶
NewVerifierFromSigner constructs a new c2sp.org/signed-note note.Verifier from an encoded Ed25519 signer key, the same input as note.NewSigner.
func ParseTilePath ¶
ParseTilePath parses a tile coordinate path according to c2sp.org/tlog-tiles.
For the go.dev/design/25530-sumdb scheme, use tlog.ParseTilePath. For the c2sp.org/static-ct-api scheme, use filippo.io/sunlight/ParseTilePath.
func ProofExtraData ¶ added in v0.9.0
ProofExtraData extracts the extra data from a tlog proof encoded according to c2sp.org/tlog-proof@v1. If no extra data is present, it returns an error.
The extra data is unauthenticated and must not be trusted.
func ReadSumDBEntry ¶ added in v0.6.0
ReadSumDBEntry splits the next entry from a tile according to the go.dev/design/25530-sumdb format, for use with WithCutEntry.
func ReadTileEntry ¶ added in v0.6.0
ReadTileEntry reads the next entry from the entry bundle according to c2sp.org/tlog-tiles, and returns the remaining data in the tile.
func RightEdge ¶
RightEdge returns the stored hash indexes of the right edge of a tree of size n. These are the same hashes that are combined into a tlog.TreeHash and allow producing record and tree proofs for any size bigger than n. See tlog.StoredHashIndex for the definition of stored hash indexes.
n must not be greater than 2^62, the largest supported tree size; RightEdge panics otherwise.
func SubtreeHash ¶ added in v0.10.0
SubtreeHash computes the hash for the subtree [start, end) using the HashReader to obtain previously stored hashes. SubtreeHash makes at most a single call to ReadHash requesting at most 1 + log₂(end - start) hashes.
A tlog.TreeHash is a special case of a SubtreeHash where start is 0. The hash of an empty subtree is the hash of the empty string.
See draft-ietf-plants-merkle-tree-certs, Section 4.
func TileHashReaderWithContext ¶ added in v0.6.0
func TileHashReaderWithContext(ctx context.Context, tree tlog.Tree, tr TileReader) tlog.HashReader
TileHashReaderWithContext returns a HashReader that satisfies requests by loading tiles of the given tree.
It is equivalent to tlog.TileHashReader, but passes the ctx argument to the TileReader methods.
func TilePath ¶
TilePath returns a tile coordinate path describing t, according to c2sp.org/tlog-tiles.
For the go.dev/design/25530-sumdb scheme, use tlog.Tile.Path. For the c2sp.org/static-ct-api scheme, use filippo.io/sunlight/TilePath.
If t.Height is not TileHeight, TilePath panics.
func ValidSubtree ¶ added in v0.10.0
ValidSubtree reports whether [start, end) is a valid subtree. Note that empty subtrees [x, x) are valid.
See draft-ietf-plants-merkle-tree-certs, Section 4.
func VerifyProof ¶ added in v0.9.0
VerifyProof verifies a proof (a "spicy signature" encoded according to c2sp.org/tlog-proof@v1) for a record hash rh (generally produced with tlog.RecordHash).
If the note signatures do not satisfy the provided policy, an error wrapping *note.UnverifiedNoteError is returned. If the proof is valid but does not verify the record hash rh at the given index, a *VerifyRecordError is returned.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
Origin string
tlog.Tree
// Extension is empty or a sequence of non-empty lines,
// each terminated by a newline character.
Extension string
}
A Checkpoint is a tree head to be formatted according to c2sp.org/checkpoint.
A checkpoint looks like this:
example.com/origin 923748 nND/nri/U0xuHUrYSy0HtMeal2vzD9V4k/BO79C+QeI=
It can be followed by extra extension lines.
func ParseCheckpoint ¶
func ParseCheckpoint(text string) (Checkpoint, error)
ParseCheckpoint parses a c2sp.org/tlog-checkpoint payload without signatures.
func VerifyCheckpoint ¶ added in v0.9.0
VerifyCheckpoint parses and verifies a signed c2sp.org/tlog-checkpoint.
If the note signatures do not satisfy the provided policy, an error wrapping *note.UnverifiedNoteError is returned.
func (Checkpoint) String ¶
func (c Checkpoint) String() string
type Client ¶ added in v0.6.0
type Client struct {
// contains filtered or unexported fields
}
Client is a tlog client that fetches and authenticates tiles, and exposes log entries as a Go iterator or by their index.
func NewClient ¶ added in v0.6.0
func NewClient(tr TileReader, opts ...ClientOption) (*Client, error)
NewClient creates a new Client that fetches tiles using the given TileReader. The TileReader would typically be a TileFetcher, optionally wrapped in a PermanentCache to cache tiles on disk.
func (*Client) AllEntries ¶ added in v0.7.0
func (c *Client) AllEntries(ctx context.Context, tree tlog.Tree, start int64) iter.Seq2[int64, []byte]
AllEntries works like Client.Entries, but fetches all entries up to the size of the tree, including those in partial data tiles.
Callers that are tailing a growing log should instead use Client.Entries, and fetch a new tree every time iteration stops.
func (*Client) Entries ¶ added in v0.6.0
Entries returns an iterator that yields entries from the given tree, starting at the given index. The first item in the yielded pair is the overall entry index in the log, starting at start.
The provided tree should have been verified by the caller, for example by verifying the signatures on a Checkpoint.
Iteration may stop before the size of the tree to avoid fetching a partial data tile. Resuming with the same tree will yield the remaining entries, however clients tailing a growing log are encouraged to fetch the next checkpoint and use that as the tree argument. If this behavior is not desired, use Client.AllEntries instead.
Callers must check Client.Err after the iteration breaks.
func (*Client) Entry ¶ added in v0.6.0
func (c *Client) Entry(ctx context.Context, tree tlog.Tree, index int64) ([]byte, tlog.RecordProof, error)
Entry returns a log entry by its index, and an inclusion proof in the tree.
The provided tree should have been verified by the caller, for example by verifying the signatures on a Checkpoint.
func (*Client) Err ¶ added in v0.6.0
Err returns the error encountered by the latest Client.Entries call.
type ClientOption ¶ added in v0.6.0
type ClientOption func(*Client)
ClientOption is a function that configures a Client.
func WithCutEntry ¶ added in v0.6.0
func WithCutEntry(cut func(tile []byte) (entry []byte, rh tlog.Hash, rest []byte, err error)) ClientOption
WithCutEntry configures the function to split the next entry from a data tile (a.k.a. entry bundle).
The entry is surfaced by the Entries method, the record hash is used to check inclusion in the tree, and the rest is passed to the next invocation of cut.
The input tile is never empty. cut must not modify the tile.
By default, the c2sp.org/tlog-tiles#log-entries format is used, as implemented by ReadTileEntry. For the go.dev/design/25530-sumdb format, use ReadSumDBEntry. For the c2sp.org/static-ct-api format, use filippo.io/sunlight.Client instead.
func WithSumDBEntries
deprecated
added in
v0.6.0
func WithSumDBEntries() ClientOption
WithSumDBEntries configures the function to split the next entry from a tile according to the go.dev/design/25530-sumdb format.
Deprecated: use WithCutEntry with ReadSumDBEntry instead.
func WithTimeout ¶ added in v0.6.0
func WithTimeout(d time.Duration) ClientOption
WithTimeout configures the maximum duration the Client.Entries loop will block waiting for each next extry. The default is 5 minutes.
type CosignatureSigner ¶
type CosignatureSigner struct {
// contains filtered or unexported fields
}
CosignatureSigner is a note.Signer that produces timestamped cosignatures according to c2sp.org/tlog-cosignature.
func NewCosignatureSigner ¶
func NewCosignatureSigner(name string, key crypto.Signer) (*CosignatureSigner, error)
NewCosignatureSigner constructs a new CosignatureSigner from an ML-DSA-44 or Ed25519 private key.
Note that ML-DSA-44 cosigners reject checkpoints with extension lines.
func (*CosignatureSigner) KeyHash ¶
func (s *CosignatureSigner) KeyHash() uint32
func (*CosignatureSigner) Name ¶
func (s *CosignatureSigner) Name() string
func (*CosignatureSigner) SignSubtree ¶ added in v0.10.0
func (s *CosignatureSigner) SignSubtree(origin string, start, end int64, hash tlog.Hash) ([]byte, error)
SignSubtree signs a subtree [start, end) with the given hash for the log with the given origin. The timestamp is set to zero. The returned signature is in the format of a note signature, starting with the — and ending with a newline.
func (*CosignatureSigner) Verifier ¶
func (s *CosignatureSigner) Verifier() *CosignatureVerifier
type CosignatureVerifier ¶
type CosignatureVerifier struct {
// contains filtered or unexported fields
}
CosignatureVerifier is a note.Verifier that verifies cosignatures according to c2sp.org/tlog-cosignature.
func NewCosignatureVerifier ¶ added in v0.7.0
func NewCosignatureVerifier(vkey string) (*CosignatureVerifier, error)
NewCosignatureVerifier constructs a new CosignatureVerifier from a c2sp.org/signed-note vkey string. It supports ML-DSA-44 and Ed25519 vkeys.
Note that ML-DSA-44 verifiers reject cosignatures on checkpoints with extension lines.
func NewCosignatureVerifierFromKey ¶ added in v0.10.0
func NewCosignatureVerifierFromKey(name string, key crypto.PublicKey) (*CosignatureVerifier, error)
NewCosignatureVerifierFromKey constructs a new CosignatureVerifier from a public key. It supports ed25519.PublicKey and *mldsa.PublicKey.
Note that ML-DSA-44 verifiers reject cosignatures on checkpoints with extension lines.
func (*CosignatureVerifier) PublicKey ¶ added in v0.10.0
func (v *CosignatureVerifier) PublicKey() crypto.PublicKey
PublicKey returns the ed25519.PublicKey or *mldsa.PublicKey of the verifier, depending on the algorithm.
func (*CosignatureVerifier) String ¶
func (v *CosignatureVerifier) String() string
String returns the vkey encoding of the verifier, according to c2sp.org/signed-note.
func (*CosignatureVerifier) VerifySubtree ¶ added in v0.10.0
func (v *CosignatureVerifier) VerifySubtree(origin string, start, end int64, hash tlog.Hash, signature []byte) bool
VerifySubtree reports whether signature is a valid cosignature by this verifier over the subtree [start, end) with the given hash for the log with the given origin.
signature must be a single note signature line ending in a newline, like the one returned by CosignatureSigner.SignSubtree, and its key name and hash must match this verifier.
Note that a checkpoint cosignature is a valid cosignature over the equivalent subtree, and this method allows non-zero timestamps for root subtrees.
type HashProof ¶ added in v0.6.0
A HashProof is a verifiable proof that a particular tree head contains a particular subtree hash. A tlog.RecordProof is a special case of a HashProof where the subtree has size 1. A HashProof is a special case of a SubtreeProof where the subtree is full (i.e. the size is a power of two).
func ProveHash ¶ added in v0.6.0
func ProveHash(t, i int64, r tlog.HashReader) (HashProof, error)
ProveHash returns the proof that the tree of size t contains the hash with tlog.StoredHashIndex i.
type HashReaderOverlay ¶ added in v0.10.0
type HashReaderOverlay struct {
// contains filtered or unexported fields
}
A HashReaderOverlay is a tlog.HashReader for a tree that extends an original tree with appended records, whose stored hashes are held in memory.
It can be used to stage the hashes of new records before they are persisted, and to compute tree hashes, subtree hashes, proofs, and tiles that span both the original tree and the appended records.
The underlying HashReader is responsible for serving any requested hashes in the original tree. Which hashes are requested depends on the caller: HashReaderOverlay.AppendRecordHash, tlog.StoredHashes, tlog.TreeHash, and SubtreeHash only need the RightEdge of the original tree (as long as the tree or subtree extends past the original tree), while tlog.ReadTileData might need more (such as the full contents of the rightmost tiles).
func NewHashReaderOverlay ¶ added in v0.10.0
func NewHashReaderOverlay(n int64, r tlog.HashReader) *HashReaderOverlay
NewHashReaderOverlay returns a HashReaderOverlay over an original tree of size n, whose hashes are served by r. If n is 0, r may be nil.
n must not be negative or greater than 2^62, the largest supported tree size; NewHashReaderOverlay panics otherwise.
func (*HashReaderOverlay) AppendRecordHash ¶ added in v0.10.0
func (o *HashReaderOverlay) AppendRecordHash(rh tlog.Hash) error
AppendRecordHash extends the tree by one record with the given record hash (as produced by tlog.RecordHash), computing and adding the record's stored hashes to the overlay.
The hashes of completed subtrees may be requested from the overlay, which needs at most the RightEdge of the original tree from the underlying HashReader.
func (*HashReaderOverlay) ReadHashes ¶ added in v0.10.0
func (o *HashReaderOverlay) ReadHashes(indexes []int64) ([]tlog.Hash, error)
ReadHashes implements tlog.HashReader. Any hashes in the original tree are requested from the underlying HashReader in a single ReadHashes call.
func (*HashReaderOverlay) Size ¶ added in v0.10.0
func (o *HashReaderOverlay) Size() int64
Size returns the size of the extended tree: the size of the original tree plus the number of appended leaf records.
type PermanentCache ¶ added in v0.6.0
type PermanentCache struct {
// contains filtered or unexported fields
}
PermanentCache is a TileReader that caches verified, non-partial tiles in a filesystem directory. It passes through ReadEndpoint calls without caching.
func NewPermanentCache ¶ added in v0.6.0
func NewPermanentCache(tr TileReader, dir string, opts ...PermanentCacheOption) (*PermanentCache, error)
NewPermanentCache creates a new PermanentCache that caches tiles in the given directory. The directory must exist.
func (*PermanentCache) ReadEndpoint ¶ added in v0.6.0
ReadEndpoint passes through to the underlying TileReader.
func (*PermanentCache) ReadTiles ¶ added in v0.6.0
func (c *PermanentCache) ReadTiles(ctx context.Context, tiles []tlog.Tile) (data [][]byte, err error)
ReadTiles implements TileReader.
func (*PermanentCache) SaveTiles ¶ added in v0.6.0
func (c *PermanentCache) SaveTiles(tiles []tlog.Tile, data [][]byte)
SaveTiles implements TileReader.
type PermanentCacheOption ¶ added in v0.6.0
type PermanentCacheOption func(*PermanentCache)
PermanentCacheOption is a function that configures a PermanentCache.
func WithPermanentCacheLogger ¶ added in v0.6.0
func WithPermanentCacheLogger(log *slog.Logger) PermanentCacheOption
WithPermanentCacheLogger configures the logger used by the PermanentCache. By default, log lines are discarded.
func WithPermanentCacheTilePath ¶ added in v0.6.0
func WithPermanentCacheTilePath(tilePath func(tlog.Tile) string) PermanentCacheOption
WithPermanentCacheTilePath configures the function used to generate the tile path from a tlog.Tile. By default, PermanentCache uses the c2sp.org/tlog-tiles scheme implemented by TilePath. For the go.dev/design/25530-sumdb scheme, use tlog.Tile.Path. For the c2sp.org/static-ct-api scheme, use filippo.io/sunlight.TilePath.
type Policy ¶ added in v0.9.0
type Policy interface {
// Check returns nil if the provided signatures satisfy the policy.
//
// The signatures must already have been verified with their respective
// verifiers, and would usually be obtained from [note.Note.Sigs].
Check(origin string, sigs []note.Signature) error
// Verifier implements [note.Verifiers], returning the Verifier for any of
// the cosigners in the policy.
Verifier(name string, hash uint32) (note.Verifier, error)
}
Policy encodes the requirements for a set of (co)signatures on a c2sp.org/tlog-checkpoint.
The Verifier method allows the policy to be passed in as the known parameter to note.Open, while the Check method must be applied to note.Note.Sigs and Checkpoint.Origin after note.Open and ParseCheckpoint.
func OriginPolicy ¶ added in v0.9.0
OriginPolicy returns a Policy that enforces the provided origin string.
This is usually combined with a SingleVerifierPolicy for the log's public key Verifier, using ThresholdPolicy with a threshold of 2-of-2.
func ParsePolicy ¶ added in v0.9.0
ParsePolicy parses a Policy from the provided byte slice.
The policy format is EXPERIMENTAL and may change in future releases. It is based on the Sigsum policy format but it uses vkeys instead of raw public keys. It is compatible with Tessera witness policies. It currently requires the checkpoint origin to match the log vkey name.
func SingleVerifierPolicy ¶ added in v0.9.0
SingleVerifierPolicy returns a Policy that requires a single verifier to have signed the note. The origin is not restricted.
func ThresholdPolicy ¶ added in v0.9.0
ThresholdPolicy returns a Policy that requires at least n of the provided policies to be satisfied.
It panics if n is less than zero or greater than the number of polcies.
type RecordInSubtreeProof ¶ added in v0.10.0
A RecordInSubtreeProof is a verifiable proof that a particular subtree contains a particular record. A tlog.RecordProof is a special case of a RecordInSubtreeProof where the subtree has start index 0.
draft-ietf-plants-merkle-tree-certs calls this a "Subtree Inclusion Proof".
func ProveRecordInSubtree ¶ added in v0.10.0
func ProveRecordInSubtree(start, end, n int64, r tlog.HashReader) (RecordInSubtreeProof, error)
ProveRecordInSubtree returns the proof that the subtree [start, end) contains the record with index n.
type SubtreeProof ¶ added in v0.10.0
A SubtreeProof is a verifiable proof that a particular tree head contains a particular subtree. A tlog.TreeProof is a special case of a SubtreeProof where the subtree has start index 0. A tlog.RecordProof is a special case of a SubtreeProof where the subtree has size 1.
draft-ietf-plants-merkle-tree-certs calls this a "Subtree Consistency Proof".
func ProveSubtree ¶ added in v0.10.0
func ProveSubtree(t, start, end int64, r tlog.HashReader) (SubtreeProof, error)
ProveSubtree returns the proof that the tree of size t contains the subtree [start, end), where start and end are record indexes.
type TileArchiveFS ¶ added in v0.8.0
type TileArchiveFS struct {
// contains filtered or unexported fields
}
TileArchiveFS is an fs.FS that reads tiles and accessory files from a collection of zip files, numbered 000.zip, 001.zip, ...
Each zip file contains the corresponding level 2 tile, and all the full tiles below it. All other files (higher-level tiles, partial tiles on the right edge, checkpoint, etc.) are expected to be present in every zip file.
It supports both c2sp.org/tlog-tiles and c2sp.org/static-ct-api tile layouts, but not go.dev/design/25530-sumdb.
func NewTileArchiveFS ¶ added in v0.8.0
func NewTileArchiveFS(f fs.FS) *TileArchiveFS
NewTileArchiveFS creates a new TileArchiveFS that reads zip files from the root of the given fs.FS. f.Open must return files that implement io.ReaderAt.
func (*TileArchiveFS) Close ¶ added in v0.8.0
func (tf *TileArchiveFS) Close() error
type TileFS ¶ added in v0.8.0
type TileFS struct {
// contains filtered or unexported fields
}
TileFS is a TileReader that reads tiles from a fs.FS.
func NewTileFS ¶ added in v0.8.0
func NewTileFS(f fs.FS, opts ...TileFSOption) (*TileFS, error)
NewTileFS creates a new TileFS that reads tiles from the given fs.FS. By default, it expects tiles to be laid out according to c2sp.org/tlog-tiles.
func (*TileFS) ReadEndpoint ¶ added in v0.8.0
ReadEndpoint fetches an arbitrary path.
func (*TileFS) ReadTiles ¶ added in v0.8.0
ReadTiles implements TileReader.
type TileFSOption ¶ added in v0.8.0
type TileFSOption func(*TileFS)
TileFSOption is a function that configures a TileFS.
func WithGzipDataTiles ¶ added in v0.8.0
func WithGzipDataTiles() TileFSOption
WithGzipDataTiles configures the TileFS to transparently decompress gzip-compressed data tiles.
func WithTileFSTilePath ¶ added in v0.8.0
func WithTileFSTilePath(tilePath func(tlog.Tile) string) TileFSOption
WithTileFSTilePath configures the function used to generate the tile path from a tlog.Tile. By default, TileFS uses the c2sp.org/tlog-tiles scheme implemented by TilePath. For the go.dev/design/25530-sumdb scheme, use tlog.Tile.Path. For the c2sp.org/static-ct-api scheme, use filippo.io/sunlight.TilePath.
type TileFetcher ¶ added in v0.6.0
type TileFetcher struct {
// contains filtered or unexported fields
}
TileFetcher is a TileReader that fetches tiles from a remote server.
func NewTileFetcher ¶ added in v0.6.0
func NewTileFetcher(base string, opts ...TileFetcherOption) (*TileFetcher, error)
NewTileFetcher creates a new TileFetcher that fetches tiles from the given base URL. By default, it fetches tiles according to c2sp.org/tlog-tiles.
func (*TileFetcher) ReadEndpoint ¶ added in v0.6.0
ReadEndpoint fetches an arbitrary path.
It retries 429 and 5xx responses, and network errors.
func (*TileFetcher) ReadTiles ¶ added in v0.6.0
ReadTiles implements TileReader.
It retries 429 and 5xx responses, and network errors.
func (*TileFetcher) SaveTiles ¶ added in v0.6.0
func (f *TileFetcher) SaveTiles(tiles []tlog.Tile, data [][]byte)
SaveTiles implements TileReader. It does nothing.
type TileFetcherOption ¶ added in v0.6.0
type TileFetcherOption func(*TileFetcher)
TileFetcherOption is a function that configures a TileFetcher.
func WithConcurrencyLimit ¶ added in v0.6.0
func WithConcurrencyLimit(limit int) TileFetcherOption
WithConcurrencyLimit configures the maximum number of concurrent requests made by the TileFetcher. By default, there is no limit.
func WithHTTPClient ¶ added in v0.6.0
func WithHTTPClient(hc *http.Client) TileFetcherOption
WithHTTPClient configures the HTTP client used by the TileFetcher.
Note that TileFetcher may need to make multiple parallel requests to the same host, more than the default MaxIdleConnsPerHost.
func WithTileFetcherLogger ¶ added in v0.6.0
func WithTileFetcherLogger(log *slog.Logger) TileFetcherOption
WithTileFetcherLogger configures the logger used by the TileFetcher. By default, log lines are discarded.
func WithTilePath ¶ added in v0.6.0
func WithTilePath(tilePath func(tlog.Tile) string) TileFetcherOption
WithTilePath configures the function used to generate the tile path from a tlog.Tile. By default, TileFetcher uses the c2sp.org/tlog-tiles scheme implemented by TilePath. For the go.dev/design/25530-sumdb scheme, use tlog.Tile.Path. For the c2sp.org/static-ct-api scheme, use filippo.io/sunlight.TilePath.
func WithUserAgent ¶ added in v0.6.0
func WithUserAgent(ua string) TileFetcherOption
WithUserAgent configures the User-Agent header used by the TileFetcher. By default, the User-Agent is "filippo.io/torchwood.Client".
type TileReader ¶ added in v0.6.0
type TileReader interface {
// ReadTiles returns the data for each requested tile.
// See [tlog.TileReader.ReadTiles] for details.
ReadTiles(ctx context.Context, tiles []tlog.Tile) (data [][]byte, err error)
// SaveTiles informs the TileReader that the tile data has been confirmed.
// See [tlog.TileReader.SaveTiles] for details.
SaveTiles(tiles []tlog.Tile, data [][]byte)
// ReadEndpoint fetches an arbitrary endpoint at the given path, such as
// "checkpoint", if supported.
ReadEndpoint(ctx context.Context, path string) (data []byte, err error)
}
TileReader is an interface equivalent to tlog.TileReader, but with a context parameter for cancellation, a fixed TileHeight, and a method to fetch arbitrary additional endpoints, if available.
type TileReaderWithContext
deprecated
added in
v0.6.0
type TileReaderWithContext = TileReader
TileReaderWithContext is an obsolete name for TileReader.
Deprecated: use TileReader instead.
type VerifyRecordError ¶ added in v0.9.0
VerifyRecordError is returned by VerifyProof when the inclusion proof does not verify. It can be used to diagnose the issue or print a better error message. All of its fields are unauthenticated and must not be trusted.
func (*VerifyRecordError) Error ¶ added in v0.9.0
func (e *VerifyRecordError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bastion runs a reverse proxy service that allows un-addressable applications (for example those running behind a firewall or a NAT, or where the operator doesn't wish to take the DoS risk of being reachable from the Internet) to accept HTTP requests.
|
Package bastion runs a reverse proxy service that allows un-addressable applications (for example those running behind a firewall or a NAT, or where the operator doesn't wish to take the DoS risk of being reachable from the Internet) to accept HTTP requests. |
|
cmd
|
|
|
age-keylookup
command
|
|
|
age-keyserver
command
|
|
|
age-keyserver-keygen
command
|
|
|
litebastion
command
Command litebastion runs a reverse proxy service that allows un-addressable applications (for example those running behind a firewall or a NAT, or where the operator doesn't wish to take the DoS risk of being reachable from the Internet) to accept HTTP requests.
|
Command litebastion runs a reverse proxy service that allows un-addressable applications (for example those running behind a firewall or a NAT, or where the operator doesn't wish to take the DoS risk of being reachable from the Internet) to accept HTTP requests. |
|
litewitness
command
|
|
|
spicy
command
|
|
|
witnessctl
command
|
|
|
internal
|
|
|
mpt
|
|
|
internal/pmem
Package pmem implements persistent, transactional memory backed by on-disk files.
|
Package pmem implements persistent, transactional memory backed by on-disk files. |
|
internal/slicemath
Package slicemath implements safe “pointer arithmetic” on slices.
|
Package slicemath implements safe “pointer arithmetic” on slices. |
|
internal/span
Package span implements growable memory spans.
|
Package span implements growable memory spans. |
|
Package prefix implements a compressed binary Merkle trie, or prefix tree: an append-only compressed key-value accumulator based on a sparse binary Merkle tree.
|
Package prefix implements a compressed binary Merkle trie, or prefix tree: an append-only compressed key-value accumulator based on a sparse binary Merkle tree. |
|
Package tesserax implements additional functions for use with the tessera package.
|
Package tesserax implements additional functions for use with the tessera package. |