Repository navigation
feat(memory): public-key sync mode — ephemeral sessions push with no secret - #192
Merged
Merged
Conversation
…secret The passphrase mode needs the same secret on every pushing machine, which an ephemeral cloud session can't safely hold (no secret-store, no SSH key). Add an asymmetric mode so a session encrypts to a PUBLIC recipient key (not a secret) and only private-key holders can decrypt. - backup.ts: MAGIC_V3 = ephemeral X25519 → HKDF-SHA256(salt=ephPub|recipPub) → AES-256-GCM (sealed-box shape), pure node:crypto, zero deps. New: generateMemoryKeypair / saveMemoryKey / loadMemoryKey / parseRecipient / backupToRecipient / restoreWithKey / isAsymmetricBackup. - sync.ts: syncFromExport decrypts V3 with the local private key (no passphrase); clear error if the key is missing. - remote-sync.ts: [memory.sync] recipient = "kitmem-pub-…"; push encrypts to it; tryAutoPush no longer requires KIT_MEMORY_PASSPHRASE when a recipient is set. - kit memory keygen: mint the keypair (private 0600), print the shareable public recipient; refuses to clobber an existing key without --force. Private key stays only on durable machines (~/.kit/memory-key.json). 3 new tests (round-trip, wrong-key confidentiality, malformed-recipient); live end-to-end verified passphrase-free. Suite 1985 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
|
✅ Docker image built successfully
|
This was referenced Jul 1, 2026
Merged
sandstream
added a commit
that referenced
this pull request
Jul 1, 2026
#196) Cut 3.1.0 from [Unreleased]: - gzip-compress memory sync blobs before encryption (~3x smaller, #193) - public-key sync mode — ephemeral sessions push with no secret (#192) - kit agent-config wires GitHub Copilot (#195) - external timestamp anchor via command transport (#186) - plus device-identity hardening + transport fixes Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Cross-device memory sync used a symmetric passphrase — every machine that pushes needs the same secret. An ephemeral cloud session (Claude Code on the web) can't safely hold it: its env-vars field is explicitly "not for secrets", it has no SSH key, and the container is thrown away. So ephemeral sessions couldn't contribute their memory to the hub without either leaking a secret or losing the data on teardown.
What
An asymmetric (public-key) mode that flips the trust model:
kitmem-pub-…) — not a secret, safe to put in a setup script, an env var, or even commit.~/.kit/memory-key.json,0600) can decrypt on pull.push_on_end/pull_on_startwork passphrase-free.How (zero new deps)
backup.ts—MAGIC_V3: fresh ephemeral X25519 keypair per blob →ECDH(eph, recipient)→HKDF-SHA256(salt = ephPub‖recipPub, info="kit-memory-v3")→ AES-256-GCM. libsodium sealed-box shape, purenode:crypto. New helpers:generateMemoryKeypair,saveMemoryKey,loadMemoryKey,parseRecipient,backupToRecipient,restoreWithKey,isAsymmetricBackup.sync.ts—syncFromExportdecrypts a V3 blob with the local private key (no passphrase); clear error if the key is missing.remote-sync.ts—[memory.sync] recipient = "kitmem-pub-…"; push encrypts to it;tryAutoPushno longer requiresKIT_MEMORY_PASSPHRASEwhen a recipient is configured.kit memory keygen— mint the keypair (private0600), print the shareable public recipient; refuses to overwrite an existing key without--force(a new key would orphan old blobs).The passphrase mode is unchanged and remains the default; asymmetric is opt-in via
recipient.Tests
3 new: encrypt-to-public / decrypt-with-private round-trip; a different private key cannot decrypt (confidentiality);
parseRecipientrejects malformed keys. Plus a live end-to-end run (push withundefinedpassphrase → pull with the private key → real content recovered). Full suite 1985 green, prettier clean, public surface unchanged.Setup (ephemeral web sessions, seamless)
No passphrase, no SSH key, no token to manage in the container.
🤖 Generated with Claude Code
https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Generated by Claude Code