Skip to content

Package audit/verify ​

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

github.com/bide-ai/bide/audit/verify · pkg.go.dev · Stability: core

Package verify is a dependency-light, standalone verifier for Bide audit proofs.

Functions

  • func AnchorLeaf(entry []byte) []byte: AnchorLeaf returns the leaf bytes of an anchor log entry from its JSON: "bide.audit.anchor-leaf.v1\x00" || entry.
  • func Consistency(first, size int, path [][]byte, firstRoot, laterRoot []byte) bool: Consistency runs the RFC 6962 §2.1.2 consistency-proof algorithm: reports whether firstRoot (over the first first leaves) is an append-only prefix of laterRoot (over size leaves).
  • func EventLeaf(event []byte) []byte: EventLeaf returns the leaf bytes of an event from its canonical JSON, the event's salt included ({"kind":...,"event":...,"salt":...}, with a snake_case kind and event, and the salt the event's proof discloses in base64): "bide.audit.event-leaf.v3\x00" || event.
  • func Inclusion(root, leaf []byte, index, size int, path [][]byte) bool: Inclusion runs the RFC 6962 §2.1.1 inclusion-proof algorithm: leaf is the canonical leaf bytes (JournalLeaf, KeyLeaf, EventLeaf, or AnchorLeaf of the content), index/size locate it in the tree, path is the sibling hashes leaf-to-root, and root is the committed Merkle root (an STH's Root).
  • func JournalLeaf(record []byte) []byte: JournalLeaf returns the leaf bytes of a journal record from the bytes a store persists for it (a proof's record_bytes, verbatim, including its "salt"): "bide.audit.journal-leaf.v1\x00" || record.
  • func KeyLeaf(key string) []byte: KeyLeaf returns the leaf bytes of an absence key: "bide.audit.key-leaf.v1\x00" || key.
  • func TreeHead(h Head, sig []byte, v Verifier) bool: TreeHead reports whether sig is a valid signature, under v, of the signed tree head h.

type Head ​

go
type Head struct {
	Alg            string
	Kind           string
	RunID          string
	Size           int
	Root           []byte
	TimestampNanos int64
	Journal        *TreeRef
}

Head is the content of a signed tree head (the "sth" of a proof): the scheme it is signed under, the tree's kind and run, its size and root, when it was signed, and, for an absence key-set head, the source journal tree.

type TreeRef ​

go
type TreeRef struct {
	Size int    `json:"size"`
	Root []byte `json:"root"`
}

TreeRef names one tree by its size and root: the source journal of an absence key-set head.

type Verifier ​

go
type Verifier interface {
	Alg() string

	Verify(message, sig []byte) bool
}

Verifier checks signatures under one scheme with one public key.

Constructors and functions

  • func NewVerifier(alg string, pub []byte) (Verifier, error): NewVerifier returns the verifier of scheme alg for the encoded public key pub, with the encodings the audit package uses: ed25519, the 32-byte key; ecdsa-p256, the 65-byte SEC1 uncompressed point (0x04 || X || Y), whose signatures are 64-byte low-S r||s over SHA-256 of the message; ml-dsa-65, the 1952-byte ML-DSA-65 public key; ed25519+ml-dsa-65, a 4-byte big-endian length of the Ed25519 key, the Ed25519 key, then the ML-DSA-65 key.

Apache-2.0 licensed.