Skip to content

perf(sdk-core): apply HKDF across bulk wallet share flows - #9552

Open
pranavjain97 wants to merge 4 commits into
masterfrom
pranavjain/wcn-2314-apply-encryptionsession-hkdf-across-bulk-wallet-share-flows
Open

perf(sdk-core): apply HKDF across bulk wallet share flows#9552
pranavjain97 wants to merge 4 commits into
masterfrom
pranavjain/wcn-2314-apply-encryptionsession-hkdf-across-bulk-wallet-share-flows

Conversation

@pranavjain97

Copy link
Copy Markdown
Contributor

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

  • New unit tests added, existing suite unaffected.
  • yarn install + full workspace build clean.
  • Browser smoke test at bulk scale.
  • Webauthn accept path with a real passkey device.

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
@pranavjain97
pranavjain97 requested review from a team as code owners August 24, 2026 16:30
@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

WCN-2314

@pranavjain97 pranavjain97 changed the title Pranavjain/wcn 2314 apply encryptionsession hkdf across bulk wallet share flows perf(sdk-core): apply EncryptionSession HKDF across bulk wallet share flows Aug 24, 2026
@pranavjain97 pranavjain97 changed the title perf(sdk-core): apply EncryptionSession HKDF across bulk wallet share flows perf(sdk-core): apply HKDF across bulk wallet share flows Aug 24, 2026
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
pranavjain97 force-pushed the pranavjain/wcn-2314-apply-encryptionsession-hkdf-across-bulk-wallet-share-flows branch from ecb2da3 to b8f4284 Compare August 24, 2026 17:24
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