perf(sdk-core): apply HKDF across bulk wallet share flows - #9552
Open
pranavjain97 wants to merge 4 commits into
Open
perf(sdk-core): apply HKDF across bulk wallet share flows#9552pranavjain97 wants to merge 4 commits into
pranavjain97 wants to merge 4 commits into
Conversation
createEncryptionSession(pw, { encryptionVersion }) returns a
V1EncryptionSession shim when v1 is pinned. Same IEncryptionSession
interface, runs SJCL PBKDF2 per call instead of opening an HKDF
session.
Lets callers use one factory regardless of envelope version, no
useV2 branching at call sites.
TICKET: WCN-2314
Contributor
Collapses N encrypt-side Argon2 derivations to 1 (2 with webauthn). One session over newWalletPassphrase + independent session over webauthnInfo.passphrase; per-share adata (walletShare.enterprise) threaded per call so webauthn envelopes stay enterprise-bound. BATCH_SIZE=16 preserved as the decrypt-side WASM OOM guard. TICKET: WCN-2314
Same shape as bulkAcceptShare. One session over newWalletPassphrase || userLoginPassword covers all three accept paths in processAcceptShare. createUserKeychain accepts an optional IEncryptionSession so the specialOverrideCase batch collapses too. Session skipped for reject-only bulks. Mirrors BATCH_SIZE=16. TICKET: WCN-2314
Decrypt the wallet keychain once and thread the plaintext into every shareWallet call via a new optional decryptedKeychain param on ShareWalletOptions. Saves N-1 Argon2 decrypts of the same encryptedPrv. Per-recipient encrypt still uses a unique ECDH-derived secret (irreducible). Sequential loop preserved to bound WASM instances. TICKET: WCN-2314
pranavjain97
force-pushed
the
pranavjain/wcn-2314-apply-encryptionsession-hkdf-across-bulk-wallet-share-flows
branch
from
August 24, 2026 17:24
ecb2da3 to
b8f4284
Compare
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.
Summary
Run Argon2id once per bulk share operation instead of once per share, via createEncryptionSession. Halves wall time on the recipient's re-encrypt path for large bulks.
Fixes WCN-2314.
Impact
The encrypt side collapses from N Argon2 derivations to 1 (2 with webauthn). Decrypt side still runs N Argon2 because each share has a unique ECDH-derived password — no session can span them — batched to bound
WASM memory. Full elimination requires WCN-2400.
Security
Fresh hkdfSalt per envelope keeps per-envelope AES keys cryptographically independent (same isolation as pre-Argon2). Session destroy() in try/finally guarantees the HKDF root never outlives the operation. v1
(SJCL) callers keep the pre-existing contract via the shim.
Test plan