Skip to content

fix: set scrypt maxmem for startup key derivation#81

Merged
hqhq1025 merged 1 commit intoOpenCoworkAI:mainfrom
Sun-sunshine06:pr/startup-scrypt-maxmem-fix
Mar 27, 2026
Merged

fix: set scrypt maxmem for startup key derivation#81
hqhq1025 merged 1 commit intoOpenCoworkAI:mainfrom
Sun-sunshine06:pr/startup-scrypt-maxmem-fix

Conversation

@Sun-sunshine06
Copy link
Copy Markdown
Collaborator

Summary\n- set explicit maxmem headroom for both secure and legacy scrypt key derivation paths\n- reuse the secure scrypt options in the credentials-store fallback machine key path\n- add regression coverage for fallback initialization and secure scrypt options\n\n## Testing\n- npx vitest run tests/store-encryption.test.ts tests/credentials-store-legacy-key.test.ts\n- npm run typecheck\n\n## Context\nThis fixes the Windows/Electron startup failure caused by RangeError: Invalid scrypt params: error:030000AC:digital envelope routines::memory limit exceeded when beta.7 falls back to machine-bound key derivation.

Copy link
Copy Markdown
Collaborator

@hqhq1025 hqhq1025 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — Approve

Well-scoped fix for the scrypt maxmem RangeError. Confirmed the issue locally: Node v22 + OpenSSL 3.x defaults to 32 MiB maxmem, but N=65536/r=8 requires 64 MiB. The 128 * N * r + 1 MiB formula is the standard approach per RFC 7914.

Verified

  • No crypto parameter changes (N/r/p unchanged), only resource limit — zero security impact
  • Derived key output is bit-identical regardless of maxmem
  • Test coverage for the previously untested scrypt fallback path ✅

Minor suggestions (non-blocking)

  • LEGACY_SCRYPT_OPTIONS is exported but has no external consumer — could stay as internal const
  • Consider adding expect(LEGACY_SCRYPT_OPTIONS.maxmem).toBeGreaterThan(128 * 16384 * 8) for symmetry

@hqhq1025 hqhq1025 merged commit 38b7321 into OpenCoworkAI:main Mar 27, 2026
3 checks passed
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.

2 participants