anchor

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package anchor writes the head of the audit chain somewhere the machine that keeps the log cannot rewrite. The chain shows every edit, deletion and insertion by itself; only a cut-off end needs an outside witness, and an anchor is that witness: a statement "the chain reached seq N with hash H at time T", kept in a file, posted to a webhook or timestamped in Bitcoin through OpenTimestamps. `agentgate verify --anchors` checks them all.

Index

Constants

This section is empty.

Variables

View Source
var DefaultCalendars = []string{"https://a.pool.opentimestamps.org", "https://b.pool.opentimestamps.org"}

DefaultCalendars are the public OpenTimestamps calendars. A proof from any one of them is enough; asking two keeps one outage from losing it.

Functions

func Read

func Read(path string) ([]audit.Link, error)

Read loads the anchors kept in a file: JSON statements one per line, or plain seq:hash lines as verify prints them. Blank lines and lines starting with # are skipped.

func ReadDir

func ReadDir(dir string) ([]audit.Link, error)

ReadDir loads every anchor statement an ots: destination left in dir.

Types

type Destination

type Destination interface {
	Publish(ctx context.Context, s Statement) (string, error)
	String() string
}

Destination is where a statement goes. Parse reads one.

func Parse

func Parse(s string, client *http.Client) (Destination, error)

Parse reads a destination:

https://example.com/hook   POST the statement as JSON (an ntfy topic URL works)
ots:./anchors              stamp it with OpenTimestamps, keep the proof in the directory
file:./anchors.jsonl       append it to a file (also: a bare path)

type File

type File struct{ Path string }

File appends statements to a file, one per line. Put it in a git repository, a synced folder or a mounted share and it is out of reach of whoever edits the log.

func (File) Publish

func (f File) Publish(_ context.Context, s Statement) (string, error)

Publish appends the statement.

func (File) String

func (f File) String() string

type OTS

type OTS struct {
	Dir       string
	Calendars []string
	Client    *http.Client
}

OTS stamps statements with OpenTimestamps: the statement's hash goes to public calendars, which commit it to the Bitcoin blockchain within hours. The proof is kept next to the statement as anchor-<seq>.json.ots; once the calendars have committed, `ots upgrade` completes it and `ots verify` shows the block that dates it, without trusting agentgate or this machine.

func (OTS) Publish

func (o OTS) Publish(ctx context.Context, s Statement) (string, error)

Publish stamps the statement and writes it and its proof to Dir.

func (OTS) String

func (o OTS) String() string

type Statement

type Statement struct {
	Seq  int64     `json:"seq"`
	Hash string    `json:"hash"`
	At   time.Time `json:"at"`
	Host string    `json:"host,omitempty"`
	Log  string    `json:"log,omitempty"`
}

Statement is one anchor.

func New

func New(head audit.Link, log string) Statement

New makes a statement for a link, now.

func (Statement) Line

func (s Statement) Line() []byte

Line is the statement as one line of JSON, which is what every destination stores and what OpenTimestamps stamps.

func (s Statement) Link() audit.Link

Link is the chain position the statement names.

Jump to

Keyboard shortcuts

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