From 89cca604106d66916ae4797f193400a965443349 Mon Sep 17 00:00:00 2001 From: Mohammad Al Faiyaz Date: Mon, 16 Sep 2024 11:03:36 -0400 Subject: [PATCH] chore: refactor dkg initialization to seperately between user and backup Ticket: WP-2292 TICKET: WP-2292 --- .../src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts b/modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts index 195bf0dd7e..c2a69553bd 100644 --- a/modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts +++ b/modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts @@ -387,6 +387,31 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils { return { ...(await keychains.add(recipientKeychainParams)), reducedEncryptedPrv: reducedEncryptedPrv }; } + /** + * Converts a User or Backup MPCv1 SigningMaterial to RetrofitData needed by MPCv2 DKG. + * + * @param decryptedKeyshare - MPCv1 decrypted signing material for user or backup as a json.stringify string and bitgo's Big Si. + * @param partyId - The party ID of the MPCv1 keyshare. + * @returns The retrofit data needed to start an MPCv2 DKG session. + */ + getKeyDataForRetrofit( + decryptedKeyshare: string, + partyId: MPCv2PartiesEnum.BACKUP | MPCv2PartiesEnum.USER + ): DklsTypes.RetrofitData { + const mpc = new Ecdsa(); + const xiList = [ + Array.from(bigIntToBufferBE(BigInt(1), 32)), + Array.from(bigIntToBufferBE(BigInt(2), 32)), + Array.from(bigIntToBufferBE(BigInt(3), 32)), + ]; + return this.getMpcV2RetrofitDataFromMpcV1Key({ + mpcv1PartyKeyShare: decryptedKeyshare, + mpcv1PartyIndex: partyId === MPCv2PartiesEnum.USER ? 1 : 2, + xiList, + mpc, + }); + } + /** * Converts user and backup MPCv1 SigningMaterial to RetrofitData needed by MPCv2 DKG. *