Skip to content

feat(sdk-api): add v2 encrypt/decrypt using Argon2id#8495

Merged
pranavjain97 merged 4 commits intomasterfrom
WCN-30-v2-encrypt-decrypt
Apr 17, 2026
Merged

feat(sdk-api): add v2 encrypt/decrypt using Argon2id#8495
pranavjain97 merged 4 commits intomasterfrom
WCN-30-v2-encrypt-decrypt

Conversation

@pranavjain97
Copy link
Copy Markdown
Contributor

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.

@pranavjain97 pranavjain97 requested review from a team as code owners April 13, 2026 20:52
@linear
Copy link
Copy Markdown

linear bot commented Apr 13, 2026

@pranavjain97 pranavjain97 force-pushed the WCN-29-vendor-hash-wasm branch from dfae16d to 0b1a2ad Compare April 13, 2026 21:33
@pranavjain97 pranavjain97 requested review from a team as code owners April 14, 2026 17:01
@pranavjain97 pranavjain97 force-pushed the WCN-30-v2-encrypt-decrypt branch from 597e548 to c111d99 Compare April 14, 2026 17:09
Comment thread modules/sdk-api/src/bitgoAPI.ts
Comment thread modules/sdk-api/src/encrypt.ts Outdated
@pranavjain97 pranavjain97 changed the base branch from WCN-29-vendor-hash-wasm to master April 14, 2026 18:25
Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts Outdated
Comment thread modules/sdk-core/src/bitgo/bitgoBase.ts
@pranavjain97 pranavjain97 force-pushed the WCN-30-v2-encrypt-decrypt branch 5 times, most recently from b816e65 to a9be0b8 Compare April 15, 2026 19:18
Comment thread modules/sdk-api/src/encrypt.ts
@pranavjain97 pranavjain97 force-pushed the WCN-30-v2-encrypt-decrypt branch 3 times, most recently from f05550c to 15275f9 Compare April 16, 2026 19:41
@pranavjain97 pranavjain97 requested a review from mrdanish26 April 16, 2026 20:04
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
Replace hand-written if-checks and V2Envelope interface with a
V2EnvelopeCodec that enforces type safety, Argon2id parameter caps,
and non-empty base64 strings in a single decode step.

WCN-30

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

TICKET: WCN-30
@pranavjain97 pranavjain97 force-pushed the WCN-30-v2-encrypt-decrypt branch from 15275f9 to f4ae573 Compare April 16, 2026 21:01
Copy link
Copy Markdown
Contributor

@zahin-mohammad zahin-mohammad left a comment

Choose a reason for hiding this comment

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

minor nits, can address in a follow up.

Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
Copy link
Copy Markdown
Contributor Author

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

will address comments in followup, non blocking

Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
Comment thread modules/sdk-api/src/encrypt.ts
@pranavjain97 pranavjain97 merged commit 2ece7cd into master Apr 17, 2026
31 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.

3 participants