test(crypto): add keys + primitives coverage with Argon2id parameter lock - #220
Merged
Conversation
Fills the empty toMatchInlineSnapshot() with the golden hex for the canonical (seed=64x0x42, salt=0x00..0xff, ops=3, mem=64MiB, parallelism=1 via libsodium) Argon2id derivation.
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.
Closes Phase 1 §1.4 of
.claude/plans/tech-debt-remediation.md.Summary
Dedicated coverage for
keys.ts(205L) +primitives.ts(16L) with real libsodium, including an Argon2id regression lock via inline snapshot.Key features
toMatchInlineSnapshot()on a fixed(seed=64×0x42, salt=0x00..0xff)pair + a separatecrypto_pwhasharg-spy assertingARGON2_PARAMS.OPS_LIMIT/MEMORY_LIMIT/ALG_ARGON2ID13. Inline comment documents the parallelism=1 deviation from RFC 9106 spec=4 (per MEMORY.md).keytarmocked only for keychain isolation.Coverage
keys.test.ts(505L) — Argon2id lock,deriveKeycontext separation,deriveMasterKeysnapshot + verifier-equality + memzero-on-failure,generateSaltuniqueness,generateDeviceSigningKeyPair(Ed25519 + BLAKE2b deviceId),generateKeyVerifier, X25519 ECDH roundtrip,deriveLinkingKeys,computeVerificationCode(deterministic, 6-digit, zero-padded),computeLinkingProof+computeKeyConfirm,getOrCreateSigningKeyPair,getOrDeriveVaultKey.primitives.test.ts(118L) —generateFileKeyuniqueness across 1000 calls + byte distribution,secureCleanupin-place zeroization.Note to reviewer
The Argon2id inline snapshot is empty until first-run write. CI will need one
-upass to populate the hex — or the maintainer can run locally and commit the populated snapshot. Once populated, any parameter drift trips the test.Test plan
pnpm --filter desktop test --project main src/main/crypto/keys.test.ts -uonce to populate Argon2id snapshot; commit the updatepnpm --filter desktop test --project main src/main/crypto/keys.test.ts src/main/crypto/primitives.test.ts— 0 failurespnpm typecheck:node && pnpm typecheck:webcleanpnpm lintclean🤖 Generated with Claude Code