Part II — Intermediate Development · Chapter 11 · Lesson 5 of 6 · 4 min read
Lesson 5: Checksums, Signatures, Trusted Keys, and Registry Policy
Lesson level: Intermediate
Purpose: Learn how to prove that an installed archive is the one its publisher intended, and how a registry policy decides which publishers and keys to trust.
Release note: commands, field names, and syntax in this lesson are illustrative. Verify them against your installed v0.63 release before relying on them.
Learning objectives
By the end of this lesson, you should be able to:
- Explain what a checksum proves and what it does not.
- Explain how a signature links an archive to a publisher key.
- Manage a list of trusted keys for a project.
- Write a registry policy that requires signed packages.
- Respond correctly when verification fails.
5.1 Two different questions
Integrity asks whether the archive changed since it was recorded. Authenticity asks who produced it. A checksum answers the first question. A signature answers the second.
5.2 Checksums
A checksum is a cryptographic hash of the archive bytes. Any change to the archive produces a different hash. The lock from Lesson 2 records the checksum of each registry package.
[[package]]
name = "input_checks"
version = "1.2.3"
checksum = "sha256:3f9a…c71e"
On a locked install, the installer recomputes the hash and stops if it differs from the recorded value.
5.3 What a checksum cannot prove
A checksum proves the archive matches what was recorded, not that the recorded archive was safe or came from the right publisher. If an attacker controls the first download, the lock records the attacker's archive.
5.4 Signatures
A publisher signs the archive with a private key. Anyone with the matching public key can verify the signature. A valid signature shows that the holder of that private key produced this exact archive.
pea package --sign --key publisher.key
pea verify input_checks-1.2.3.peapkg
5.5 Checksums and signatures together
| Evidence | Proves | Does not prove |
|---|---|---|
| Checksum in lock | Archive unchanged since recorded | Who produced it |
| Signature | Produced by the key holder | That the key holder is trustworthy |
| Trusted key list | Which keys you accept | That the code is safe to run |
Use all three. Review and permissions from Lesson 4 still decide whether the code is acceptable.
5.6 Trusted keys
A project lists the public keys it accepts. A signature from an unknown key fails verification even if it is mathematically valid.
[trust]
keys = [
{ id = "team-release-2026", file = "keys/team-release-2026.pub" },
]
5.7 Key lifecycle
- Add a key only after confirming its fingerprint through a separate channel.
- Record who approved each key and when.
- Rotate keys on a schedule and after any suspected exposure.
- Remove retired keys, and decide whether old signatures remain acceptable.
- Never commit private keys to the repository.
5.8 Registry policy
A registry policy states which registries a project may use and what evidence each package must carry. It turns individual checks into a rule the installer enforces.
[registry_policy]
allowed_registries = ["https://registry.example.com"]
require_signature = true
require_checksum = true
allow_unsigned = []
5.9 Exceptions
Sometimes a needed package is unsigned. List it by name and exact version in allow_unsigned, record the reason and an expiry date, and review it at each release. Never use a wildcard exception.
5.10 When verification fails
| Failure | Possible cause | Correct response |
|---|---|---|
| Checksum mismatch | Archive altered, mirror corruption, or stale lock | Stop; compare with the original source; do not update the lock to make it pass |
| Unknown signing key | New publisher key or impersonation | Confirm the key out of band before trusting it |
| Invalid signature | Tampered archive or wrong key | Treat as a security incident |
| Missing signature | Publisher did not sign | Use a signed release or a recorded exception |
5.11 Worked example
A developer runs a locked install of order_rules and sees a checksum mismatch for input_checks 1.2.3. The team does not regenerate the lock. They download the archive directly from the registry, compare hashes, and find the internal mirror served a corrupted copy. After the mirror is repaired, the locked install succeeds with the original lock unchanged.
5.12 Verification in continuous integration
pea install --locked
pea verify --all
pea audit --permissions
These illustrative commands make every build check integrity, authenticity, and permissions before tests run.
5.13 Common mistakes
| Mistake | Consequence | Fix |
|---|---|---|
| Regenerating the lock after a mismatch | Hides tampering | Investigate first |
| Trusting a key from the same channel as the package | Attacker supplies both | Confirm fingerprints separately |
| Wildcard unsigned exceptions | Policy has no effect | Name exact versions with expiry |
| Committing private keys | Anyone can sign as you | Store keys in a secret manager |
5.14 Guided practice
- Record the checksum of an archive and change one byte; observe the mismatch.
- Sign an archive and verify it with the public key.
- Verify the same archive with an untrusted key and read the error.
- Write a registry policy with one expiring exception.
5.15 Hands-on lab
Configure order_rules to require signed packages from one registry. Install a signed input_checks, then simulate a tampered archive and an unknown key, and record each failure.
Deliverable: the policy file, the trusted-key list with approval notes, and the output of each verification attempt.
5.16 Review questions
- What does a checksum prove, and what does it not prove?
- What does a valid signature prove?
- Why must a key be confirmed through a separate channel?
- Why should a lock not be regenerated after a mismatch?
- How should an unsigned-package exception be recorded?
5.17 Applied challenge
Write an incident runbook for a signature failure in production builds. Include who is notified, how builds are paused, how the cause is confirmed, and how normal installs resume.
Lesson summary
- Checksums prove integrity; signatures prove origin.
- Trusted keys decide whose signatures count.
- A registry policy makes these checks mandatory.
- Verification failures are investigated, not overridden.
Transition to the Chapter 11 Checkpoint
The checkpoint combines all five lessons: you will publish a signed package and consume it from a locked, audited project.
Lesson status: Ready for review.