Skip to content

feat(mbe): add MPCv2 signing support to master/sendMany#57

Merged
pranavjain97 merged 2 commits into
masterfrom
WP-5152-mpcv2-signing-e2e
Jul 7, 2025
Merged

feat(mbe): add MPCv2 signing support to master/sendMany#57
pranavjain97 merged 2 commits into
masterfrom
WP-5152-mpcv2-signing-e2e

Conversation

@pranavjain97

@pranavjain97 pranavjain97 commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

Ticket: WP-5152

@pranavjain97 pranavjain97 force-pushed the WP-5151-mpc-ecdsa-onprem-ebe branch from 082cac6 to 713f293 Compare July 4, 2025 15:28
@pranavjain97 pranavjain97 force-pushed the WP-5152-mpcv2-signing-e2e branch from 1adcbfc to 30ba0c8 Compare July 4, 2025 15:29

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be calling the express endpoint directly.

Base automatically changed from WP-5151-mpc-ecdsa-onprem-ebe to master July 7, 2025 15:42
@pranavjain97 pranavjain97 dismissed mohammadalfaiyazbitgo’s stale review July 7, 2025 15:42

The base branch was changed.

@pranavjain97 pranavjain97 merged commit 30936ff into master Jul 7, 2025
3 checks passed
@pranavjain97 pranavjain97 deleted the WP-5152-mpcv2-signing-e2e branch July 7, 2025 16:03
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.

2 participants