feat(sdk-api): add v2 encrypt/decrypt using Argon2id#8495
Open
pranavjain97 wants to merge 4 commits intomasterfrom
Open
feat(sdk-api): add v2 encrypt/decrypt using Argon2id#8495pranavjain97 wants to merge 4 commits intomasterfrom
pranavjain97 wants to merge 4 commits intomasterfrom
Conversation
dfae16d to
0b1a2ad
Compare
597e548 to
c111d99
Compare
| */ | ||
| export async function decryptAsync(password: string, ciphertext: string): Promise<string> { | ||
| try { | ||
| const envelope = JSON.parse(ciphertext); |
Contributor
There was a problem hiding this comment.
worth io-ts decoding?
Contributor
Author
There was a problem hiding this comment.
not really, its an internal format we produce, not external input
b816e65 to
a9be0b8
Compare
mrdanish26
reviewed
Apr 16, 2026
| async function deriveKeyV2( | ||
| password: string, | ||
| salt: Uint8Array, | ||
| params: { memorySize: number; iterations: number; parallelism: number } |
Contributor
There was a problem hiding this comment.
m, t, and p are read from the parsed JSON envelope and passed straight into Argon2 with no caps. Because ciphertext is often untrusted, an attacker could set huge parameters and force excessive CPU/memory work on every decrypt attempt. Can we enforce maximum allowed values here?
Contributor
There was a problem hiding this comment.
The structure and valid values could easily be encoded in an io-ts codec.
Contributor
Author
There was a problem hiding this comment.
good catch, added io-ts codec for this
f05550c to
15275f9
Compare
Add encryptV2() and decryptV2() alongside existing v1 SJCL functions. V2 uses Argon2id (m=64MiB, t=3, p=4) for KDF and WebCrypto AES-256-GCM for symmetric encryption. Self-describing JSON envelope stores all parameters for forward compatibility. Existing v1 encrypt/decrypt is untouched. No call site changes. WCN-30 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> TICKET: WCN-30
Add decryptAsync() that auto-detects v1 (SJCL) or v2 (Argon2id) envelopes. This is the non-breaking migration path for clients to move from sync decrypt() to async before the breaking release. - decryptAsync() on encrypt.ts and BitGoAPI - decryptAsync on BitGoBase interface - Tests for v1 and v2 auto-detection, wrong password rejection WCN-30 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> TICKET: WCN-30
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> TICKET: WCN-30
15275f9 to
f4ae573
Compare
mrdanish26
approved these changes
Apr 16, 2026
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.
Add encryptV2() and decryptV2() alongside existing v1 SJCL functions. V2 uses Argon2id (m=64MiB, t=3, p=4) for KDF and WebCrypto AES-256-GCM for symmetric encryption. Self-describing JSON envelope stores all parameters for forward compatibility.
Existing v1 encrypt/decrypt is untouched. No call site changes.