Help us shape the future of Go! Take the 2026 Go Developer Survey

verify

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package verify is a dependency-light, standalone verifier for Bide audit proofs. It depends on nothing but the Go standard library (crypto/sha256, crypto/ed25519, encoding/binary, bytes, math/bits, strings), deliberately NOT the agent core or gsm, so a third party (an auditor, a regulator) can verify a proof without importing the SDK, or reimplement this file from RFC 6962 and check us against it. That is what "verifiable without trusting the vendor" means in practice.

It operates on canonical LEAF BYTES, not typed records, precisely so it needs no domain types. A leaf's bytes are a versioned tag naming its kind followed by its content: JournalLeaf builds a journal record's leaf from the record's journal encoding (the bytes a store persists, the record's random salt included), KeyLeaf an absence key's, EventLeaf an event's (its random salt included), and AnchorLeaf an anchor entry's. The algorithms mirror the audit package exactly and are cross-checked against it in the tests, so the intentional duplication cannot drift.

This mirror is verification-only, by design: it can check a proof, never mint one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnchorLeaf added in v0.7.0

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

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 added in v0.7.0

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":...}, the salt the event's proof discloses, in base64): "bide.audit.event-leaf.v2\x00" || event.

func Inclusion

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). Reports whether leaf is provably at index in a size-leaf tree committed by root.

func JournalLeaf added in v0.7.0

func JournalLeaf(record []byte) []byte

JournalLeaf returns the leaf bytes of a journal record from its journal encoding (the JSON a store persists for it, including its "salt"): "bide.audit.journal-leaf.v1\x00" || record.

func KeyLeaf added in v0.7.0

func KeyLeaf(key string) []byte

KeyLeaf returns the leaf bytes of an absence key: "bide.audit.key-leaf.v1\x00" || key.

func TreeHead

func TreeHead(kind, runID string, size int, root []byte, timestamp int64, journal *TreeRef, sig, pub []byte) bool

TreeHead reports whether sig is a valid Ed25519 signature, under pub, of the signed tree head committing to (kind, runID, size, root, timestamp, journal). kind is the tree's kind ("journal", "events", or an "absence/..." key set); journal is the source journal tree of an absence key-set head and nil otherwise. The canonical encoding is domain-separated and length-prefixed, byte-identical to audit.TreeHead.canonical(), so an STH signed by the SDK verifies here and vice versa. The caller checks that kind and runID are the tree it expects.

Like audit, it refuses a head whose shape no commitment has, whatever its signature: a "journal" or "events" head that names a source journal, an "absence/<set>" head that names none, and a head of any other kind.

Types

type TreeRef added in v0.7.0

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.

Jump to

Keyboard shortcuts

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