feat(mbe): add MPCv2 signing support to master/sendMany#57
Merged
Conversation
082cac6 to
713f293
Compare
1adcbfc to
30ba0c8
Compare
mohammadalfaiyazbitgo
previously approved these changes
Jul 4, 2025
mohammadalfaiyazbitgo
left a comment
Contributor
There was a problem hiding this comment.
not gonna block, but i think refactoring to directly use sendMany would make sense no?
| const txRequest = await getTxRequest(bitgo, wallet.id(), txRequestId, reqId); | ||
|
|
||
| const { apiVersion } = txRequestResolved; | ||
| const { apiVersion } = txRequest; |
Contributor
There was a problem hiding this comment.
i thought we'd default to full?
Comment on lines
+13
to
+115
| export async function handleEcdsaSigning( | ||
| bitgo: BitGoBase, | ||
| wallet: Wallet, | ||
| txRequestId: string, | ||
| enclavedExpressClient: EnclavedExpressClient, | ||
| source: 'user' | 'backup', | ||
| commonKeychain: string, | ||
| reqId?: IRequestTracer, | ||
| ) { | ||
| const ecdsaMPCv2Utils = new EcdsaMPCv2Utils(bitgo, wallet.baseCoin); | ||
| const txRequest = await getTxRequest(bitgo, wallet.id(), txRequestId, reqId); | ||
|
|
||
| // Get BitGo GPG key for MPCv2 | ||
| const bitgoGpgKey = await ecdsaMPCv2Utils.getBitgoMpcv2PublicGpgKey(); | ||
|
|
||
| // Round 1: Generate user's Round 1 share | ||
| const { | ||
| signatureShareRound1, | ||
| userGpgPubKey, | ||
| encryptedRound1Session, | ||
| encryptedUserGpgPrvKey, | ||
| encryptedDataKey, | ||
| } = await enclavedExpressClient.signMpcV2Round1({ | ||
| txRequest, | ||
| bitgoGpgPubKey: bitgoGpgKey.armor(), | ||
| source, | ||
| pub: commonKeychain, | ||
| }); | ||
|
|
||
| // Send Round 1 share to BitGo and get updated txRequest | ||
| const round1TxRequest = await commonTssMethods.sendSignatureShareV2( | ||
| bitgo, | ||
| wallet.id(), | ||
| txRequestId, | ||
| [signatureShareRound1], | ||
| RequestType.tx, | ||
| wallet.baseCoin.getMPCAlgorithm(), | ||
| userGpgPubKey, | ||
| undefined, | ||
| wallet.multisigTypeVersion(), | ||
| reqId, | ||
| ); | ||
|
|
||
| // Round 2: Generate user's Round 2 share | ||
| const { signatureShareRound2, encryptedRound2Session } = | ||
| await enclavedExpressClient.signMpcV2Round2({ | ||
| txRequest: round1TxRequest, | ||
| bitgoGpgPubKey: bitgoGpgKey.armor(), | ||
| encryptedDataKey, | ||
| encryptedUserGpgPrvKey, | ||
| encryptedRound1Session, | ||
| source, | ||
| pub: commonKeychain, | ||
| }); | ||
|
|
||
| // Send Round 2 share to BitGo and get updated txRequest | ||
| const round2TxRequest = await commonTssMethods.sendSignatureShareV2( | ||
| bitgo, | ||
| wallet.id(), | ||
| txRequestId, | ||
| [signatureShareRound2], | ||
| RequestType.tx, | ||
| wallet.baseCoin.getMPCAlgorithm(), | ||
| userGpgPubKey, | ||
| undefined, | ||
| wallet.multisigTypeVersion(), | ||
| reqId, | ||
| ); | ||
|
|
||
| // Round 3: Generate user's Round 3 share | ||
| const { signatureShareRound3 } = await enclavedExpressClient.signMpcV2Round3({ | ||
| txRequest: round2TxRequest, | ||
| bitgoGpgPubKey: bitgoGpgKey.armor(), | ||
| encryptedDataKey, | ||
| encryptedUserGpgPrvKey, | ||
| encryptedRound2Session, | ||
| source, | ||
| pub: commonKeychain, | ||
| }); | ||
|
|
||
| // Send Round 3 share to BitGo | ||
| await commonTssMethods.sendSignatureShareV2( | ||
| bitgo, | ||
| wallet.id(), | ||
| txRequestId, | ||
| [signatureShareRound3], | ||
| RequestType.tx, | ||
| wallet.baseCoin.getMPCAlgorithm(), | ||
| userGpgPubKey, | ||
| undefined, | ||
| wallet.multisigTypeVersion(), | ||
| reqId, | ||
| ); | ||
|
|
||
| logger.debug('Successfully completed ECDSA MPCv2 signing!'); | ||
| return commonTssMethods.sendTxRequest( | ||
| bitgo, | ||
| txRequest.walletId, | ||
| txRequest.txRequestId, | ||
| RequestType.tx, | ||
| reqId, | ||
| ); | ||
| } |
Contributor
There was a problem hiding this comment.
nit: I think this could all be wrapped into how express does mpcv2/v1 signings
https://github.com/BitGo/BitGoJS/blob/5367fbb471b81a6d3f7b95b30df69e431b623418/modules/sdk-core/src/bitgo/wallet/wallet.ts#L1936
Contributor
There was a problem hiding this comment.
in fact I think you could refactor the signings calls and put them into sendMany.
Comment on lines
+243
to
+251
| const result = await handleEcdsaSigning( | ||
| bitgo, | ||
| wallet, | ||
| txRequest.txRequestId, | ||
| enclavedExpressClient, | ||
| 'user', | ||
| userPubKey, | ||
| reqId, | ||
| ); |
Contributor
There was a problem hiding this comment.
this should be calling the express endpoint directly.
The base branch was changed.
mohammadalfaiyazbitgo
approved these changes
Jul 7, 2025
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.
Ticket: WP-5152