Skip to content

Package audit/anchorobj ​

Go module github.com/bide-ai/bide; all packages.

github.com/bide-ai/bide/audit/anchorobj · pkg.go.dev · Stability: experimental

Package anchorobj is the part of an object-store audit anchor that does not depend on any storage SDK: the layout of the objects that hold signed tree heads, their canonical body, the checks a Reader makes on an object it reads back, the equivocation check, and the tripwire for run IDs that look like personal data.

Constants

  • const SizeDigits = 19: SizeDigits is the width of the inverted size in an object name.
  • const DigestHex = 32: DigestHex is the length of the digest in an object name, in hex digits.
  • const ObjectSuffix = ".json": ObjectSuffix ends every object name.
  • const PartitionLen = 64: PartitionLen is the length of a partition name (a hex SHA-256).
  • const MaxObjectBytes = 1 << 20: MaxObjectBytes bounds what is read for one object: a head is a few hundred bytes plus the run ID, and no object an anchor writes is near this size.

Functions

  • func CheckEquivocation(heads []audit.SignedTreeHead, errEquivocation error) error: CheckEquivocation returns an error wrapping errEquivocation when two heads of one tree and size commit to different roots: the log key signed two histories.
  • func InvertedSize(size int) string: InvertedSize is the sortable, fixed-width form of a head size: larger sizes sort first.
  • func ObjectName(size int, body []byte) string: ObjectName is the name of a body within its partition: inverted size, then its digest.
  • func SplitKey(prefix, key string) (partition, name string, ok bool): SplitKey splits a key under prefix into its partition and name.
  • func SuspectID(id string) string: SuspectID returns a reason when a run or trail ID looks like it holds personal data, or "".

type Layout ​

go
type Layout struct {
	Format string

	PartitionTag string

	ErrObject error

	ErrBadSignature error
}

Layout is one backend's naming and encoding of anchored heads.

Methods

  • func (l Layout) Collides(other Layout) bool: Collides reports whether two layouts could take each other's objects: the same format or the same partition tag.
  • func (l Layout) Decode(partition, name string, body []byte, v audit.Verifier) (audit.SignedTreeHead, error): Decode checks that body is the object the key names (partition and name) and returns its head.
  • func (l Layout) Encode(sth audit.SignedTreeHead) ([]byte, error): Encode is the body of the object that anchors sth.
  • func (l Layout) Key(prefix, kind, runID string, size int, body []byte) string: Key is the full key of a body for a head of the given kind, run and size.
  • func (l Layout) LoadDir(dir string, v audit.Verifier, errNotFound, errEquivocation error) ([]audit.SignedTreeHead, error): LoadDir reads a downloaded set of anchored objects (for example the output of "aws s3 sync" or "gcloud storage cp -r" of the anchor prefix) and verifies each against v.
  • func (l Layout) Partition(kind, runID string) string: Partition is the partition name of a tree kind and run ID.
  • func (l Layout) Validate() error: Validate reports why l cannot be used: an empty format, a partition tag that does not end in a NUL byte (so that one tag could be a prefix of another), or a missing error value (an error wrapping a nil error would match nothing).

type Name ​

go
type Name struct {
	Size   int
	Digest string
}

Name is the parts of an object name.

Constructors and functions

  • func ParseName(name string) (Name, bool): ParseName splits "<inverted size>-<digest>.json".

Apache-2.0 licensed.