attest

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package attest provides capture-time, off-host-verifiable signing for evidence - the difference between an audit log and an audit log a defender can trust after host compromise.

AgentProvenance's `graph verify` recomputes hashes from a SQLite file the attacker controls post-root: rewrite the row, recompute the chain, verify passes. That is integrity against corruption, not tamper-evidence against the HIDS threat model. This package signs an evidence digest with a key at capture time so that, even if the store is later rewritten, the signature over the original digest no longer verifies.

The formats are deliberately standard rather than bespoke:

  • the payload is an in-toto Statement (subject digests + a predicate),
  • the envelope is DSSE (Dead Simple Signing Envelope, the in-toto/SLSA transport), with ed25519 signatures.

The signing key here is a local ed25519 key (file/env). Anchoring it in a TPM or remote KMS so it is unobtainable after root, and posting the chain head to an external transparency log, are deployment concerns layered on top of this primitive; the wire format does not change.

Index

Constants

View Source
const (
	StatementType        = "https://in-toto.io/Statement/v1"
	DefaultPredicateType = "https://agentprovenance.dev/Evidence/v1"
)

StatementType and PredicateType identify the in-toto payload.

Variables

This section is empty.

Functions

func DigestSHA256

func DigestSHA256(data []byte) string

DigestSHA256 returns the hex sha256 of data, the canonical subject digest.

func GenerateKey

func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, string, error)

GenerateKey returns a fresh ed25519 keypair and its key id (a short hash of the public key), for tests and bootstrap.

func KeyID

func KeyID(pub ed25519.PublicKey) string

KeyID is a stable short identifier for a public key (first 16 hex of its sha256), used to tag signatures so a verifier can select the right key.

func LoadPrivateKeyHex

func LoadPrivateKeyHex(path string) (ed25519.PrivateKey, error)

LoadPrivateKeyHex loads a hex-encoded ed25519 private key (seed or full key) from path. A 32-byte value is treated as a seed; a 64-byte value as the full private key. This keeps the on-disk format trivial; a TPM/KMS-backed signer would implement the same Sign call without changing the wire format.

func LoadPublicKeyHex

func LoadPublicKeyHex(path string) (ed25519.PublicKey, error)

LoadPublicKeyHex loads a hex-encoded ed25519 public key from path.

Types

type Envelope

type Envelope struct {
	PayloadType string      `json:"payloadType"`
	Payload     string      `json:"payload"` // base64(canonical statement JSON)
	Signatures  []Signature `json:"signatures"`
}

Envelope is a DSSE envelope carrying a base64 payload and ed25519 signatures.

func Sign

func Sign(stmt Statement, key ed25519.PrivateKey, keyID string) (Envelope, error)

Sign produces a DSSE envelope over the statement. The pre-authentication encoding (PAE) follows the DSSE spec so the signature is bound to both the payload type and the payload bytes.

type Signature

type Signature struct {
	KeyID string `json:"keyid,omitempty"`
	Sig   string `json:"sig"`
}

Signature is one DSSE signature: base64(sig) plus an optional key id.

type Statement

type Statement struct {
	Type          string    `json:"_type"`
	Subject       []Subject `json:"subject"`
	PredicateType string    `json:"predicateType"`
	Predicate     any       `json:"predicate,omitempty"`
}

Statement is an in-toto v1 statement: what is being attested (subjects) and the claim about it (predicate).

func NewStatement

func NewStatement(subjectName, sha256hex string, predicate any) Statement

NewStatement builds an in-toto statement over a single subject digest.

func Verify

func Verify(env Envelope, pub ed25519.PublicKey) (Statement, error)

Verify checks that at least one signature on the envelope is valid for pub and returns the decoded statement. It fails closed: any decode error, or no valid signature, is an error.

type Subject

type Subject struct {
	Name   string            `json:"name"`
	Digest map[string]string `json:"digest"` // e.g. {"sha256": "..."}
}

Subject is a signed-over artifact identified by its content digest.

Jump to

Keyboard shortcuts

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