Skip to content

Native encryption: age, one content layout, and seekable packs - #218

Draft
mbertschler wants to merge 5 commits into
mainfrom
native-crypt
Draft

mbertschler wants to merge 5 commits into
mainfrom
native-crypt

Conversation

@mbertschler

@mbertschler mbertschler commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Proposes step 3 of the rclone replacement in design/native-crypt.md: squirrel encrypts every artifact itself in the age format, rclone's crypt overlay goes away, and packs become seekable. It follows #216 and #217. The S3 transport comes afterwards, on its own branch.

This pull request holds the design only. Implementation follows on this branch, in the sessions below.

The design in short

  • One content layout. The content-addressed layout is retired; pack_threshold = 0 still stores every file as an object.
  • Encryption belongs to the packed layout. crypt is accepted on packed destinations and refused on mirrors: an encrypted mirror needs a tool to read any file, yet discloses every path, size and modification time.
  • Crypt only on local and sftp, written natively. Encrypted s3, b2 and gcs destinations are refused until the S3 transport lands; rclone never handles an encrypted destination.
  • age with post-quantum hybrid recipients (mlkem768x25519, age v1.3+). Recovery without squirrel needs the stock age command, zstd, tar and a BLAKE3 tool.
  • Two keys you hold, two the destination holds. The agent identity (on the pushing machine) and the recovery kit (printed once, kept offline) open .squirrel-keys, which holds the destination's random data identity and naming key. Every other file is encrypted to the data identity.
  • A rekey rewrites one small file. destination rekey re-encrypts .squirrel-keys to the new keys and starts a new data generation; no artifact is rewritten, and every file opens with the new keys.
  • .squirrel-keys is one ciphertext with many copies: the root, every volume directory, and the local store, so every index snapshot carries it without disclosing anything.
  • Verification never decrypts. Squirrel decrypts its own output while sending and confirms the ciphertext fingerprint at landing. That closes SAFETY-AUDIT D2 without downloading anything. cloudbox is verified by its server's sha256sum at landing and on every verify pass; presence+size never gates offload.
  • No secret in the config file. Every secret field takes { file = … } or { env = … }; a key file must be private and outside every volume. keygen writes the agent identity to such a file.
  • Seekable packs: zstd frames of about 1 MiB, frame offsets in the placement map, ranged reads on local and sftp. Restoring one file reads one frame instead of the whole pack.
  • Padmé padding of objects, always on, for about 1% of storage.
  • The recovery drill: asked for monthly, with the reminder starting at three quarters of the cadence and a visible per-destination opt-out. A destination earns offload credit only while its current kit has been drilled within the cadence; pushes, verify and restore never wait. Recorded in ux-principles.md.
  • Reference setup: cloudbox becomes an encrypted packed destination written natively over sftp; s3archive waits for the S3 transport to be encrypted.

Also amended here: native-mirror.md (its crypt question is decided), ux-principles.md §1 (the drill's exception and its hold on offload credit), and design/README.md.

Related: #219 (ride-along index snapshots disclose every volume's paths on plaintext destinations), stated in the design and fixed separately.

Open questions

None. Rewrapping artifacts after a rekey is no longer needed.

Sessions

Working rules as on #217: commit small and push often, never rebase or force-push, keep go vet ./..., go test ./... and golangci-lint run green on every push, amend the design in the same commit when the code proves it wrong, tick the box and leave a short note when a session finishes, and never mark this pull request ready or merge it.

  • 1. Keys, .squirrel-keys and the native encryption layer. Retiring the content-addressed layout first, then the file and env secret forms, the crypt block, keygen, .squirrel-keys and its copies, recipient pinning, the encryption layer with object padding in transportArtifacts, and the evidence rows for local and sftp. The shared content-addressed and packed test fixtures become packed fixtures on the native transports first.
  • 2. rclone crypt removed, restore, recover and rekey. Removal of rclone crypt and the refusal of encrypted s3, b2 and gcs, restore and recover with --identity, rekey with its generations, and the recovery procedure in formats.md.
  • 3. Seekable packs. The frame writer, the placement map fields and the migration, GetRange on local and sftp, and the restore strategy.
  • 4. Drill, hardening and wrap-up. verify --recovery-kit, its reminder and its hold on offload credit, the tampering suite, the docs framing review, reference-setup.md, the testbed walk, and the benchmark.

Review of the native crypt proposal:

- Artifacts are encrypted to a random data identity kept in
  .squirrel-keys, which the agent identity and the recovery kit open. A
  rekey rewrites .squirrel-keys and starts a new generation; no artifact
  is rewritten, and every file opens with the new keys. The write-time
  check now covers every artifact's only stanza, and the former open
  question on rewrapping is settled.
- .squirrel-keys is one ciphertext copied to the root, every volume
  directory and the local store, so snapshots carry it without
  disclosing anything.
- Crypt is allowed only on local and sftp until the S3 transport lands;
  rclone moves no ciphertext.
- cloudbox is verified by its server's sha256sum at landing and on every
  verify pass; presence+size never gates offload.
- No secret sits in the config file: every secret field takes
  { file = ... } or { env = ... }, and keygen writes the agent identity
  to a private key file outside every volume.
- A destination's first drill gates its offload credit, and a rekey to
  a new kit resets it; ux-principles records the hold.
- The snapshot path leak on plaintext destinations is stated and
  tracked in #219.
A destination earns offload credit only while its current kit has been
drilled within recovery_drill_every, not just once. The reminder starts
at three quarters of the cadence, so a timely drill never stalls an
offload; durability pulls carry the last drill time and cadence, so
relayed credit lapses on time. Pushes, verify and restore never wait.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant