Skip to content

fix(crypto): use 12-byte AES-GCM nonce for new seed exports - #4

Open
adequatelimited wants to merge 1 commit into
mainfrom
fix/ar4-gcm-nonce-12
Open

fix(crypto): use 12-byte AES-GCM nonce for new seed exports#4
adequatelimited wants to merge 1 commit into
mainfrom
fix/ar4-gcm-nonce-12

Conversation

@adequatelimited

Copy link
Copy Markdown
Collaborator

Repo: adequatesystems/mochimo-wallet · Branch: fix/ar4-gcm-nonce-12main
Audit 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.tsexport() 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 --noEmit clean; 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).

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.
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.

1 participant