fix(crypto): use 12-byte AES-GCM nonce for new seed exports - #4
Open
adequatelimited wants to merge 1 commit into
Open
fix(crypto): use 12-byte AES-GCM nonce for new seed exports#4adequatelimited wants to merge 1 commit into
adequatelimited wants to merge 1 commit into
Conversation
New encryptions now use the standard 96-bit GCM nonce instead of 16 bytes. Decrypt continues to read the IV length from the stored record, so existing 16-byte-IV keystores still decrypt.
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.
Repo:
adequatesystems/mochimo-wallet· Branch:fix/ar4-gcm-nonce-12→mainAudit finding: AR-4 — AES-GCM used a 16-byte IV instead of the 12-byte standard nonce (Severity: LOW)
What & why
The master-seed AES-GCM encryption generated a 16-byte IV. GCM's standard/recommended nonce is 96 bits (12 bytes); non-standard sizes are internally re-hashed by GCM. Best-practice alignment.
Changes
src/core/MasterSeed.ts—export()now generates a 12-byte random nonce for new encryptions. Decrypt paths (import/importFromDerivedKey) continue to read the IV length from the stored record, so nothing on the read path is hardcoded.test/…— new exports carry a 12-byte IV and round-trip; a synthesized legacy 16-byte-IV blob still decrypts.Backward compatibility
✅ No impact on existing wallets. Old keystores store their own 16-byte IV and decrypt unchanged; only newly written blobs use the 12-byte nonce.
Testing
npx tsc --noEmitclean; MasterSeed suite green including the new legacy-IV decrypt test.Notes for reviewer
Pure best-practice tweak; no security-critical behavior change (the IV was already random and unique per encryption).