Skip to content

A-1213877919321096: Security - #254

Merged
owlsua merged 2 commits into
mainfrom
A-1213877919321096
Aug 3, 2026
Merged

owlsua merged 2 commits into
mainfrom
A-1213877919321096

Conversation

@owlsua

@owlsua owlsua commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

💬 Description

Security improvements

More

  • Upgraded wallet encryption to AES-256 via a new encryption version (V3)
  • Existing V1/V2 accounts stay decryptable and auto-migrate to V3 on unlock
  • Hardened hexToBytes against null/empty input
  • Refactored account service to remove duplicate DB loads (getAccount() reuse)
  • Removed a wasted PBKDF2 derivation on account creation
  • Aligned unlockAccount error shape with its success shape
  • Added migration round-trip tests (v1→v2, v2→v3, v1→v3)
  • Tests

📋 Checklist:

  • I have named my branch as A-[id of Asana task]
  • I have set the title of my PR as A-[id of Asana task]: [short description]
  • My changes passed successfully by prettier check
  • My changes passed successfully by lint check
  • My changes kept the previous test coverage rate
  • I have added enough tests for my new feature/bugfix
  • I have set at least one person to review this PR
  • I have set myself as the assignee of this PR
  • I have set at least one label to this PR

owlsua added 2 commits July 2, 2026 22:30
Introduce a version-aware key size so V3 derives a 256-bit key
(AES-256-GCM) while V1/V2 keep their 128-bit keys for backward-compatible
decryption of already-stored data. Existing accounts are migrated to V3
on unlock via the existing reEncryptAccount flow.

Also guard hexToBytes against null/empty input to avoid a TypeError on
malformed data. Adds migration round-trip tests (v1->v2, v2->v3, v1->v3).
Reuse getAccount() instead of repeating loadAccounts()+get(), collapse the
duplicate loadAccountSubRoutines() call in reEncryptAccount, and reuse the
already-computed accountVersion in unlockAccount.

saveAccount no longer derives a key just to obtain a salt: getEncryptedPrivateKeys
now generates the salt when none is passed and returns it, removing one
expensive PBKDF2 derivation per account creation.

Align the unlockAccount rejection shape with its success shape (addresses,
btcPrivateKeys) so consumers can destructure consistently on error.
@owlsua owlsua self-assigned this Jul 2, 2026
@owlsua owlsua added the security label Jul 2, 2026
@owlsua
owlsua requested a review from anyxem July 2, 2026 21:36
@owlsua owlsua changed the title A 1213877919321096 A-1213877919321096: Security Jul 2, 2026
@owlsua
owlsua merged commit 37efe6e into main Aug 3, 2026
1 check passed
@owlsua
owlsua deleted the A-1213877919321096 branch August 3, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants