Documentation
¶
Overview ¶
Package sign signs pkgx bottles with Ed25519, interoperably with both minisign (detached .minisig files, for tarballs served over HTTP from dist.pkgx.dev) and cosign (PEM keys + blob signatures, for bottles published as OCI artifacts on ghcr.io). A single Ed25519 keypair backs both: minisign and cosign each verify a plain Ed25519 signature over the bottle bytes, so one signature value serves both transports.
The package is pure standard library for signing and for verifying legacy ("Ed") signatures; verifying minisign's prehashed ("ED") form additionally pulls in golang.org/x/crypto/blake2b. CGO_ENABLED=0.
Index ¶
- func ParsePublicKeyPEM(p []byte) (ed25519.PublicKey, error)
- func SimpleSigningPayload(dockerRef, manifestDigest string) ([]byte, error)
- func VerifyBlob(data []byte, b64sig string, pub ed25519.PublicKey) error
- func VerifyMinisign(data []byte, minisig, pubkey string) error
- type KeyID
- type Keypair
- func (k *Keypair) PublicKeyFile(comment string) string
- func (k *Keypair) PublicKeyPEM() ([]byte, error)
- func (k *Keypair) PublicKeyString() string
- func (k *Keypair) SecretKeyFile(comment string) string
- func (k *Keypair) SignBlob(data []byte) string
- func (k *Keypair) SignMinisign(data []byte, untrusted, trusted string) string
- func (k *Keypair) SignPayload(payload []byte) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePublicKeyPEM ¶
ParsePublicKeyPEM decodes a PKIX PEM Ed25519 public key (a cosign.pub).
func SimpleSigningPayload ¶
SimpleSigningPayload builds cosign's "simple signing" JSON payload binding a signature to an OCI image by its manifest digest (e.g. "sha256:abc…") and reference. This payload — not the raw bytes — is what a cosign image signature covers; bottle stores it as the signature artifact's layer and SignPayload's output in the cosign signature annotation.
func VerifyBlob ¶
VerifyBlob checks a base64 Ed25519 blob signature (cosign form) over data.
func VerifyMinisign ¶
VerifyMinisign checks a detached minisign signature over data against a minisign public key. Both legacy ("Ed") and prehashed ("ED", Blake2b-512) algorithms are accepted, so signatures made by the minisign CLI verify too.
Types ¶
type KeyID ¶
type KeyID [8]byte
KeyID is minisign's 8-byte key identifier, echoed in every signature so a verifier can tell which key a signature claims to originate from.
type Keypair ¶
type Keypair struct {
ID KeyID
Public ed25519.PublicKey
Private ed25519.PrivateKey
}
Keypair is an Ed25519 signing keypair plus its minisign-style KeyID.
func LoadSecretKey ¶
LoadSecretKey parses a SecretKeyFile back into a Keypair.
func (*Keypair) PublicKeyFile ¶
PublicKeyFile returns the two-line minisign public-key file (comment + key).
func (*Keypair) PublicKeyPEM ¶
PublicKeyPEM encodes the Ed25519 public key as a PKIX PEM block — the form `cosign verify-blob --key <file>` and `cosign verify --key <file>` expect.
func (*Keypair) PublicKeyString ¶
PublicKeyString encodes the public key as minisign's one-line base64 form, base64("Ed" || keyID || pubkey) — the "RW…"-prefixed string a verifier stores as the second line of a .pub file.
func (*Keypair) SecretKeyFile ¶
SecretKeyFile encodes the keypair's private key for storage by go-pkgx tools: a comment line plus base64(keyID || Ed25519 private key). This is not minisign's scrypt-encrypted format — it is meant for CI signing keys held in a secret store, so protection is the store's job, not a passphrase.
func (*Keypair) SignBlob ¶
SignBlob returns the base64 Ed25519 signature over data, matching what `cosign sign-blob --key … <file>` emits and what `cosign verify-blob --signature …` checks. It is the same signature value SignMinisign embeds, in cosign's encoding.
func (*Keypair) SignMinisign ¶
SignMinisign returns a detached minisign signature file (the content of a .minisig) over data. It uses legacy Ed25519 (algorithm "Ed", signature over the raw message) so `minisign -V` and crypto/ed25519 both verify it without Blake2b. The trusted comment is authenticated by the trailing global signature; untrusted defaults if empty.
func (*Keypair) SignPayload ¶
SignPayload signs an arbitrary payload (e.g. a SimpleSigningPayload) and returns the base64 signature to store in cosign's `dev.cosignproject.cosign/signature` annotation.