Skip to content

Conversation

@mohammadalfaiyazbitgo
Copy link
Contributor

No description provided.

This comment was marked as outdated.

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo force-pushed the tests/mpc-dkg branch 2 times, most recently from 4999da5 to 5b3e4d5 Compare August 1, 2025 14:13
Comment on lines 17 to 30
debugLogger('MPC Finalize request received');
debugLogger('Request inputs:', {
source: req.decoded.source,
coin: req.decoded.coin,
encryptedData: req.decoded.encryptedData,
encryptedDataKey: req.decoded.encryptedDataKey,
bitgoKeyChain: req.decoded.bitgoKeyChain,
counterPartyGpgPub: req.decoded.counterPartyGpgPub,
counterPartyKeyShare: req.decoded.counterPartyKeyShare,
bitgoKeyChainKeyShares: req.decoded.bitgoKeyChain.keyShares.map((keyShare: any) =>
JSON.stringify(keyShare),
),
});

Copy link
Contributor

Choose a reason for hiding this comment

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

remove

coin: coinInstance,
verifySignatures: [
source === 'user' ? sourceGpgPub : counterPartyGpgPub,
source === 'user' ? counterPartyGpgPub : sourceGpgPub,
Copy link
Contributor

Choose a reason for hiding this comment

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

did u mean source === 'backup here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no,

async verifyWalletSignatures(
    userGpgPub: string,
    backupGpgPub: string,
    bitgoKeychain: Keychain,
    decryptedShare: string,
    verifierIndex: 1 | 2,
    useHardcodedBitGoKeys?: {
      env: EnvironmentName;
      pubKeyType: 'nitro' | 'onprem';
    }
  ): Promise<void> {

if the source is 'user' then we have to provide the source gpg key for userGpgKey, and vice versa.

sourceIndex,
{
env: req.bitgo.env,
pubKeyType: 'onprem',
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we were fetching constants from bitgo in the sdk method for this check, i added some changes to the SDK to use the hard coded ones if these options were given. BitGo/BitGoJS@520d70d

Comment on lines 18 to 19
debugLogger('MPC Initialize request received');
debugLogger('Request inputs:', { source: req.decoded.source });
Copy link
Contributor

Choose a reason for hiding this comment

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

is this helpful? also, we use logger.debug for all the logs

Comment on lines 146 to 149
): Promise<EDDSA.KeyCombine> {
const eddsa = await bitgoSdk.Eddsa.initialize();
return eddsa.keyCombine(...params);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need a helper just for this? It might be clearer to do this at the caller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was because getting a mock to work on this method was next to impossible so i removed it out and mocked it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements MPC (Multi-Party Computation) Distributed Key Generation (DKG) functionality with comprehensive test coverage. The changes include adding error stack traces to response handling, refactoring MPC finalize operations to use utility functions, and introducing extensive test suites for both MPC initialization and finalization workflows.

  • Enhances error debugging by including stack traces in error responses
  • Refactors MPC finalize operations to use centralized utility functions for better maintainability
  • Adds comprehensive test coverage for MPC initialization and finalization workflows
  • Updates package dependencies to latest beta versions

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/shared/responseHandler.ts Adds stack trace information to error responses for better debugging
src/api/advancedWalletManager/utils.ts Introduces utility functions for EDDSA operations and wallet signature verification
src/api/advancedWalletManager/mpcInitialize.ts Improves error handling by using specific BadRequestError
src/api/advancedWalletManager/mpcFinalize.ts Refactors to use utility functions and improves parameter structure
src/advancedWalletManager/routers/advancedWalletManagerApiSpec.ts Removes redundant error handling now managed by responseHandler
src/tests/api/master/recoveryWalletMpcV2.test.ts Updates chain ID in test expectations
src/tests/api/advancedWalletManager/mpcInitialize.test.ts Adds comprehensive test suite for MPC initialization
src/tests/api/advancedWalletManager/mpcFinalize.test.ts Adds comprehensive test suite for MPC finalization
package.json Updates BitGo SDK dependencies to latest beta versions
masterBitgoExpress.json Updates API schema to include stack trace in error responses

Comment on lines +100 to 103
const combinedKey = await eddsaKeyCombine([
sourcePrivateShare,
[bitgoToSourceYShare, counterPartyToSourceYShare],
]);
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The parameters passed to eddsaKeyCombine don't match the function signature. The function expects Parameters<Eddsa['keyCombine']> but is receiving an array with sourcePrivateShare and an array of yShares. This should be sourcePrivateShare as first parameter and the array of yShares as second parameter, not wrapped in an outer array.

Suggested change
const combinedKey = await eddsaKeyCombine([
sourcePrivateShare,
[bitgoToSourceYShare, counterPartyToSourceYShare],
]);
const combinedKey = await eddsaKeyCombine(
sourcePrivateShare,
[bitgoToSourceYShare, counterPartyToSourceYShare],
);

Copilot uses AI. Check for mistakes.
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo force-pushed the tests/mpc-dkg branch 3 times, most recently from 086ee67 to 24bb820 Compare August 6, 2025 17:21
pranavjain97
pranavjain97 previously approved these changes Aug 6, 2025
Copy link
Contributor

@pranavjain97 pranavjain97 left a comment

Choose a reason for hiding this comment

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

lgtm; just fix CI and double check the copilot comment

- added tests for mpc finalize
- added tests for mpc initalize

Ticket: WP-5338
@pranavjain97 pranavjain97 merged commit 36ac2de into master Aug 6, 2025
4 checks passed
@pranavjain97 pranavjain97 deleted the tests/mpc-dkg branch August 6, 2025 17:37
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.

3 participants