← Techne home

✉️ Sealed Envelope Lab

Seal a note so that only its reader can open it — and prove that it was you who sealed it. This small, story-first lab teaches public-key cryptography the way a paper envelope teaches privacy: by holding one in your hands.

Why an envelope?

Paper envelopeIn this lab
An envelope sealed shut Encryption — a sealed box (X25519 + XSalsa20-Poly1305, via libsodium). Only the reader’s private key opens it; it is tamper-evident, too.
A signature across the flap A digital signature (Ed25519). Sealing hides the contents; signing proves who sealed it.
Recognising a familiar hand A fingerprint, pinned out-of-band — a public key is only trustworthy if you confirmed it through a separate, trusted channel.

How the lab works

  1. Make keys. Each person generates two key pairs — one for signing, one for encryption — and the private halves never move.
  2. Pin fingerprints. Public keys are exchanged, and their fingerprints compared over a channel you already trust.
  3. Seal. Encrypt the note to the reader’s public key, then sign the sealed envelope with your signing key.
  4. Open. The reader checks the signature first, then opens the box. Wrong key, wrong signer, or one flipped byte — and the envelope is refused.

The rules we never break

Try it

git clone https://github.com/petelittle/sealed-envelope-lab.git
cd sealed-envelope-lab
python -m pip install -r tools/requirements.txt

python tools/sealed_envelope_lab.py genkeys --owner Alice --keys alice-keys.json
python tools/sealed_envelope_lab.py genkeys --owner Bob   --keys bob-keys.json
python tools/sealed_envelope_lab.py pubs --keys bob-keys.json   # share Bob's public keys

python tools/sealed_envelope_lab.py seal \
  --keys alice-keys.json \
  --to "<Bob's encryption public key>" \
  --file examples/hello-envelope.txt \
  --out envelope.json

Bob then opens it with the open command, pinning Alice’s signing public key — the full walkthrough lives in the repository’s README and guides.

Open the project on GitHub →

The lab is a teaching tool: it works on small files so that every part can be inspected and understood. It is not a production messaging product — the repository’s security notes say plainly where the simplifications are.

Where the road leads