You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(auth): load the encryption key once and derive purpose keys #658
getEncryptionKey re-reads the key file and re-imports the key on every encrypt and decrypt (web/src/server/Auth/Core/encryption.server.ts:18-33, web/src/server/env.server.ts:43-98, :244-246). That is about six blocking file syscalls plus importKey per operation, on the event loop. A page of 100 app events with cursors repeats it 100 times.
The raw key is used directly for stored secrets, app event cursors (web/src/server/AppRuntime/events.server.ts:76) and frame tokens (web/src/server/AppRuntime/ui/assets.server.ts:38). Purposes are separated only by AES-GCM additional data, and they share one key and one nonce budget.
Proposal
Load and import the key once at startup.
Derive separate keys per purpose with HKDF-SHA256 (stored secrets, cursors, frame and asset tokens).
Keep decrypting existing stored secrets: version the ciphertext format and re-encrypt lazily or in a migration. Cursors and frame tokens are short-lived and can switch directly.
Acceptance
Test: encrypt/decrypt does no file I/O after startup.
Test: existing stored secrets still decrypt after the change; a token sealed for one purpose does not open under another.
Activity