signature

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TierFree     = "free"
	TierLicensed = "licensed"
)

The two plugin tiers. A key serves exactly one of them.

View Source
const Alg = "ed25519"

Alg is the only signature algorithm the contract defines.

Variables

View Source
var Floor, _ = loadFloor(signedSinceJSON)

Floor maps tier -> slug -> first signed version. Tests swap it with signaturetest.UseFloor.

View Source
var Keys = []Key{}

Keys is the trust root. Empty until P7-PLUG-71 (free) and P7-PLUG-72 (licensed).

View Source
var Presigning, _ = loadPresigning(signedSinceJSON)

Presigning maps tier -> slug -> pre-signing releases. Tests swap it with signaturetest.UsePresigning.

View Source
var Revoked = []string{}

Revoked lists key ids that no longer verify anything, whatever Keys holds.

Functions

func CheckKeys

func CheckKeys() error

CheckKeys reports whether the key table is usable: ids derived from the keys, no id or public key repeated, no key listed under two tiers, no malformed or small-order key. A broken table fails every Verify closed; TestKeyTable runs this over the committed table.

func FloorRequires

func FloorRequires(tier, slug, version string) bool

FloorRequires reports whether an entry of tier/slug/version must carry a release_signature because of the floor.

func Pinned

func Pinned(tier string) bool

Pinned reports whether the key table holds at least one key for tier. A revoked key still counts: a tier that once pinned a key never falls back to treating signatures as absent.

func SigningInput

func SigningInput(slug, version, sha256hex string) []byte

SigningInput returns the bytes the release pipeline signs: "nself-plugin-v1\n<slug>\n<version>\n<sha256 hex>\n".

func UnsignedAllowed

func UnsignedAllowed(tier, slug, version, sha256 string) bool

UnsignedAllowed reports whether an unsigned release of tier/slug/version with archive digest sha256 may proceed to the ordinary unsigned rule. It is false when the floor or the pre-signing list names the slug (in any tier) and this exact (tier, slug, version, sha256) is not on the list.

func Verify

func Verify(tier, slug, version, sha256hex string, rel *Release) error

Verify checks rel for the given tier, slug, version and tarball sha256.

Types

type Input

type Input struct {
	Tier, Slug, Version, SHA256 string
	Release                     *Release // nil when the entry has none
	V15                         bool     // compat.V15() at the call site
	Strict                      bool     // refuse a missing signature even in v1.4 mode (NSELF_PLUGIN_REQUIRE_CHECKSUM on a stable plugin)
	AllowUnsigned               bool     // --allow-unsigned; the caller passes true only for local path or link installs
}

Input is one install decision.

type Key

type Key struct {
	ID        string // derived: plugins-<first 16 hex of sha256(PublicKey)>
	Tier      string // TierFree or TierLicensed
	PublicKey ed25519.PublicKey
}

Key is one trusted release-signing public key.

type Outcome

type Outcome struct {
	Verified bool   // a signature was checked and is good
	Warning  string // non-empty: print once and proceed
}

Outcome reports a passing decision.

func Decide

func Decide(in Input) (Outcome, error)

Decide applies the rules above.

type PresigningRelease

type PresigningRelease struct {
	Version string `json:"version"`
	SHA256  string `json:"sha256"`
}

PresigningRelease is one release that existed before signing began.

type Release

type Release struct {
	KeyID string `json:"key_id"`
	Alg   string `json:"alg"`
	Sig   string `json:"sig"` // raw 64-byte signature, standard padded base64
}

Release is the release_signature object of a registry or catalog entry.

Directories

Path Synopsis
Package signaturetest gives tests a throwaway release key and swaps the compiled-in key table and floor, restoring both on t.Cleanup.
Package signaturetest gives tests a throwaway release key and swaps the compiled-in key table and floor, restoring both on t.Cleanup.

Jump to

Keyboard shortcuts

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