proof

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package proof verifies a proof packet under NO-PROOF-NO-CLOSE: every declared artifact exists on disk and its bytes hash to the recorded digest. The digest is identity.Hash (sha256[:16]), binding the packet to the exact bytes it covers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(path string, pkt *Packet) error

Save writes a packet manifest to path as indented JSON, creating the directory if needed and writing atomically so a crash never leaves a half-written manifest.

func Verify

func Verify(root string, pkt *Packet) error

Verify checks that every artifact in pkt exists under root and matches its recorded digest. It returns EINVALID when the packet declares nothing and ECONFLICT on the first missing artifact or digest mismatch. Provenance is not a gate condition: a packet verifies on its bytes regardless of the commit it records, so a proof created at one commit still verifies at another.

Types

type Artifact

type Artifact struct {
	Path   string `json:"path"`
	Digest string `json:"sha256"`
}

Artifact is one declared piece of proof: a repository-relative path and the expected content digest.

type Packet

type Packet struct {
	Arc        string      `json:"arc"`
	Provenance *Provenance `json:"provenance,omitempty"`
	Artifacts  []Artifact  `json:"artifacts"`
}

Packet is a declared proof: the artifacts that must exist and match, plus optional provenance. Provenance is nil when none was recorded (e.g. no git repo).

func Create

func Create(root, arc, gitSHA string, paths []string) (Packet, error)

Create builds a proof packet for arc by hashing each path's bytes under root (identity.Hash, sha256[:16]). Paths are recorded repo-relative, exactly as Verify resolves them. gitSHA records provenance; an empty gitSHA records none. The caller resolves the SHA and passes it, so proof needs no version-control dependency. A proof must cover real bytes: an empty path set is EINVALID and an unreadable artifact is an error, never a silent skip.

func Load

func Load(path string) (Packet, error)

Load reads a packet manifest from a JSON file.

type Provenance

type Provenance struct {
	GitSHA string `json:"git_sha,omitempty"`
}

Provenance records where a proof packet came from: the commit the proof was created against. It is optional and informational — the gate binds a packet to its bytes by digest; the git SHA binds it to a commit.

Jump to

Keyboard shortcuts

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