feat(client): NaCl-box crypto primitives + pairing payload codec#27
Open
Codename-11 wants to merge 1 commit into
Open
feat(client): NaCl-box crypto primitives + pairing payload codec#27Codename-11 wants to merge 1 commit into
Codename-11 wants to merge 1 commit into
Conversation
Adds pure crypto layer usable by both daemon and client for the ARC v3 E2E-encrypted relay flow (Phase 10 of the v3 daemon plan). - `packages/client/src/crypto.ts`: `generateKeypair`, `box`, `unbox` (returns null on auth failure), and URL-safe base64 helpers. Wraps `tweetnacl` for zero-native-build crypto_box (Curve25519 + XSalsa20 + Poly1305). - `packages/client/src/pairing.ts`: Zod schema + encode/decode for the compact QR pairing payload (v, relayUrl, daemonPub, pairCode, label). JSON is canonicalized before base64url so identical payloads always encode to the same string. - `tests/crypto-primitives.test.ts`: 15 vitest cases covering keypair shape, box/unbox roundtrips, tamper/wrong-key/wrong-nonce rejection, base64url safety, and pairing payload encode/decode including malformed inputs and schema violations. Primitives only — relay server and daemon pairing flow are follow-up batches.
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.
Summary
packages/client/src/crypto.ts—generateKeypair,box,unbox(null on auth failure), and URL-safe base64 helpers, wrappingtweetnacl(zero native build, Curve25519 + XSalsa20 + Poly1305).packages/client/src/pairing.ts— Zod schema + canonical encode/decode for the compact QR pairing payload (v,relayUrl,daemonPub,pairCode, optionallabel).tests/crypto-primitives.test.ts— 15 vitest cases: keypair shape & uniqueness, box/unbox roundtrip, tamper/wrong-nonce/wrong-key rejection, base64url safety, pairing payload roundtrip + malformed-input errors + schema-version rejection.Context: Phase 10 of the ARC v3 daemon plan (E2E-encrypted relay). Primitives only — the relay server (Unit 10) and daemon pairing flow will consume these in follow-up batches.
Test plan
pnpm installnpx tsc --noEmit— passesnpx vitest run tests/crypto-primitives.test.ts— 15/15 passbox/unboxround-trips "hello" across two fresh keypairs via the@axiom-labs/arc-clientpackage export+,/,=)