Skip to content

feat(sdk-api): hkdf caching encryption for multi call operations#8508

Open
pranavjain97 wants to merge 2 commits intomasterfrom
pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations
Open

feat(sdk-api): hkdf caching encryption for multi call operations#8508
pranavjain97 wants to merge 2 commits intomasterfrom
pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations

Conversation

@pranavjain97
Copy link
Copy Markdown
Contributor

@pranavjain97 pranavjain97 commented Apr 14, 2026

Summary

Adds v2 encryption (Argon2id + AES-256-GCM) alongside existing v1 SJCL, with an HKDF session caching layer for multi-call operations.

  • encryptV2 / decryptV2: Argon2id (m=64MiB, t=3, p=4) KDF + AES-256-GCM. Self-describing JSON envelope with all parameters.
  • decryptAsync: Auto-detects v1/v2 from envelope v field. Non-breaking migration path from sync decrypt().
  • io-ts codec: V2EnvelopeCodec validates structure and caps Argon2id parameters to prevent DoS.
  • createEncryptionSession: Runs Argon2id once, derives per-call AES keys via HKDF (<1ms each). For multi-encrypt flows like MPC signing.

Existing v1 encrypt/decrypt is untouched. Call site usages in the wallet flows will be done in a separate PR while being backwards compatible with sjcl.

@linear
Copy link
Copy Markdown

linear bot commented Apr 14, 2026

@pranavjain97 pranavjain97 force-pushed the pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations branch from 7794281 to fe17e9c Compare April 14, 2026 19:41
@pranavjain97 pranavjain97 force-pushed the WCN-30-v2-encrypt-decrypt branch 2 times, most recently from b816e65 to a9be0b8 Compare April 15, 2026 19:18
@pranavjain97 pranavjain97 force-pushed the pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations branch 4 times, most recently from 80f7404 to 125015d Compare April 15, 2026 19:55
@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 force-pushed the pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations branch 4 times, most recently from 063a97d to fafc5ef Compare April 16, 2026 20:47
@pranavjain97 pranavjain97 force-pushed the WCN-30-v2-encrypt-decrypt branch from 15275f9 to f4ae573 Compare April 16, 2026 21:01
Introduces createEncryptionSession() that runs Argon2id once and derives
per-call AES-256-GCM keys via HKDF (<1ms each), eliminating repeated
expensive KDF calls in multi-encrypt/decrypt flows.

- createEncryptionSession() in encrypt.ts: Argon2id -> HKDF CryptoKey
- EncryptionSession interface: encrypt(), decrypt(), destroy()
- V2Envelope extended with optional hkdfSalt for session-produced envelopes
- decryptV2 handles both standalone and session envelopes
- decryptAsync fix: v2 errors no longer fall through silently to v1

WCN-31

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@pranavjain97 pranavjain97 force-pushed the pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations branch from fafc5ef to 933e2f8 Compare April 16, 2026 21:21
@pranavjain97 pranavjain97 requested a review from a team April 16, 2026 21:24
@pranavjain97 pranavjain97 marked this pull request as ready for review April 17, 2026 19:10
@pranavjain97 pranavjain97 requested review from a team as code owners April 17, 2026 19:10
@pranavjain97 pranavjain97 changed the base branch from WCN-30-v2-encrypt-decrypt to master April 17, 2026 19:10
- Throw on invalid JSON in decryptAsync instead of silently falling through
- Use static import for @bitgo/argon2 instead of dynamic import
- Remove @deprecated from decrypt() on BitGoBase interface
- Add test for invalid JSON input in decryptAsync

WCN-31

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@pranavjain97 pranavjain97 force-pushed the pranavjain/wcn-31-phase-1-hkdf-caching-layer-for-multi-call-operations branch from dfd5c83 to 49267e8 Compare April 17, 2026 19:40
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