Files
terminarandClaude Opus 5.5 35f8b7d18a trust: the verifying half of publisher signatures (own module)
Moved from yet/internal/trust, behavior and file formats unchanged, so
yacota (images) checks against the same trust-policy.json and
known-keys.json as yet (packages): the signature payload and its check
(Verify over fetched referrers), known keys with TOFU pinning
(Reconcile; refusals are ErrRefused), the trust policy (Evaluate,
AllowsCapability), Curated, Pinned and Home (yet's data directory).
Signing, key storage and the registry side stay in yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:27:35 +01:00

38 lines
1.1 KiB
Go

package trust
import (
"yetano.dev/yetano/core"
"yetano.dev/yetano/core/paths"
)
// Home is the directory of a host's trust state: yet's data directory
// (core/paths' DataDir for "yet" in scope), which holds
// trust-policy.json (DefaultPolicyPath) and known-keys.json
// (DefaultKnownKeysPath). Every program that checks signatures reads
// these, so a host has one trust policy and one set of pinned keys,
// whichever program pulled first.
func Home(scope core.Scope) (string, error) {
r, err := paths.New(core.Application{Name: "yet", Kind: core.CLI, Scope: scope})
if err != nil {
return "", err
}
return r.DataDir()
}
// Curated reports whether a rule of p covers the namespace of name (any
// type): only its allowed keys satisfy such a namespace (Evaluate).
func (p Policy) Curated(name string) bool {
for _, rule := range p.Rules {
if matchesNamespace(rule.Namespace, name) {
return true
}
}
return false
}
// Pinned reports whether keys accept a key for repoKey: its content has
// been seen signed (Reconcile), or a key was added for it.
func (keys KnownKeys) Pinned(repoKey string) bool {
return len(keys[repoKey]) > 0
}