perf(evm-wallet): make PBKDF2 iterations configurable, speed up crypto tests#907
Merged
Merged
Conversation
Add optional `pbkdf2Iterations` parameter to `encryptMnemonic()` and `decryptMnemonic()`, defaulting to the production value of 600,000. Thread the parameter through `keyring-vat` initialize() and unlock(). Tests now pass 1,000 iterations instead of 600,000, reducing combined test time from ~250s to ~1.8s (mnemonic-crypto: 140s → 0.15s, keyring-vat: 110s → 1.6s). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
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
The evm-wallet mnemonic encryption tests were taking ~250s combined (140s for
mnemonic-crypto.test.ts, 110s forkeyring-vat.test.ts) because they run PBKDF2 with 600,000 iterations — the production default — on every encrypt/decrypt call.This PR adds an optional
pbkdf2Iterationsparameter toencryptMnemonic(),decryptMnemonic(), and keyring-vat'sinitialize()/unlock()methods. The parameter defaults to 600,000, so production behavior is unchanged. Tests now pass 1,000 iterations, reducing combined test time from ~250s to ~1.8s.pbkdf2Iterationsparameter toencryptMnemonic()anddecryptMnemonic(), defaulting toDEFAULT_PBKDF2_ITERATIONS(600,000)initialize()andunlock()TEST_PBKDF2_ITERATIONS(1,000)900_000ms test timeouts (no longer needed)Test plan
All 36 tests across
mnemonic-crypto.test.ts(8 tests) andkeyring-vat.test.ts(28 tests) pass in ~1.8s total. The tests exercise the same encrypt/decrypt logic paths as before — only the iteration count differs, which doesn't affect correctness of AES-GCM encryption, key derivation structure, or error handling.🤖 Generated with Claude Code
Note
Medium Risk
Introduces a new optional security parameter (
pbkdf2Iterations) to mnemonic encryption/decryption and keyring unlock/initialize; production defaults are unchanged but callers could accidentally use too-low iteration counts if misconfigured.Overview
Makes PBKDF2 iteration count configurable for mnemonic encryption by adding an optional
pbkdf2Iterationsparameter toencryptMnemonic/decryptMnemonic(defaulting to 600,000) and threading it through keyring vatinitializeandunlock.Speeds up test suite by updating mnemonic/keyring crypto tests to use
TEST_PBKDF2_ITERATIONS = 1_000and removing the long per-test timeouts while keeping the same behavioral assertions (roundtrip, wrong password, tampering, deterministic output).Written by Cursor Bugbot for commit 1fa27e3. This will update automatically on new commits. Configure here.