Skip to content

Commit ae2780b

Browse files
Support Botbitgobot
authored andcommitted
feat(dkg): add EdDSA MPCv2 keygen API spec entries and route stubs to AWM
Add io-ts request/response types and three new route entries to AdvancedWalletManagerApiSpec for the EdDSA MPCv2 DKG protocol: - POST /api/{coin}/eddsampcv2/keygen/initialize - POST /api/{coin}/eddsampcv2/keygen/round1 - POST /api/{coin}/eddsampcv2/keygen/finalize Each route is wired in createKeyGenRouter with a NotImplementedError stub; the real handlers land in WCI-892. The type exports (EddsaMPCv2KeyGenInitialize/Round1/FinalizeRequestType and ResponseType) are needed by the ME client added in the next PR. Ticket: WCI-895 Session-Id: 4df43c40-1cea-4bcc-ae92-080304169427 Task-Id: 04666b37-650f-4c07-97b0-76a62e98f1ad
1 parent 95a2371 commit ae2780b

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

src/advancedWalletManager/routers/advancedWalletManagerApiSpec.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,73 @@ const MpcV2RecoveryResponse = {
310310
const MpcV2RecoveryResponseType = t.type(MpcV2RecoveryResponse);
311311
export type MpcV2RecoveryResponseType = t.TypeOf<typeof MpcV2RecoveryResponseType>;
312312

313+
// EdDSA MPCv2 key generation types
314+
const EddsaMPCv2KeyGenSignedMessage = t.type({
315+
message: t.string,
316+
signature: t.string,
317+
});
318+
319+
const EddsaMPCv2KeyGenInitializeRequest = {
320+
source: t.union([t.literal('user'), t.literal('backup')]),
321+
enterprise: t.string,
322+
bitgoPublicGpgKey: t.string,
323+
};
324+
const EddsaMPCv2KeyGenInitializeRequestType = t.type(EddsaMPCv2KeyGenInitializeRequest);
325+
export type EddsaMPCv2KeyGenInitializeRequestType = t.TypeOf<
326+
typeof EddsaMPCv2KeyGenInitializeRequestType
327+
>;
328+
329+
const EddsaMPCv2KeyGenInitializeResponse = {
330+
gpgPublicKey: t.string,
331+
signedMsg1: EddsaMPCv2KeyGenSignedMessage,
332+
encryptedState: t.string,
333+
encryptedStateKey: t.string,
334+
};
335+
const EddsaMPCv2KeyGenInitializeResponseType = t.type(EddsaMPCv2KeyGenInitializeResponse);
336+
export type EddsaMPCv2KeyGenInitializeResponseType = t.TypeOf<
337+
typeof EddsaMPCv2KeyGenInitializeResponseType
338+
>;
339+
340+
const EddsaMPCv2KeyGenRound1Request = {
341+
source: t.union([t.literal('user'), t.literal('backup')]),
342+
bitgoMsg1: EddsaMPCv2KeyGenSignedMessage,
343+
encryptedState: t.string,
344+
encryptedStateKey: t.string,
345+
};
346+
const EddsaMPCv2KeyGenRound1RequestType = t.type(EddsaMPCv2KeyGenRound1Request);
347+
export type EddsaMPCv2KeyGenRound1RequestType = t.TypeOf<typeof EddsaMPCv2KeyGenRound1RequestType>;
348+
349+
const EddsaMPCv2KeyGenRound1Response = {
350+
signedMsg2: EddsaMPCv2KeyGenSignedMessage,
351+
encryptedState: t.string,
352+
encryptedStateKey: t.string,
353+
};
354+
const EddsaMPCv2KeyGenRound1ResponseType = t.type(EddsaMPCv2KeyGenRound1Response);
355+
export type EddsaMPCv2KeyGenRound1ResponseType = t.TypeOf<
356+
typeof EddsaMPCv2KeyGenRound1ResponseType
357+
>;
358+
359+
const EddsaMPCv2KeyGenFinalizeRequest = {
360+
source: t.union([t.literal('user'), t.literal('backup')]),
361+
bitgoMsg2: EddsaMPCv2KeyGenSignedMessage,
362+
commonPublicKeychain: t.string,
363+
encryptedState: t.string,
364+
encryptedStateKey: t.string,
365+
};
366+
const EddsaMPCv2KeyGenFinalizeRequestType = t.type(EddsaMPCv2KeyGenFinalizeRequest);
367+
export type EddsaMPCv2KeyGenFinalizeRequestType = t.TypeOf<
368+
typeof EddsaMPCv2KeyGenFinalizeRequestType
369+
>;
370+
371+
const EddsaMPCv2KeyGenFinalizeResponse = {
372+
source: t.union([t.literal('user'), t.literal('backup')]),
373+
commonKeychain: t.string,
374+
};
375+
const EddsaMPCv2KeyGenFinalizeResponseType = t.type(EddsaMPCv2KeyGenFinalizeResponse);
376+
export type EddsaMPCv2KeyGenFinalizeResponseType = t.TypeOf<
377+
typeof EddsaMPCv2KeyGenFinalizeResponseType
378+
>;
379+
313380
// API Specification
314381
export const AdvancedWalletManagerApiSpec = apiSpec({
315382
'v1.multisig.sign': {
@@ -481,6 +548,51 @@ export const AdvancedWalletManagerApiSpec = apiSpec({
481548
description: 'Recover a MPC transaction',
482549
}),
483550
},
551+
'v1.eddsampcv2.keygen.initialize': {
552+
post: httpRoute({
553+
method: 'POST',
554+
path: '/api/{coin}/eddsampcv2/keygen/initialize',
555+
request: httpRequest({
556+
params: { coin: t.string },
557+
body: EddsaMPCv2KeyGenInitializeRequest,
558+
}),
559+
response: {
560+
200: EddsaMPCv2KeyGenInitializeResponseType,
561+
...ErrorResponses,
562+
},
563+
description: 'Initialize EdDSA MPCv2 key generation',
564+
}),
565+
},
566+
'v1.eddsampcv2.keygen.round1': {
567+
post: httpRoute({
568+
method: 'POST',
569+
path: '/api/{coin}/eddsampcv2/keygen/round1',
570+
request: httpRequest({
571+
params: { coin: t.string },
572+
body: EddsaMPCv2KeyGenRound1Request,
573+
}),
574+
response: {
575+
200: EddsaMPCv2KeyGenRound1ResponseType,
576+
...ErrorResponses,
577+
},
578+
description: 'EdDSA MPCv2 key generation round 1',
579+
}),
580+
},
581+
'v1.eddsampcv2.keygen.finalize': {
582+
post: httpRoute({
583+
method: 'POST',
584+
path: '/api/{coin}/eddsampcv2/keygen/finalize',
585+
request: httpRequest({
586+
params: { coin: t.string },
587+
body: EddsaMPCv2KeyGenFinalizeRequest,
588+
}),
589+
response: {
590+
200: EddsaMPCv2KeyGenFinalizeResponseType,
591+
...ErrorResponses,
592+
},
593+
description: 'Finalize EdDSA MPCv2 key generation',
594+
}),
595+
},
484596
});
485597

486598
export type AkmApiSpecRouteHandler<
@@ -613,5 +725,23 @@ export function createKeyGenRouter(
613725
}),
614726
]);
615727

728+
router.post('v1.eddsampcv2.keygen.initialize', [
729+
responseHandler<AdvancedWalletManagerConfig>(async (_req) => {
730+
throw new NotImplementedError('EdDSA MPCv2 key generation initialize not implemented');
731+
}),
732+
]);
733+
734+
router.post('v1.eddsampcv2.keygen.round1', [
735+
responseHandler<AdvancedWalletManagerConfig>(async (_req) => {
736+
throw new NotImplementedError('EdDSA MPCv2 key generation round1 not implemented');
737+
}),
738+
]);
739+
740+
router.post('v1.eddsampcv2.keygen.finalize', [
741+
responseHandler<AdvancedWalletManagerConfig>(async (_req) => {
742+
throw new NotImplementedError('EdDSA MPCv2 key generation finalize not implemented');
743+
}),
744+
]);
745+
616746
return router;
617747
}

0 commit comments

Comments
 (0)