Repository navigation
feat(sdk-core): upgrade v1 user keys to argon2 on sign - #10129
pranavjain97 merged 7 commits into
Conversation
587e6a1 to
c20c23b
Compare
|
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review |
|
Claude finished @nayandas190's task in 44s —— View job Review of #10129: upgrade v1 user keys to argon2 on signI read the Overall: The design is sound and I found nothing blocking. The upgrade is opt-in. It verifies the new envelope with a decrypt round-trip before writing. It uses Worth considering
Minor
I'd go with item 1 as the one change before merge. The rest are optional. |
There was a problem hiding this comment.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🔴
modules/sdk-core/src/bitgo/keychain/upgradeEncryption.ts— With an older sdk-api or a customBitGoBase, signing and Lightning payments with a passphrase now throw a TypeError. Base signs normally.shouldUpgradeEncryptioncallsbitgo.isUpgradeEncryptionOnSignEnabled()without checking it exists. It runs inside the signing call, before the upgrade, which is the only part that never throws. Fix: treat a missing method as false (typeof bitgo.isUpgradeEncryptionOnSignEnabled === 'function' && ...) so all 5 call sites keep signing. Sites: wallet.ts:655, pendingApproval.ts:493, lightning.ts:295, lightning.ts:425. [also at: modules/sdk-core/src/bitgo/wallet/wallet.ts:681 - Signing can now fail with a TypeError when the BitGo object lacksisUpgradeEncryptionOnSignEnabled. That breaks the promise that the upgrade never affects signing.; modules/sdk-core/src/bitgo/wallet/wallet.ts:2660 - A signing call can now fail with a TypeError when the BitGo object has noisUpgradeEncryptionOnSignEnabledmethod.]Why this was flagged
Trigger: a BitGoBase object that does not define the new
isUpgradeEncryptionOnSignEnabledmethod. Examples are an older @ bitgo/sdk-api BitGoAPI installed next to a newer @ bitgo/sdk-core, or a custom or mock BitGoBase. On the common path (walletPassphrase given, keychain has an encryptedPrv, no prv), Wallet.startUserKeyEncryptionUpgrade (wallet.ts:655) calls shouldUpgradeEncryption synchronously inside signTransaction, signTypedData and signMessage. LightningWallet.payInvoice and withdrawOnchain call it with no condition (lightning.ts:295, 425), and so does PendingApproval.recreateAndSignTSSTransaction (pendingApproval.ts:493). The call throwsTypeError: bitgo.isUpgradeEncryptionOnSignEnabled is not a function, so the sign, payment or approval fails before it reaches the server. On the base branch these calls succeed. The PR says the upgrade never blocks or fails signing, but the guard sits outside the never-throw upgradeEncryption promise, so that promise does not protect this call.Verification: In
modules/sdk-core/src/bitgo/keychain/upgradeEncryption.tsthe function sits at about line 14. It isreturn upgradeEncryption ?? bitgo.isUpgradeEncryptionOnSignEnabled();. It does not check that the method exists, so it throws a TypeError whenever no per-callupgradeEncryptionis given. On the base commit these calls sign normally.
Adds opt-in upgrading of v1 user keys to v2 (argon2) encryption when a user signs. The upgrade runs in the background, after signing, and never blocks or fails the signing call.
Enabling it
BitGoconstructor optionupgradeEncryptionOnSign(defaultfalse), read throughbitgo.isUpgradeEncryptionOnSignEnabled().upgradeEncryption?: booleanon signing options, which overrides the constructor setting. It is never sent to the server.Where it runs
wallet.signTransaction(multisig, TSS, OFC),wallet.signMessage,wallet.signTypedDatapendingApproval.approve(TSS recreate and sign)payInvoiceandwithdrawOnchain(user auth key)Safety
encryptedPrv, so the server rejects it if the key changed in the meantime. That case is reported asskipped: keyChanged.Issue Number
WCN-285