Skip to content

feat: add v2 encrypt/decrypt support to WRW flows#8828

Open
bdesoky wants to merge 1 commit into
masterfrom
WCN-172
Open

feat: add v2 encrypt/decrypt support to WRW flows#8828
bdesoky wants to merge 1 commit into
masterfrom
WCN-172

Conversation

@bdesoky
Copy link
Copy Markdown
Contributor

@bdesoky bdesoky commented May 21, 2026

Ticket: WCN-172

This pull request refactors key decryption logic across multiple coin modules to use the asynchronous decryptAsync method instead of the synchronous decrypt method. Additionally, it updates the Web Crypto usage in encryptV2.ts to ensure compatibility with both browser and Node.js environments by using the correct subtle crypto implementation. These changes improve security, performance, and compatibility.

Key Decryption Refactor

Migration to async decryption:

  • Replaces all instances of this.bitgo.decrypt with await this.bitgo.decryptAsync for user and backup key decryption in the following coins and modules:

Crypto Compatibility Improvements

Web Crypto subtle selection:

  • Updates encryptV2.ts to use a subtle variable that references either the browser's crypto.subtle or Node's webcrypto.subtle, ensuring compatibility across environments. All cryptographic operations (importKey, deriveKey, encrypt, decrypt) now use this unified reference. [1] [2] [3] [4] [5]

These changes modernize the codebase to use asynchronous cryptography APIs, which is essential for non-blocking operations, and ensure that cryptographic functions work seamlessly in both browser and Node.js contexts.

WRW Local Test

Tested by wiring the modules from local BitGoJs (with these changes) into WRW. A HTETH wallet was created in staging with encryptionVersion: 2. Before these changes, the following error would appear when attempting to use the WRW:
image
With the changes wired up:

Screen.Recording.2026-05-21.at.5.47.35.PM.mov

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 21, 2026

WCN-172

@bdesoky bdesoky force-pushed the WCN-172 branch 2 times, most recently from 9fbbd43 to f78b977 Compare May 21, 2026 21:27
@bdesoky bdesoky marked this pull request as ready for review May 21, 2026 22:07
@bdesoky bdesoky requested review from a team as code owners May 21, 2026 22:07
@bdesoky bdesoky requested review from Marzooqa and vinhkhangtieu May 21, 2026 22:07
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