File formats¶
Byte-level descriptions of everything the module reads from or writes to disk
and the network, and of the container image signatures its signing-sigstore
sibling pushes to a registry.
The minisign signature file¶
Four lines, conventionally written next to the artefact as
<artefact>.minisig:
untrusted comment: <text>
base64( "ED" || key_id[8] || signature[64] )
trusted comment: <text>
base64( global_signature[64] )
- The first base64 body decodes to exactly 74 bytes: a two-byte algorithm tag, an eight-byte key identifier, and a raw 64-byte Ed25519 signature over the artefact's BLAKE2b-512 digest.
- The second decodes to exactly 64 bytes: the global signature.
global_signature = ed25519(signature || trusted_comment). The message is the 64 signature bytes followed by the bytes of the trusted comment aftertrusted comment:, with no trailing newline. Getting this wrong yields a file that parses cleanly and fails only at the global-signature check.- The untrusted comment is covered by nothing. Never make a trust decision on its contents.
- The trusted comment is covered by the global signature, so it is tamper-evident.
The parser is tolerant about layout: it trims trailing newlines, accepts CRLF line endings, skips blank lines, and identifies the comment lines by their prefixes. Any other non-blank line is treated as a base64 body, and exactly two must be present.
The "ED" and "Ed" tags¶
| Tag | Meaning |
|---|---|
"Ed" |
Legacy, "pure": ed25519(<whole file bytes>). This module never produces it and refuses to verify it. |
"ED" |
Prehashed: ed25519(BLAKE2b-512(<whole file bytes>)). The only variant produced or accepted here. |
Note the asymmetry: a public-key file carries "Ed" even though the
signatures it verifies carry "ED". The tag describes what was signed, which
is a property of the signature, not of the key.
"ED" is not Ed25519ph / HashEdDSA. It is a plain hash-then-sign construction:
the caller hashes, and an ordinary Ed25519 signing operation signs that digest
as its message. Driving a KMS with its ED25519_PH_SHA_512 algorithm produces
something neither Rust consumer can verify.
The default trusted comment¶
With Options.TrustedComment empty, the comment is built as tab-separated
fields:
and, when Options.Project is set, two further fields:
The base form is exactly what minisign -S writes; the trailing hashed
marks the prehashed variant. The two extra fields keep the same tab-separated
style, so anything parsing the conventional format still finds what it expects.
The key: field duplicates the identifier already in the signature body. The
body is authoritative, and the copy exists only so a signature file is
greppable under review. Both are covered by the same signature, so they cannot
disagree without verification failing.
The minisign public-key file¶
Two lines:
The base64 body decodes to exactly 42 bytes. That single base64 string,
without the comment line, is what cargo-binstall pins as pubkey in a
crate's [package.metadata.binstall.signing] table, and ParsePublicKey
accepts either form.
How the key identifier is derived¶
The reference minisign implementation generates this identifier randomly at key-generation time and stores it in the key files it writes. A KMS-held key offers no such step to hook, and keeping local state alongside an HSM key would be one more thing to lose, so it is derived instead. The derivation is deterministic and stateless: a rebuilt signing host recomputes an identical identifier, and a published public key can be re-derived and audited from the KMS public half alone.
The identifier is opaque. Verification rests on the Ed25519 key itself, so a hash prefix is entirely adequate. The bytes are used in the order returned, with no endianness reinterpretation. minisign's C implementation prints the identifier byte-reversed in its human-readable comments, but that affects only comment text; on the wire both sides compare raw bytes.
The WKD directory layout¶
openpgpkey.WriteWKDTree writes a complete tree under an output directory. For
the advanced method (the default), with domain example.com:
<outDir>/.well-known/openpgpkey/example.com/
├── policy (zero bytes, required by the specification)
├── submission-address (only when Options.SubmissionAddress is set)
└── hu/<z-base-32 hash> (one per unique email)
The direct method drops the <domain>/ level:
Files are written 0644 and directories 0755. A Web Key Directory is served
publicly, so world-readable is correct. WriteWKDTree refuses to operate
outside <outDir>/.well-known/openpgpkey, which is what the domain validation
protects.
It returns the relative paths of every file written, in write order: metadata
first, then the hu/ files in lexicographic hash order.
What goes inside a hu/ file¶
Binary OpenPGP packets, not ASCII armour. Input keys may be either form and are dearmoured as needed. Where several keys share an address, their binary streams are concatenated in ascending order of uppercase-hex primary fingerprint, so the same key set produces a byte-identical file regardless of the order it was passed in.
The hu/ filename¶
SHA-1 is fixed by the WKD wire format, not chosen here. It is a bucket identifier, not a security primitive: authenticity comes from OpenPGP signature verification, never from the filename.
z-base-32 is Zooko's human-oriented base-32 alphabet,
ybndrfg8ejkmcpqxot1uwisza345h769, mandated by the specification. There is no
= padding. A SHA-1 digest is 20 bytes, which encodes to exactly 32
characters.
openpgpkey.WKDHash(email) computes it from a full address;
openpgpkey.WKDLocalPartHash(localPart) from an already-split local part. Both
route through one implementation, shared with the resolver, so the publish and
fetch sides cannot drift apart.
The URLs a consumer fetches¶
For release@example.com:
| Method | URL |
|---|---|
| Advanced | https://openpgpkey.example.com/.well-known/openpgpkey/example.com/hu/<hash>?l=release |
| Direct | https://example.com/.well-known/openpgpkey/hu/<hash>?l=release |
verify.WKDURLs(email) returns both plus the canonical advanced host, so you
can print exactly what will be requested. The domain is lower-cased when the
URLs are built; the ?l= local part is passed through url.QueryEscape
as supplied, while the hash always uses the lower-cased form.
The resolver requests the advanced URL first and falls back to the direct URL only on HTTP 404.
What a resolver accepts back¶
The response is parsed as a binary keyring, then filtered to entities carrying a User ID whose email matches the requested address, compared case-insensitively. Keys for any other address are discarded, and a response containing none for the requested address is treated as unavailable.
The filter matters because a WKD endpoint controls the bytes it returns. It
closes the gap on the key_source=external path, where there is no second
anchor to cross-check against: a directory cannot smuggle an unrelated key into
the trust set.
The OpenPGP artefacts¶
| Artefact | Produced by | Shape |
|---|---|---|
| Armoured public key | openpgpkey.ArmoredPublicKey, WriteArmoredPublicKey |
A -----BEGIN PGP PUBLIC KEY BLOCK----- envelope holding one v4 RSA key, a User ID, and a positive-certification self-signature |
| Detached signature | openpgpkey.DetachSign |
A -----BEGIN PGP SIGNATURE----- envelope over the manifest bytes |
| Checksums manifest | your build | Opaque bytes to this module, which signs and verifies them without parsing |
The public key deliberately carries a User ID and self-signature: a bare
public-key packet is rejected by the verifier as a "v4 entity without any
identities". Producing that self-signature requires signing, which is why
minting a key needs the private half. An opaque KMS-backed crypto.Signer is
enough, because go-crypto drives RSA signing through the crypto.Signer
interface.
Signatures are reproducible when you pin the times. DetachSign truncates the
signature creation time to whole seconds (an OpenPGP v4 signature packet
stores it as uint32 seconds since the epoch) and disables go-crypto's
random-salt notation, which would otherwise make each run differ.
The rotation manifest¶
verify.SignRotationManifest writes two files, rotate-keys.json and its
minisign signature rotate-keys.json.minisig. The manifest follows
go-tool-base spec 0101,
decision D5:
{
"schema": "gtb.rotate-keys/v1",
"issued_at": "2026-06-21T10:00:00Z",
"not_after": "2027-06-21T10:00:00Z",
"reason": "compromise",
"add": [
{
"fingerprint": "<40 hex characters>",
"armored": "-----BEGIN PGP PUBLIC KEY BLOCK-----..."
}
],
"revoke": [
{
"fingerprint": "<40 hex characters>",
"since": "2026-06-21T09:00:00Z"
}
],
"epoch": 3
}
| Field | Rule |
|---|---|
schema |
Exactly gtb.rotate-keys/v1. |
issued_at, not_after |
RFC 3339 times, both required, not_after after issued_at. |
reason |
scheduled or compromise. It says why the manifest was issued, and either may carry revokes. |
add |
Release keys to trust. Each armored block holds exactly one OpenPGP key, whose primary fingerprint is fingerprint, and which passes the strength floor. |
revoke |
Release keys to distrust, by primary fingerprint. since is parsed and checked as a time, and has no other effect. |
epoch |
At least 1. |
Fingerprints are compared upper-case with spaces removed, and none may appear
twice across add and revoke. Unknown fields and trailing data are refused.
Manifests are cumulative: each carries every add and revoke since the
baseline, because a release ships only its latest manifest and an install that
skipped earlier ones learns only what that one carries. Applying a manifest
replaces the stored adds and epoch, and keeps every stored revoke: a revoke is
permanent, so a later manifest that omits one does not trust the key again.
What an added key's armored text may hold¶
The text is published exactly as it stands, so it must be the public key's
armour and nothing else. That means one PGP PUBLIC KEY BLOCK, with no armour
headers, holding only public-key, user-ID and signature packets. Anything else
returns ErrRotationManifestMalformed (see the
errors reference for the full rule).
This stops a secret being published beside the key by accident. It is not a guarantee against an issuer who hides a secret on purpose, in a field a public key may carry, such as a user ID or a signature's data.
Three ordinary exports are refused, and each has a fix:
Comment:armour headers (sq's default, or gpg's--comment). Delete the header lines, and leave the blank line after-----BEGINin place.- A photo ID. Export the key again without it, keeping every user ID:
--export-options export-minimal does not drop a photo ID. To publish the
user ID for one address only, filter the export instead:
That drops every user ID with another address. Give the bare address, as
here. Written in angle brackets, it matches no user ID, so the export has
none and is refused too.
- A gpg backup export (--export-options backup). It carries gpg's trust
packets, which a published key does not. Export the key again without
backup.
The signature is an ordinary minisign file over the manifest bytes, made with
the prehashed "ED" algorithm. Its trusted comment is the default one, with
issued_at as the timestamp and rotate-keys.json as the file name, so the
same manifest and key always give the same bytes.
The container image signatures¶
Written by
signing-sigstore's
SignImage, in the shapes cosign v3 writes, so cosign's verifiers read them.
Both name the image by digest. The bundle does not name the repository. The
legacy payload does, in docker-reference, but cosign 3.1.4 does not check it
and accepts the signature copied to another repository. Scope trust by key, not
by path.
The legacy signature¶
| Part | Value |
|---|---|
| Tag | <repository>:sha256-<hex>.sig |
| Manifest | OCI image manifest, config application/vnd.oci.image.config.v1+json |
| Layer media type | application/vnd.dev.cosign.simplesigning.v1+json |
| Layer annotation | dev.cosignproject.cosign/signature: the base64 signature |
| Layer content | the simple-signing payload below, which is what is signed |
{"critical":{"identity":{"docker-reference":"<repository>"},"image":{"docker-manifest-digest":"sha256:<hex>"},"type":"cosign container image signature"},"optional":null}
Each signing key adds one layer. Signing again with a key whose signature is already there changes nothing.
The bundle referrer¶
| Part | Value |
|---|---|
| Manifest | OCI image manifest, artifactType application/vnd.dev.sigstore.bundle.v0.3+json, subject the signed image |
| Config | application/vnd.oci.empty.v1+json, content {}, artifactType as the manifest's |
| Layer | one Sigstore bundle v0.3, media type application/vnd.dev.sigstore.bundle.v0.3+json, annotated org.opencontainers.image.title: sha256-<bundle hex>.sigstore.json, where <bundle hex> is this layer's own digest |
| Annotations | dev.sigstore.bundle.content: dsse-envelope; dev.sigstore.bundle.predicateType: https://sigstore.dev/cosign/sign/v1; org.opencontainers.image.created |
| Discovery | the registry's referrers API, or the <repository>:sha256-<hex> fallback index on a registry without one, such as GitLab's |
The bundle holds a DSSE envelope over an in-toto v1 statement whose one
subject is the image digest, with an empty https://sigstore.dev/cosign/sign/v1
predicate. The signature covers the DSSE pre-authentication encoding of that
statement. Its verification material is a public-key hint (base64 of the
SHA-256 of the DER public key), with no certificate, no transparency-log entry
and no timestamp.
The signature algorithm¶
| Key | Signed as |
|---|---|
| ECDSA P-256 | SHA-256 digest, ASN.1 DER |
| Ed25519 | the whole message, pure Ed25519 (never Ed25519ph) |
| RSA 2048, 3072, 4096 | SHA-256 digest, PKCS#1 v1.5 (never PSS) |
The module chooses these options itself and verifies every signature against
the signer's public key before pushing. A signer whose output does not verify
fails with sigstore.ErrSignatureInvalid, and nothing is pushed. cosign v3.1.3's
own sign --key signs an Ed25519 key pre-hashed, which
cosign verify rejects.
Related¶
- Sign artefacts with minisign.
- Publish keys via WKD.
- Why there are two signature formats.
- Sign a container image.