Skip to content

feat(sdk-core): add v2 decryption support to password change#8804

Merged
bdesoky merged 1 commit into
masterfrom
WCN-281
May 21, 2026
Merged

feat(sdk-core): add v2 decryption support to password change#8804
bdesoky merged 1 commit into
masterfrom
WCN-281

Conversation

@bdesoky
Copy link
Copy Markdown
Contributor

@bdesoky bdesoky commented May 19, 2026

Ticket: WCN-281

This pull request adds support for updating passwords on both v1 (SJCL) and v2 (Argon2id) encrypted keychains, ensuring that the encryption version is preserved during password changes. It introduces the new asynchronous method updateSingleKeychainPasswordAsync, updates tests to cover mixed-version keychains, and refactors code to use the new async methods where appropriate.

Keychain password update enhancements

  • Added updateSingleKeychainPasswordAsync to the Keychains class, which supports both v1 and v2 (Argon2id) keychain envelopes and preserves the encryption version during password updates.
  • Updated the updatePassword method and related code paths to use updateSingleKeychainPasswordAsync for asynchronous and version-aware password changes. [1] [2]

Interface and documentation updates

  • Extended the IKeychains interface to include the new updateSingleKeychainPasswordAsync method and clarified documentation for both sync and async methods. [1] [2]

Test improvements

  • Added and updated tests in keychains.ts to verify that password updates work with both v1 and v2 keychains, including cases with mixed keychain versions and ensuring the encryption version is preserved.
  • Refactored stubs and mocks in tests to use the new async methods and ensure correct error handling. [1] [2]

Refactoring for async cryptography

  • Replaced synchronous decrypt calls with decryptAsync in keychain-related code to ensure compatibility with Argon2id and asynchronous cryptographic operations.

Dependency updates

  • Imported EncryptionVersion where needed to support version detection and preservation logic.

This pull request introduces support for updating passwords on both v1 (SJCL) and v2 (Argon2id) encrypted keychains, ensuring that v2 keychains retain their encryption version after a password change. It adds an asynchronous method for updating a single keychain password, refactors code to use this method where appropriate, and enhances tests to cover mixed-version scenarios.

Keychain password update enhancements

  • Added a new method updateSingleKeychainPasswordAsync to the Keychains class, which supports updating passwords for both v1 and v2 (Argon2id) keychains while preserving the encryption version.
  • Updated updatePassword and related code paths to use the new asynchronous method, ensuring compatibility with both keychain versions. [1] [2]

Interface and API changes

  • Extended the IKeychains interface to include the new updateSingleKeychainPasswordAsync method.
  • Improved documentation for both the synchronous and asynchronous single keychain password update methods. [1] [2]

Test improvements

  • Enhanced tests to verify that password updates preserve v2 envelopes and correctly handle a mix of v1 and v2 keychains. Refactored tests to use the async method and updated stubs accordingly. [1] [2] [3]

Internal refactoring

  • Refactored decryption calls in keychain-related methods to use the asynchronous decryptAsync method for consistency and improved error handling.
  • Added necessary imports and minor code cleanups to support the new functionality.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

WCN-281

@bdesoky bdesoky marked this pull request as ready for review May 19, 2026 15:35
@bdesoky bdesoky requested review from a team as code owners May 19, 2026 15:35
@bdesoky bdesoky requested review from mrdanish26 and ranga-r2 May 19, 2026 15:35
Comment thread modules/sdk-core/src/bitgo/keychain/iKeychains.ts Outdated
@bdesoky bdesoky marked this pull request as draft May 19, 2026 19:49
@bdesoky bdesoky marked this pull request as ready for review May 19, 2026 20:39
Comment thread modules/sdk-core/src/bitgo/keychain/keychains.ts
Comment thread modules/sdk-core/src/bitgo/keychain/keychains.ts Outdated
Comment thread modules/sdk-core/src/bitgo/keychain/keychains.ts
@bdesoky bdesoky requested a review from pranavjain97 May 20, 2026 21:00
@bdesoky bdesoky force-pushed the WCN-281 branch 2 times, most recently from 0340c71 to 1bb217a Compare May 21, 2026 17:27
Comment thread modules/sdk-core/src/bitgo/keychain/keychains.ts
Comment thread modules/bitgo/test/v2/unit/keychains.ts
Copy link
Copy Markdown
Contributor

@pranavjain97 pranavjain97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@bdesoky bdesoky merged commit b2239f5 into master May 21, 2026
24 checks passed
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.

2 participants