@@ -130,12 +130,9 @@ interface SignMpcGShareResponse {
130130// ECDSA MPCv2 interfaces
131131interface SignMpcV2Round1Params {
132132 txRequest : TxRequest ;
133- bitgoGpgPubKey : string ;
134- source : 'user' | 'backup' ;
135- pub : string ;
136133}
137134
138- interface SignMpcV2Round1Response {
135+ export interface SignMpcV2Round1Response {
139136 signatureShareRound1 : SignatureShareRecord ;
140137 userGpgPubKey : string ;
141138 encryptedRound1Session : string ;
@@ -145,30 +142,28 @@ interface SignMpcV2Round1Response {
145142
146143interface SignMpcV2Round2Params {
147144 txRequest : TxRequest ;
148- bitgoGpgPubKey : string ;
149- encryptedDataKey : string ;
150145 encryptedUserGpgPrvKey : string ;
151146 encryptedRound1Session : string ;
152- source : 'user' | 'backup' ;
153- pub : string ;
147+ encryptedDataKey : string ;
148+ bitgoPublicGpgKey : string ;
149+ bitgoGpgPubKey : string ;
154150}
155151
156- interface SignMpcV2Round2Response {
152+ export interface SignMpcV2Round2Response {
157153 signatureShareRound2 : SignatureShareRecord ;
158154 encryptedRound2Session : string ;
159155}
160156
161157interface SignMpcV2Round3Params {
162158 txRequest : TxRequest ;
163- bitgoGpgPubKey : string ;
164- encryptedDataKey : string ;
165159 encryptedUserGpgPrvKey : string ;
166160 encryptedRound2Session : string ;
167- source : 'user' | 'backup' ;
168- pub : string ;
161+ encryptedDataKey : string ;
162+ bitgoPublicGpgKey : string ;
163+ bitgoGpgPubKey : string ;
169164}
170165
171- interface SignMpcV2Round3Response {
166+ export interface SignMpcV2Round3Response {
172167 signatureShareRound3 : SignatureShareRecord ;
173168}
174169
@@ -606,20 +601,30 @@ export class EnclavedExpressClient {
606601 }
607602 }
608603
609- async signMpcV2Round1 ( params : SignMpcV2Round1Params ) : Promise < SignMpcV2Round1Response > {
610- if ( ! this . coin ) {
604+ /**
605+ * Create custom MPCv2 Round 1 signing function for enclaved express client
606+ */
607+ export function createCustomMPCv2SigningRound1Generator (
608+ enclavedExpressClient : EnclavedExpressClient ,
609+ source : 'user' | 'backup' ,
610+ pub : string ,
611+ ) : ( params : SignMpcV2Round1Params ) => Promise < SignMpcV2Round1Response > {
612+ return async function ( params ) : Promise < SignMpcV2Round1Response > {
613+ if ( ! enclavedExpressClient [ 'coin' ] ) {
611614 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 1' ) ;
612615 }
613616
614617 try {
615- let request = this . apiClient [ 'v1.mpc.sign' ] . post ( {
616- coin : this . coin ,
618+ let request = enclavedExpressClient [ ' apiClient' ] [ 'v1.mpc.sign' ] . post ( {
619+ coin : enclavedExpressClient [ ' coin' ] ,
617620 shareType : 'mpcv2round1' ,
618621 ...params ,
622+ source,
623+ pub,
619624 } ) ;
620625
621- if ( this . tlsMode === TlsMode . MTLS ) {
622- request = request . agent ( this . createHttpsAgent ( ) ) ;
626+ if ( enclavedExpressClient [ ' tlsMode' ] === TlsMode . MTLS ) {
627+ request = request . agent ( enclavedExpressClient [ ' createHttpsAgent' ] ( ) ) ;
623628 }
624629 const response = await request . decodeExpecting ( 200 ) ;
625630 return response . body ;
@@ -628,22 +633,33 @@ export class EnclavedExpressClient {
628633 debugLogger ( 'Failed to sign mpcv2 round 1: %s' , err . message ) ;
629634 throw err ;
630635 }
631- }
636+ } ;
637+ }
632638
633- async signMpcV2Round2 ( params : SignMpcV2Round2Params ) : Promise < SignMpcV2Round2Response > {
634- if ( ! this . coin ) {
639+ /**
640+ * Create custom MPCv2 Round 2 signing function for enclaved express client
641+ */
642+ export function createCustomMPCv2SigningRound2Generator (
643+ enclavedExpressClient : EnclavedExpressClient ,
644+ source : 'user' | 'backup' ,
645+ pub : string ,
646+ ) : ( params : SignMpcV2Round2Params ) => Promise < SignMpcV2Round2Response > {
647+ return async function ( params ) : Promise < SignMpcV2Round2Response > {
648+ if ( ! enclavedExpressClient [ 'coin' ] ) {
635649 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 2' ) ;
636650 }
637651
638652 try {
639- let request = this . apiClient [ 'v1.mpc.sign' ] . post ( {
640- coin : this . coin ,
653+ let request = enclavedExpressClient [ ' apiClient' ] [ 'v1.mpc.sign' ] . post ( {
654+ coin : enclavedExpressClient [ ' coin' ] ,
641655 shareType : 'mpcv2round2' ,
642656 ...params ,
657+ source,
658+ pub,
643659 } ) ;
644660
645- if ( this . tlsMode === TlsMode . MTLS ) {
646- request = request . agent ( this . createHttpsAgent ( ) ) ;
661+ if ( enclavedExpressClient [ ' tlsMode' ] === TlsMode . MTLS ) {
662+ request = request . agent ( enclavedExpressClient [ ' createHttpsAgent' ] ( ) ) ;
647663 }
648664 const response = await request . decodeExpecting ( 200 ) ;
649665 return response . body ;
@@ -652,22 +668,33 @@ export class EnclavedExpressClient {
652668 debugLogger ( 'Failed to sign mpcv2 round 2: %s' , err . message ) ;
653669 throw err ;
654670 }
655- }
671+ } ;
672+ }
656673
657- async signMpcV2Round3 ( params : SignMpcV2Round3Params ) : Promise < SignMpcV2Round3Response > {
658- if ( ! this . coin ) {
674+ /**
675+ * Create custom MPCv2 Round 3 signing function for enclaved express client
676+ */
677+ export function createCustomMPCv2SigningRound3Generator (
678+ enclavedExpressClient : EnclavedExpressClient ,
679+ source : 'user' | 'backup' ,
680+ pub : string ,
681+ ) : ( params : SignMpcV2Round3Params ) => Promise < SignMpcV2Round3Response > {
682+ return async function ( params ) : Promise < SignMpcV2Round3Response > {
683+ if ( ! enclavedExpressClient [ 'coin' ] ) {
659684 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 3' ) ;
660685 }
661686
662687 try {
663- let request = this . apiClient [ 'v1.mpc.sign' ] . post ( {
664- coin : this . coin ,
688+ let request = enclavedExpressClient [ ' apiClient' ] [ 'v1.mpc.sign' ] . post ( {
689+ coin : enclavedExpressClient [ ' coin' ] ,
665690 shareType : 'mpcv2round3' ,
666691 ...params ,
692+ source,
693+ pub,
667694 } ) ;
668695
669- if ( this . tlsMode === TlsMode . MTLS ) {
670- request = request . agent ( this . createHttpsAgent ( ) ) ;
696+ if ( enclavedExpressClient [ ' tlsMode' ] === TlsMode . MTLS ) {
697+ request = request . agent ( enclavedExpressClient [ ' createHttpsAgent' ] ( ) ) ;
671698 }
672699 const response = await request . decodeExpecting ( 200 ) ;
673700 return response . body ;
@@ -676,7 +703,7 @@ export class EnclavedExpressClient {
676703 debugLogger ( 'Failed to sign mpcv2 round 3: %s' , err . message ) ;
677704 throw err ;
678705 }
679- }
706+ } ;
680707}
681708
682709/**
0 commit comments