Skip to content

feat(ebe): support mpc signing for eddsa#34

Merged
pranavjain97 merged 7 commits intomasterfrom
WP-4759-ecdsa-signing-advanced-wallets
Jun 20, 2025
Merged

feat(ebe): support mpc signing for eddsa#34
pranavjain97 merged 7 commits intomasterfrom
WP-4759-ecdsa-signing-advanced-wallets

Conversation

@pranavjain97
Copy link
Copy Markdown
Contributor

No description provided.

@pranavjain97 pranavjain97 force-pushed the WP-4759-ecdsa-signing-advanced-wallets branch from b57fd78 to 62c91a3 Compare June 19, 2025 22:12
@pranavjain97 pranavjain97 changed the title Wp 4759 ecdsa signing advanced wallets Wp 4759 addsa signing advanced wallets Jun 19, 2025
@pranavjain97 pranavjain97 changed the title Wp 4759 addsa signing advanced wallets feat(ebe): support mpc signing for eddsa Jun 19, 2025
@pranavjain97 pranavjain97 marked this pull request as ready for review June 20, 2025 18:34
R = 'r',
G = 'g',

// TODO: Add ECDSA share types
Copy link
Copy Markdown
Contributor

@mtexeira-simtlix mtexeira-simtlix Jun 20, 2025

Choose a reason for hiding this comment

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

Hope this helps, for ECDSA I found this variant of shares on account-lib/mpc/tss/ecdsa/types.ts file from the SDK:

export type SignConvert = { xShare?: XShareWithChallenges; // XShare of the current participant yShare?: YShare; // YShare corresponding to the other participant kShare?: KShare; // KShare received from the other participant bShare?: BShare; // Private Beta share of the participant muShare?: MUShare; // muShare received from the other participant aShare?: AShare; wShare?: WShare; };

image

TL;DR: x, y, k, a, b, mu, w are the shares for ECDSA (also g but already added for EdDSA).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dw about ECSSA, i'll add them when we get to ECDSA signing

Comment thread src/api/enclaved/signMpcTransaction.ts Outdated

export async function signMpcTransaction(req: EnclavedApiSpecRouteRequest<'v1.mpc.sign', 'post'>) {
const { source, pub, encryptedDataKey } = req.decoded;
const { coin: coinName, shareType } = req.params;
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.

change: "coin" also comes from req.decoded (not params).

const { coin: coinName, shareType } = req.params;

if (!source || !pub) {
throw new Error('Source and public key are required for MPC signing');
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.

question: shouldn't we also need to do the logger.error call here? (and in the shareType check).

Comment thread src/api/enclaved/signMpcTransaction.ts
// Response type for /mpc/sign endpoint
const SignMpcResponse: HttpResponse = {
// TODO: Define proper response type for MPC transaction signing
200: t.any,
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.

reminder: add type to return type (is always the same type or does it varies depending what coin are you signing?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done!

Comment thread src/enclavedBitgoExpress/routers/enclavedApiSpec.ts
Comment thread src/kms/kmsClient.ts
try {
kmsResponse = await superagent
.post(`${this.url}/generateDataKey`)
.set('x-api-key', 'abc')
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.

Don't need to keep adding the api key, I removed it some weeks ago : D

Comment thread src/kms/kmsClient.ts
try {
kmsResponse = await superagent
.post(`${this.url}/decryptDataKey`)
.set('x-api-key', 'abc')
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.

same as prev comment.

Copy link
Copy Markdown
Contributor

@mtexeira-simtlix mtexeira-simtlix left a comment

Choose a reason for hiding this comment

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

Added a couple of comments

@pranavjain97 pranavjain97 force-pushed the WP-4759-ecdsa-signing-advanced-wallets branch from 2b43409 to bf30d2a Compare June 20, 2025 20:45
Copy link
Copy Markdown

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 adds support for MPC signing for EDDSA by introducing new routes, handlers, and associated tests while refactoring import paths to a shared types directory.

  • Updates import paths across multiple modules to use the new shared folder structure.
  • Introduces new API route "v1.mpc.sign" with corresponding handler (signMpcTransaction) and supporting functions for EDDSA MPC signing.
  • Adjusts test cases to align with the new file structure and updated dependency versions.

Reviewed Changes

Copilot reviewed 33 out of 37 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/types/request.ts Updated import paths for Config and EnclavedExpressClient.
src/shared/responseHandler.ts Changed Config import to shared/types.
src/shared/middleware.ts Updated import path for isMasterExpressConfig.
src/shared/appUtils.ts Adjusted import for Config and TlsMode.
src/routes/master.ts Moved master API router imports to new locations.
src/routes/enclaved.ts Corrected import order and paths for EnclavedConfig.
src/masterExpressApp.ts Updated import order for config initialization.
src/kms/kmsClient.ts Added functions to generate and decrypt data keys.
src/enclavedBitgoExpress/routers/enclavedApiSpec.ts Added new route definition for v1.mpc.sign.
src/enclavedApp.ts Adjusted imports for Enclaved configuration.
src/app.ts Updated imports for determineAppMode and AppMode.
src/api/master/routers/* Updated handler imports and middleware usage.
src/api/enclaved/handlers/signMpcTransaction.ts Implements new EDDSA MPC signing logic.
Tests Updated test imports and configurations for new structure.
Comments suppressed due to low confidence (1)

src/api/enclaved/handlers/signMpcTransaction.ts:156

  • [nitpick] Verify that using 'RSA-2048' as the key type for generating the data key is intentional in the context of EDDSA MPC signing, as the algorithm mismatch might be confusing.
      const dataKey = await generateDataKey({ keyType: 'RSA-2048', cfg });

Comment thread src/kms/kmsClient.ts
.set('x-api-key', 'abc')
.send(params);
} catch (error: any) {
console.log('Error generating data key from KMS', error);
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

Consider replacing console.log with the configured logger (e.g., logger.error) for better consistency in error logging.

Suggested change
console.log('Error generating data key from KMS', error);
debugLogger('Error generating data key from KMS: %O', error);

Copilot uses AI. Check for mistakes.
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.

let's do that.

Copy link
Copy Markdown
Contributor

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo left a comment

Choose a reason for hiding this comment

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

lgtm, couple of nits that can be followed up on.

Comment on lines +73 to +75
if (!source || !pub) {
throw new Error('Source and public key are required for MPC signing');
}
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.

why not just type them as required in the codec?

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.

oh I guess because this endpoint handles both signing rounds?

Comment on lines +77 to +79
if (!shareType) {
throw new Error('Share type is required for MPC signing');
}
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.

same here?

Comment on lines +150 to +152
if (!txRequest) {
throw new Error('txRequest is required for commitment share generation');
}
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 check is in both rounds, why not just make it required?

const SignMpcRequest = {
source: t.string,
pub: t.string,
txRequest: t.union([t.undefined, t.any]),
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.

isn't this required in both signing cases so can we define it as non-nullable?

Comment thread src/kms/kmsClient.ts
.set('x-api-key', 'abc')
.send(params);
} catch (error: any) {
console.log('Error generating data key from KMS', error);
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.

let's do that.

Comment thread src/kms/kmsClient.ts
.set('x-api-key', 'abc')
.send(params);
} catch (error: any) {
console.log('Error decrypting data key from KMS', error);
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.

debugLogger.

Comment thread src/kms/types/dataKey.ts
@@ -0,0 +1,27 @@
import z from 'zod';
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.

is the kms code moved to the same repo? i didn't realize we're using zod for it.

@pranavjain97 pranavjain97 merged commit 43fcf25 into master Jun 20, 2025
3 checks passed
@pranavjain97 pranavjain97 deleted the WP-4759-ecdsa-signing-advanced-wallets branch June 20, 2025 22: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.

4 participants