PeaBox Lab › PeaLang › Learn › Chapter 11 › Lesson 5

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:

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

EvidenceProvesDoes not prove
Checksum in lockArchive unchanged since recordedWho produced it
SignatureProduced by the key holderThat the key holder is trustworthy
Trusted key listWhich keys you acceptThat 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

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

FailurePossible causeCorrect response
Checksum mismatchArchive altered, mirror corruption, or stale lockStop; compare with the original source; do not update the lock to make it pass
Unknown signing keyNew publisher key or impersonationConfirm the key out of band before trusting it
Invalid signatureTampered archive or wrong keyTreat as a security incident
Missing signaturePublisher did not signUse 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

MistakeConsequenceFix
Regenerating the lock after a mismatchHides tamperingInvestigate first
Trusting a key from the same channel as the packageAttacker supplies bothConfirm fingerprints separately
Wildcard unsigned exceptionsPolicy has no effectName exact versions with expiry
Committing private keysAnyone can sign as youStore keys in a secret manager

5.14 Guided practice

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

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

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.

← Previous Next →