Skip to content

How it works

The signer hashes the data, encrypts the hash with their private key, and publishes the result; the verifier decrypts with the public key and compares the hash.

The mechanism rests on public-key cryptography. The signer generates a key pair: a private key known only to them, and a public key distributed freely. To sign, the signer computes a hash of the data and signs the hash with the private key. The output is the signature. To verify, anyone computes the hash of the received data, decrypts the signature with the public key, and compares the two. If they match, the signature is valid: the private key was used over exactly this data, with no alteration.

graph LR
  D[Data] --> H[Hash]
  H --> S[Sign with private key]
  S --> SIG[Signature]
  SIG --> V[Verifier]
  V --> H2[Hash of received data]
  V --> U[Decrypt with public key]
  H2 --> C{Match?}
  U --> C
  C -->|yes| OK[Valid]
  C -->|no| FAIL[Invalid]

Different signature algorithms exist. RSA (used since the 1970s) signs with a modular exponentiation. ECDSA (Elliptic Curve DSA) uses elliptic-curve arithmetic and produces shorter signatures for equivalent security. EdDSA (Ed25519) is a modern curve-based scheme with deterministic signatures and fast verification. The choice matters for performance and interoperability, but the model is identical: private key to sign, public key to verify, binding between the two established by mathematics.

Adding signatures to an artifact pipeline

  1. Decide what is signed

    Sign the artifact itself (container manifest, package tarball, release binary), not just its hash. Signing a hash leaves the hash vulnerable to substitution.

  2. Publish the public key out-of-band

    Never distribute the public key over the same channel as the signed data. A verifier who fetches both from the same server is verifying nothing.

  3. Sign at build, verify at deploy

    Signatures belong in the build pipeline (where the artifact is produced) and in the deploy pipeline (where it is admitted). Nothing between build and deploy should be able to introduce an unsigned artifact.

  4. Record the signature as an OCI referrer or an in-toto attestation

    OCI referrers and in-toto attestations attach signatures to artifacts in a portable, standard way. Do not encode them as sidecar files; the artifact should carry its own provenance.

Modern signing practice extends beyond one-shot signatures. Sigstore's Cosign signs OCI artifacts and uploads signatures as referrers, so any compliant registry can store and serve them. in-toto attestations add a provenance layer: not just "who signed this", but "what steps produced this artifact, using which inputs". The combination is what turns a signature from a single proof into a verifiable chain of evidence.