libtrust

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 17 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 libtrust decides whether the device libraries and framework a build compiles are ones the user approved. The Volt IDE is the only approver: it holds the private half of a per-computer Ed25519 key, and each approval is a signed record of a library's exact bytes in ~/.volt/trust/approved.json. A library an AI agent (or anything else) writes or changes no longer matches its record, so `volt build` refuses it until the user reviews it in the IDE.

The store is tamper-evident, not tamper-proof: records can't be forged without the private key, but a same-user process could swap local.pub and re-sign. The IDE pins the key's fingerprint in the OS keychain and flags that.

Index

Constants

View Source
const Framework = "@framework"

Framework is the store name of the framework tree (device prefixes are C identifiers, so it can't collide with one).

Variables

This section is empty.

Functions

func Approve

func Approve(dir string, privPEM []byte, libs []Library, source, version string) error

Approve signs the current digest of each library into the store, using the private key PEM (which must match local.pub).

func BundledDigests

func BundledDigests(sdk fs.FS) map[string]string

BundledDigests digests a built-in SDK tree (devices/, framework/).

func Digest

func Digest(fsys fs.FS, root string) (string, error)

Digest hashes every file under root in fsys: sorted slash paths relative to root, each as "path\0size\0bytes". Anything but a regular file or directory (a symlink could pull in code from outside) is an error.

func Dir

func Dir() (string, error)

Dir is ~/.volt/trust.

func Fingerprint

func Fingerprint(pub ed25519.PublicKey) string

Fingerprint identifies a public key.

func Init

func Init(dir string, force bool) ([]byte, error)

Init makes a new approval key: it writes local.pub (and an empty store) to dir and returns the private key PEM for the IDE to keep in the keychain. Existing approvals are signed by the old key, so re-keying drops them.

func Revoke

func Revoke(dir string, names []string) error

Revoke drops approvals (no key needed: it only takes trust away).

Types

type Entry

type Entry struct {
	Hash       string `json:"hash"`
	Version    string `json:"version,omitempty"`
	Source     string `json:"source"` // sdk-baseline | local | ai | registry:<keyId>
	ApprovedAt string `json:"approvedAt"`
	Sig        string `json:"sig"`
}

Entry is one approval: the digest of a library's files when it was approved.

type Library

type Library struct {
	Name string // device prefix, or Framework
	FS   fs.FS
	Root string
	// Key is where its approvals are recorded; "" means Name. A project's own
	// libraries are keyed by the project's folder, so two projects can each
	// have a library of the same name without sharing approvals.
	Key string
}

Library is one thing a build compiles: a device folder or the framework.

func Libraries

func Libraries(devices, framework string) ([]Library, error)

Libraries lists the framework and every device folder (one holding a device.json) in sdkDir's layout: <framework>/, <devices>/<prefix>/.

func ProjectLibraries

func ProjectLibraries(project string) ([]Library, error)

ProjectLibraries lists the project's own device libraries (<project>/devices/<prefix>/ holding a device.json). None is not an error.

type Status

type Status struct {
	Name           string `json:"name"`
	Hash           string `json:"hash"`
	State          string `json:"state"` // approved | changed | unapproved | invalid | unreadable
	Detail         string `json:"detail,omitempty"`
	Source         string `json:"source,omitempty"`
	Version        string `json:"version,omitempty"`
	ApprovedAt     string `json:"approvedAt,omitempty"`
	MatchesBundled bool   `json:"matchesBundled"` // bytes equal this CLI's built-in copy
	Bundled        bool   `json:"bundled"`        // Volt ships a library by this name
	// ApprovedHashes are the versions with a valid approval (newest last).
	ApprovedHashes []string `json:"approvedHashes"`
}

Status of one library against the store.

func Check

func Check(st *Store, pub ed25519.PublicKey, libs []Library, bundled map[string]string) []Status

Check compares each library with its approval. bundled, when non-nil, maps a name to this CLI's built-in digest of it.

type Store

type Store struct {
	Schema  int                `json:"schema"`
	Key     string             `json:"key"` // fingerprint of the signing key
	Entries map[string][]Entry `json:"entries"`
}

Store is approved.json. A library may have several approved versions (one per device-library location, or older versions), newest last.

func Load

func Load(dir string) (st *Store, pub ed25519.PublicKey, ok bool, err error)

Load reads the store and local public key from dir. ok is false when approvals were never set up (no store and no key).

Jump to

Keyboard shortcuts

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