Skip to content

Commit bf30d2a

Browse files
committed
chore: add mpc signing response type
Ticket: WP-4759
1 parent 50a5dea commit bf30d2a

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

src/api/enclaved/signMpcTransaction.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ interface EddsaSigningParams {
6868
}
6969

7070
export async function signMpcTransaction(req: EnclavedApiSpecRouteRequest<'v1.mpc.sign', 'post'>) {
71-
const { source, pub, encryptedDataKey } = req.decoded;
72-
const { coin: coinName, shareType } = req.params;
71+
const { source, pub, coin, encryptedDataKey, shareType } = req.decoded;
7372

7473
if (!source || !pub) {
7574
throw new Error('Source and public key are required for MPC signing');
@@ -80,7 +79,7 @@ export async function signMpcTransaction(req: EnclavedApiSpecRouteRequest<'v1.mp
8079
}
8180

8281
const bitgo = req.bitgo;
83-
const coin = bitgo.coin(coinName);
82+
const coinInstance = bitgo.coin(coin);
8483

8584
// Get private key from KMS
8685
const prv = await retrieveKmsPrvKey({ pub, source, cfg: req.config });
@@ -92,11 +91,11 @@ export async function signMpcTransaction(req: EnclavedApiSpecRouteRequest<'v1.mp
9291
}
9392

9493
try {
95-
const mpcAlgorithm = coin.getMPCAlgorithm?.() || MPCType.ECDSA; // Default to ECDSA if method doesn't exist
94+
const mpcAlgorithm = coinInstance.getMPCAlgorithm?.() || MPCType.ECDSA; // Default to ECDSA if method doesn't exist
9695

9796
if (mpcAlgorithm === MPCType.EDDSA) {
9897
return await handleEddsaSigning(req.bitgo, req.config, {
99-
coin,
98+
coin: coinInstance,
10099
shareType,
101100
txRequest: req.decoded.txRequest,
102101
prv,

src/enclavedBitgoExpress/routers/enclavedApiSpec.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,24 @@ const SignMpcRequest = {
9696

9797
// Response type for /mpc/sign endpoint
9898
const SignMpcResponse: HttpResponse = {
99-
// TODO: Define proper response type for MPC transaction signing
100-
200: t.any,
99+
// Response type for MPC transaction signing
100+
200: t.union([
101+
// Commitment share response
102+
t.type({
103+
userToBitgoCommitment: t.any,
104+
encryptedSignerShare: t.any,
105+
encryptedUserToBitgoRShare: t.any,
106+
encryptedDataKey: t.string,
107+
}),
108+
// R share response
109+
t.type({
110+
rShare: t.any,
111+
}),
112+
// G share response
113+
t.type({
114+
gShare: t.any,
115+
}),
116+
]),
101117
500: t.type({
102118
error: t.string,
103119
details: t.string,

0 commit comments

Comments
 (0)