@@ -32,6 +32,7 @@ import {
3232 verifyPeerMessageRoundOne ,
3333 verifyPeerMessageRoundTwo ,
3434} from '../../../../../../src/bitgo/tss/eddsa/eddsaMPCv2' ;
35+ import { getBitgoSignatureShare } from '../../../../../../src/bitgo/tss/common' ;
3536import { decodeWithCodec } from '../../../../../../src/bitgo/utils/codecs' ;
3637import { generateGPGKeyPair } from '../../../../../../src/bitgo/utils/opengpgUtils' ;
3738import { MPCv2PartiesEnum } from '../../../../../../src/bitgo/utils/tss/ecdsa/typesMPCv2' ;
@@ -815,7 +816,7 @@ describe('EddsaMPCv2Utils.createOfflineRound2Share', () => {
815816 encryptedUserGpgPrvKey : round1 . encryptedUserGpgPrvKey ,
816817 encryptedRound1Session : round1 . encryptedRound1Session ,
817818 } ) ,
818- / M i s s i n g B i t G o s i g n a t u r e s h a r e /
819+ / M i s s i n g B i t G o r o u n d 1 O u t p u t s i g n a t u r e s h a r e /
819820 ) ;
820821 } ) ;
821822
@@ -1144,7 +1145,7 @@ describe('EddsaMPCv2Utils.createOfflineRound3Share', () => {
11441145 encryptedUserGpgPrvKey : round1 . encryptedUserGpgPrvKey ,
11451146 encryptedRound2Session : round2 . encryptedRound2Session ,
11461147 } ) ,
1147- / M i s s i n g B i t G o r o u n d 2 s i g n a t u r e s h a r e /
1148+ / M i s s i n g B i t G o r o u n d 2 O u t p u t s i g n a t u r e s h a r e /
11481149 ) ;
11491150 } ) ;
11501151
@@ -1181,6 +1182,45 @@ describe('EddsaMPCv2Utils.createOfflineRound3Share', () => {
11811182 } ) ;
11821183} ) ;
11831184
1185+ describe ( 'getBitgoSignatureShare' , ( ) => {
1186+ const round1OutputShare : SignatureShareRecord = {
1187+ from : SignatureShareType . BITGO ,
1188+ to : SignatureShareType . USER ,
1189+ share : JSON . stringify ( { type : 'round1Output' , data : { } } ) ,
1190+ } ;
1191+ const round2OutputShare : SignatureShareRecord = {
1192+ from : SignatureShareType . BITGO ,
1193+ to : SignatureShareType . USER ,
1194+ share : JSON . stringify ( { type : 'round2Output' , data : { } } ) ,
1195+ } ;
1196+
1197+ it ( 'selects the requested BitGo round output when multiple round outputs are present' , ( ) => {
1198+ const signatureShares = [ round1OutputShare , round2OutputShare ] ;
1199+
1200+ assert . strictEqual (
1201+ getBitgoSignatureShare ( signatureShares , SignatureShareType . USER , 'round2Output' ) ,
1202+ round2OutputShare
1203+ ) ;
1204+ assert . strictEqual (
1205+ getBitgoSignatureShare ( signatureShares , SignatureShareType . USER , 'round1Output' ) ,
1206+ round1OutputShare
1207+ ) ;
1208+ } ) ;
1209+
1210+ it ( 'skips malformed share records while selecting the requested BitGo round output' , ( ) => {
1211+ const malformedShare : SignatureShareRecord = {
1212+ from : SignatureShareType . BITGO ,
1213+ to : SignatureShareType . USER ,
1214+ share : 'not-json' ,
1215+ } ;
1216+
1217+ assert . strictEqual (
1218+ getBitgoSignatureShare ( [ malformedShare , round2OutputShare ] , SignatureShareType . USER , 'round2Output' ) ,
1219+ round2OutputShare
1220+ ) ;
1221+ } ) ;
1222+ } ) ;
1223+
11841224type TxRequestTransaction = NonNullable < TxRequest [ 'transactions' ] > [ number ] ;
11851225
11861226function assertSingleTransaction ( txRequest : TxRequest ) : TxRequestTransaction {
0 commit comments