@@ -58,7 +58,6 @@ type KeyShare = ECDSA.KeyShare;
5858openpgp . config . rejectCurves = new Set ( ) ;
5959
6060describe ( 'TSS Ecdsa Utils:' , async function ( ) {
61- const isThirdPartyBackup = false ;
6261 const coinName = 'hteth' ;
6362 const reqId = new RequestTracer ( ) ;
6463 const walletId = '5b34252f1bf349930e34020a00000000' ;
@@ -76,17 +75,13 @@ describe('TSS Ecdsa Utils:', async function () {
7675 let userKeyShare : KeyShare ;
7776 let backupKeyShare : KeyShare ;
7877 let bitgoPublicKey : openpgp . Key ;
79- let thirdPartyBackupPublicGpgKey : openpgp . Key ;
8078
8179 let userGpgKey : openpgp . SerializedKeyPair < string > & {
8280 revocationCertificate : string ;
8381 } ;
8482 let userLocalBackupGpgKey : openpgp . SerializedKeyPair < string > & {
8583 revocationCertificate : string ;
8684 } ;
87- let thirdPartyBackupGpgKeyPair : openpgp . SerializedKeyPair < string > & {
88- revocationCertificate : string ;
89- } ;
9085 let bitGoGPGKeyPair : openpgp . SerializedKeyPair < string > & {
9186 revocationCertificate : string ;
9287 } ;
@@ -127,15 +122,6 @@ describe('TSS Ecdsa Utils:', async function () {
127122 ] ,
128123 curve : 'secp256k1' ,
129124 } ) ,
130- openpgp . generateKey ( {
131- userIDs : [
132- {
133- name : 'thirdPartyBackup' ,
134- 135- } ,
136- ] ,
137- curve : 'secp256k1' ,
138- } ) ,
139125 openpgp . generateKey ( {
140126 userIDs : [
141127 {
@@ -146,10 +132,7 @@ describe('TSS Ecdsa Utils:', async function () {
146132 curve : 'secp256k1' ,
147133 } ) ,
148134 ] ;
149- [ userGpgKey , userLocalBackupGpgKey , thirdPartyBackupGpgKeyPair , bitGoGPGKeyPair ] = await Promise . all (
150- gpgKeyPromises
151- ) ;
152- thirdPartyBackupPublicGpgKey = await openpgp . readKey ( { armoredKey : thirdPartyBackupGpgKeyPair . publicKey } ) ;
135+ [ userGpgKey , userLocalBackupGpgKey , bitGoGPGKeyPair ] = await Promise . all ( gpgKeyPromises ) ;
153136 bitgoPublicKey = await openpgp . readKey ( { armoredKey : bitGoGPGKeyPair . publicKey } ) ;
154137 const constants = {
155138 mpc : {
@@ -238,38 +221,10 @@ describe('TSS Ecdsa Utils:', async function () {
238221 result . should . eql ( expectedFinalKeyShare ) ;
239222 } ) ;
240223
241- it ( 'should create a user keychain from third party backup provider' , async function ( ) {
242- const backupKeyShares = await createIncompleteBitgoHeldBackupKeyShare (
243- userGpgKey ,
244- backupKeyShare ,
245- bitGoGPGKeyPair
246- ) ;
247- const backupShareHolder : BackupKeyShare = {
248- bitGoHeldKeyShares : backupKeyShares ,
249- } ;
250- assert ( backupShareHolder . bitGoHeldKeyShares ) ;
251- const userKeychain = await tssUtils . createUserKeychainFromThirdPartyBackup (
252- userGpgKey ,
253- bitgoPublicKey ,
254- thirdPartyBackupPublicGpgKey ,
255- userKeyShare ,
256- backupShareHolder . bitGoHeldKeyShares ?. keyShares ,
257- nockedBitGoKeychain ,
258- 'password' ,
259- '1234'
260- ) ;
261- userKeychain . should . deepEqual ( nockedUserKeychain ) ;
262- } ) ;
263-
264224 it ( 'should get the respective backup key shares based on provider' , async function ( ) {
265225 const enterpriseId = 'enterprise id' ;
266226 await nockCreateBitgoHeldBackupKeyShare ( coinName , enterpriseId , userGpgKey , backupKeyShare , bitGoGPGKeyPair ) ;
267- let backupKeyShares = await tssUtils . createBackupKeyShares ( true , userGpgKey , enterpriseId ) ;
268- should . exist ( backupKeyShares . bitGoHeldKeyShares ) ;
269- should . not . exist ( backupKeyShares . userHeldKeyShare ) ;
270-
271- await nockCreateBitgoHeldBackupKeyShare ( coinName , enterpriseId , userGpgKey , backupKeyShare , bitGoGPGKeyPair ) ;
272- backupKeyShares = await tssUtils . createBackupKeyShares ( false , userGpgKey , enterpriseId ) ;
227+ const backupKeyShares = await tssUtils . createBackupKeyShares ( ) ;
273228 should . exist ( backupKeyShares . userHeldKeyShare ) ;
274229 should . not . exist ( backupKeyShares . bitGoHeldKeyShares ) ;
275230 } ) ;
@@ -289,39 +244,16 @@ describe('TSS Ecdsa Utils:', async function () {
289244 } ) ;
290245
291246 it ( 'getBackupEncryptedNShare should get valid encrypted n shares based on provider' , async function ( ) {
292- // Backup key held by third party
293- const bitgoHeldBackupKeyShare = await createIncompleteBitgoHeldBackupKeyShare (
294- userGpgKey ,
295- backupKeyShare ,
296- bitGoGPGKeyPair
297- ) ;
298- const backupShareHolder : BackupKeyShare = {
299- bitGoHeldKeyShares : bitgoHeldBackupKeyShare ,
300- } ;
301- const backupToBitgoShare = bitgoHeldBackupKeyShare . keyShares . find (
302- ( keyShare ) => keyShare . from === 'backup' && keyShare . to === 'bitgo'
303- ) ;
304247 const bitgoGpgKeyPubKey = await tssUtils . getBitgoPublicGpgKey ( ) ;
305- let backupToBitgoEncryptedNShare = await tssUtils . getBackupEncryptedNShare (
306- backupShareHolder ,
307- 3 ,
308- bitgoGpgKeyPubKey . armor ( ) ,
309- userGpgKey ,
310- true
311- ) ;
312- should . exist ( backupToBitgoEncryptedNShare ) ;
313- should . equal ( backupToBitgoEncryptedNShare . encryptedPrivateShare , backupToBitgoShare ?. privateShare ) ;
314-
315248 // Backup key held by user
316249 const backupShareHolderNew : BackupKeyShare = {
317250 userHeldKeyShare : backupKeyShare ,
318251 } ;
319- backupToBitgoEncryptedNShare = await tssUtils . getBackupEncryptedNShare (
252+ const backupToBitgoEncryptedNShare = await tssUtils . getBackupEncryptedNShare (
320253 backupShareHolderNew ,
321254 3 ,
322255 bitgoGpgKeyPubKey . armor ( ) ,
323- userGpgKey ,
324- false
256+ userGpgKey
325257 ) ;
326258 const encryptedNShare = await encryptNShare ( backupKeyShare , 3 , bitgoGpgKeyPubKey . armor ( ) , userGpgKey ) ;
327259 // cant verify the encrypted shares, since they will be encrypted with diff. values
@@ -332,14 +264,13 @@ describe('TSS Ecdsa Utils:', async function () {
332264 const backupShareHolder : BackupKeyShare = {
333265 userHeldKeyShare : backupKeyShare ,
334266 } ;
335- const backupGpgKey : BackupGpgKey = isThirdPartyBackup ? thirdPartyBackupPublicGpgKey : userLocalBackupGpgKey ;
267+ const backupGpgKey : BackupGpgKey = userLocalBackupGpgKey ;
336268 const bitgoKeychain = await tssUtils . createBitgoKeychain ( {
337269 userGpgKey,
338270 backupGpgKey,
339271 userKeyShare,
340272 backupKeyShare : backupShareHolder ,
341273 bitgoPublicGpgKey : bitgoPublicKey ,
342- isThirdPartyBackup,
343274 } ) ;
344275 const usersKeyChainPromises = [
345276 tssUtils . createParticipantKeychain (
@@ -376,112 +307,12 @@ describe('TSS Ecdsa Utils:', async function () {
376307 should . exist ( backupKeychain . encryptedPrv ) ;
377308 } ) ;
378309
379- it ( 'should generate TSS key chains when backup provider is BitGo' , async function ( ) {
380- const backupProvider = 'BitGoTrustAsKrs' ;
381-
382- const nitroGPGKeypair = await openpgp . generateKey ( {
383- userIDs : [
384- {
385- name : 'bitgo nitro' ,
386- 387- } ,
388- ] ,
389- } ) ;
390-
391- await nockGetBitgoPublicKeyBasedOnFeatureFlags ( coinName , 'enterprise_id' , nitroGPGKeypair ) ;
392- const bitgoGpgPublicKey = await tssUtils . getBitgoGpgPubkeyBasedOnFeatureFlags ( 'enterprise_id' ) ;
393-
394- const isThirdPartyBackup = tssUtils . isValidThirdPartyBackupProvider ( 'BitGoTrustAsKrs' ) ;
395- const bitgoHeldBackupShares = await createIncompleteBitgoHeldBackupKeyShare (
396- userGpgKey ,
397- backupKeyShare ,
398- nitroGPGKeypair
399- ) ;
400- const backupShareHolder : BackupKeyShare = {
401- bitGoHeldKeyShares : bitgoHeldBackupShares ,
402- } ;
403- const backupGpgKey : BackupGpgKey = isThirdPartyBackup ? thirdPartyBackupPublicGpgKey : userLocalBackupGpgKey ;
404-
405- const bitgoKeychain = await tssUtils . createBitgoKeychain ( {
406- userGpgKey,
407- backupGpgKey,
408- userKeyShare,
409- backupKeyShare : backupShareHolder ,
410- enterprise : undefined ,
411- isThirdPartyBackup,
412- bitgoPublicGpgKey : bitgoGpgPublicKey ,
413- } ) ;
414- assert ( bitgoKeychain . commonKeychain ) ;
415-
416- await nockFinalizeBitgoHeldBackupKeyShare (
417- coinName ,
418- bitgoHeldBackupShares ,
419- bitgoKeychain . commonKeychain ,
420- userKeyShare ,
421- nitroGPGKeypair ,
422- bitgoKeychain
423- ) ;
424-
425- const userBackupKeyChainPromises = [
426- tssUtils . createUserKeychain ( {
427- userGpgKey,
428- backupGpgKey,
429- userKeyShare,
430- backupKeyShare : backupShareHolder ,
431- bitgoKeychain,
432- passphrase : 'passphrase' ,
433- enterprise : undefined ,
434- isThirdPartyBackup,
435- bitgoPublicGpgKey : bitgoGpgPublicKey ,
436- } ) ,
437- tssUtils . createBackupKeychain ( {
438- userGpgKey,
439- backupGpgKey,
440- userKeyShare,
441- backupKeyShare : backupShareHolder ,
442- bitgoKeychain,
443- enterprise : undefined ,
444- bitgoPublicGpgKey : bitgoGpgPublicKey ,
445- backupProvider,
446- } ) ,
447- ] ;
448- const [ userKeychain , backupKeychain ] = await Promise . all ( userBackupKeyChainPromises ) ;
449-
450- bitgoKeychain . should . deepEqual ( nockedBitGoKeychain ) ;
451- userKeychain . should . deepEqual ( nockedUserKeychain ) ;
452- backupKeychain . id . should . equal ( '2' ) ;
453- backupKeychain . provider ?. should . equal ( backupProvider ) ;
454-
455- // verify that all four key shares are included on the response of the backup keychain
456- assert ( backupKeychain . keyShares ) ;
457- backupKeychain . keyShares . length . should . equal ( 4 ) ;
458- for ( const keyShare of bitgoHeldBackupShares . keyShares ) {
459- backupKeychain . keyShares . should . matchAny ( keyShare ) ;
460- }
461- const bitgoToBackupShare = bitgoKeychain . keyShares ?. find (
462- ( keyShare ) => keyShare . from === 'bitgo' && keyShare . to === 'backup'
463- ) ;
464- assert ( bitgoToBackupShare ) ;
465- backupKeychain . keyShares . should . matchAny ( bitgoToBackupShare ) ;
466-
467- const userToBackupShare = backupKeychain . keyShares . find (
468- ( keyShare ) => keyShare . from === 'user' && keyShare . to === 'backup'
469- ) ;
470- assert ( userToBackupShare ) ;
471- userToBackupShare . publicShare . should . equal (
472- Buffer . concat ( [
473- Buffer . from ( userKeyShare . nShares [ 2 ] . y , 'hex' ) ,
474- Buffer . from ( userKeyShare . nShares [ 2 ] . chaincode , 'hex' ) ,
475- ] ) . toString ( 'hex' )
476- ) ;
477- } ) ;
478-
479310 it ( 'should generate TSS key chains with optional params' , async function ( ) {
480311 const enterprise = 'enterprise_id' ;
481312 const backupShareHolder : BackupKeyShare = {
482313 userHeldKeyShare : backupKeyShare ,
483314 } ;
484- const backupGpgKey : BackupGpgKey = isThirdPartyBackup ? thirdPartyBackupPublicGpgKey : userLocalBackupGpgKey ;
315+ const backupGpgKey : BackupGpgKey = userLocalBackupGpgKey ;
485316 const bitgoKeychain = await tssUtils . createBitgoKeychain ( {
486317 userGpgKey,
487318 backupGpgKey,
@@ -530,7 +361,7 @@ describe('TSS Ecdsa Utils:', async function () {
530361 const backupShareHolder : BackupKeyShare = {
531362 userHeldKeyShare : backupKeyShare ,
532363 } ;
533- const backupGpgKey : BackupGpgKey = isThirdPartyBackup ? thirdPartyBackupPublicGpgKey : userLocalBackupGpgKey ;
364+ const backupGpgKey : BackupGpgKey = userLocalBackupGpgKey ;
534365 const bitgoKeychain = await tssUtils . createBitgoKeychain ( {
535366 userGpgKey,
536367 backupGpgKey,
@@ -624,7 +455,7 @@ describe('TSS Ecdsa Utils:', async function () {
624455 const backupShareHolder : BackupKeyShare = {
625456 userHeldKeyShare : customBackupKeyShare ,
626457 } ;
627- const backupGpgKey : BackupGpgKey = isThirdPartyBackup ? thirdPartyBackupPublicGpgKey : userLocalBackupGpgKey ;
458+ const backupGpgKey : BackupGpgKey = userLocalBackupGpgKey ;
628459
629460 const bitgoKeychain = await tssUtils . createBitgoKeychain ( {
630461 userGpgKey,
@@ -1599,7 +1430,7 @@ describe('TSS Ecdsa Utils:', async function () {
15991430 openSSLBytes ,
16001431 deserializedEntChallenge
16011432 ) . should . not . be . rejected ( ) ;
1602- stubUploadChallenge . should . be . calledWith (
1433+ stubUploadChallenge . calledWith (
16031434 bitgo ,
16041435 'ent_id' ,
16051436 serializedEntChallenge ,
@@ -1638,7 +1469,7 @@ describe('TSS Ecdsa Utils:', async function () {
16381469 signedNitroChallenge ,
16391470 openSSLBytes
16401471 ) . should . not . be . rejected ( ) ;
1641- stubUploadChallenge . should . be . calledWith (
1472+ stubUploadChallenge . calledWith (
16421473 bitgo ,
16431474 'ent_id' ,
16441475 serializedEntChallenge ,
0 commit comments