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

sign

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 3 Imported by: 0

Documentation

Overview

Package sign is the pure trust-contract core of StageFreight signing. It owns the neutral IR (SignPlan) and the total Compile lowering — the stable model that insulates the rest of the system from cosign. It imports config (which owns the policy structs + validation) and NEVER imports cosign: the cosign renderer (src/sign/cosign) is an edge that satisfies these requirements, not a participant in the model. See docs/design/plans/signing-trust-model.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DerefKeyRef

func DerefKeyRef(ref string) string

DerefKeyRef resolves a key reference to its concrete value WITHOUT existence checking: "env:VAR" → the environment value; otherwise the path verbatim. The one canonical place the "env:VAR vs path" grammar is parsed — shared by Enabled (which adds an existence check) and the renderer's witness resolution, so the two can never diverge.

func Enabled

func Enabled(p SignPlan) bool

Enabled reports whether a plan should actually sign. It preserves today's no-key-no-signing for the implicit `legacy` key path: a key-class plan whose key reference does not resolve is disabled (no signature, not an error). This is the only env-dependent function here; Compile stays pure.

func SignerRef

func SignerRef(p SignPlan) string

SignerRef returns the signer identity material a plan signs under, for recording as trust evidence (never for execution). Key/kms: the logical ref; oidc: the (issuer, subject) identity; empty when nothing identifies the signer.

Types

type Class

type Class string

Class is a trust class — the kind of authority a signature carries.

const (
	ClassKey      Class = "key"
	ClassOIDC     Class = "oidc"
	ClassKMS      Class = "kms"
	ClassHardware Class = "hardware"
)

type IdentityConstraints

type IdentityConstraints struct {
	Issuer  string
	Subject string
}

IdentityConstraints expresses an expected signer identity (oidc/keyless). Both fields optional; empty = no constraint (record-only at v1).

type Op

type Op string

Op is a signing operation; the renderer maps each to a concrete invocation.

const (
	OpSignImage Op = "sign-image"
	OpAttest    Op = "attest"
	OpSignBlob  Op = "sign-blob"
)

type SignOptions

type SignOptions struct {
	MultiArch     bool
	PredicatePath string
	PredicateType string // attestation predicate type (e.g. "slsaprovenance"); caller-set, never executor-defaulted
}

SignOptions carry per-invocation inputs that are not trust requirements.

type SignPlan

type SignPlan struct {
	// ── Trust requirements (what must be true) ──
	TrustClass               Class
	TransparencyRequired     bool // the signature must be recorded in a transparency log
	RequiresPhysicalPresence bool // the signer must demonstrate physical presence
	RequiresNonExportableKey bool // the signing key must be hardware-bound / non-exportable
	Identity                 IdentityConstraints

	// ── Logical references (bound to keys/URIs only at render time) ──
	KeyRef    string // key class: "path" or "env:VAR"
	KMSRef    string // kms class: a logical ref, bound to a URI by the renderer
	PKCS11Ref string // hardware class: a logical ref → pkcs11: URI via SF_PKCS11_<REF> (absent = FIDO2 --sk)

	// ── Execution modifier (kept distinct so policy logic never leaks here) ──
	Attestation bool // also emit a provenance attestation
}

SignPlan is the insulation boundary AS DATA — a declarative trust CONTRACT ("what must be true for a signature to be acceptable"), never an execution plan. It deliberately carries NO cosign vocabulary (no --sk/--key/mode/URI): the only code that turns these requirements into an invocation is the renderer, by satisfying them against a declared capability Env. Renderer-shaped fields (UseKeyless, CosignMode, UploadTlog, …) must never appear here — that erosion is exactly what collapses the "cosign as edge renderer" invariant.

func Compile

Compile lowers a validated, resolved profile to its trust contract. It is a deterministic, TOTAL transform: config.ValidateSigningProfiles is the single validation layer, so Compile has no error path and never re-validates. Purity is over the LOGICAL policy — refs stay logical (KeyRef/KMSRef are resolved to concrete keys/URIs only at render time, never here).

Directories

Path Synopsis
Package anchordoc generates the canonical signing-anchor documentation — a managed, idempotent section embedded in an operator-owned file (conventionally SECURITY.md).
Package anchordoc generates the canonical signing-anchor documentation — a managed, idempotent section embedded in an operator-owned file (conventionally SECURITY.md).
Package autosign resolves the effective signer for a target, applying Tier-0 auto-provision ONLY when the operator has consented (enabled && auto_provision && a configured state_dir).
Package autosign resolves the effective signer for a target, applying Tier-0 auto-provision ONLY when the operator has consented (enabled && auto_provision && a configured state_dir).
Package cosign is the ONLY cosign-aware code in StageFreight signing — the edge renderer that satisfies a sign.SignPlan (a declarative trust contract) against a declared capability Env, emitting a concrete cosign invocation.
Package cosign is the ONLY cosign-aware code in StageFreight signing — the edge renderer that satisfies a sign.SignPlan (a declarative trust contract) against a declared capability Env, emitting a concrete cosign invocation.
Package provision manages StageFreight's auto-provisioned Tier-0 signing identity — a persistent software cosign keypair living in the operator's signing state dir.
Package provision manages StageFreight's auto-provisioned Tier-0 signing identity — a persistent software cosign keypair living in the operator's signing state dir.

Jump to

Keyboard shortcuts

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