Skip to content

Commit a95ffdb

Browse files
Support Botbitgobot
authored andcommitted
fix(sdk-core): fix lint errors and await DKG restoreSession in tests
Fix prettier formatting in createOfflineKeyGenRound2Share (multi-line decrypt call) and in test helper (function signature and initDkg args). Remove unused variables from buildCounterPartyAndBitgoMsgs test helper. Update sdk-lib-mpc DKG session management test to await restoreSession, which is now async after the fix to load WASM before restoring state. Ticket: WCI-890 Session-Id: 2b6d8843-9bec-4a05-8725-18d450b7f097 Task-Id: dcea3d67-b592-483a-967b-968cc01f5b76
1 parent bf10059 commit a95ffdb

3 files changed

Lines changed: 10 additions & 22 deletions

File tree

modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,10 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
735735
const bitgoKeyObj = await pgp.readKey({ armoredKey: bitgoGpgPubKey });
736736
const counterPartyKeyObj = await pgp.readKey({ armoredKey: counterPartyGpgPubKey });
737737

738-
const decryptedRound1Session = await this.bitgo.decrypt({ input: encryptedRound1Session, password: walletPassphrase });
738+
const decryptedRound1Session = await this.bitgo.decrypt({
739+
input: encryptedRound1Session,
740+
password: walletPassphrase,
741+
});
739742

740743
const { dkgSession, ownMsgPayload, ownMsgFrom } = JSON.parse(decryptedRound1Session) as {
741744
dkgSession: string;

modules/sdk-core/test/unit/bitgo/utils/tss/eddsa/eddsaMPCv2.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,7 @@ describe('EddsaMPCv2Utils.createOfflineKeyGenRound2Share', () => {
818818
eddsaMPCv2Utils = new EddsaMPCv2Utils(mockBitgo, mockCoin);
819819
});
820820

821-
async function runRound1(
822-
partyId: MPCv2PartiesEnum.USER | MPCv2PartiesEnum.BACKUP = MPCv2PartiesEnum.USER
823-
): Promise<{
821+
async function runRound1(partyId: MPCv2PartiesEnum.USER | MPCv2PartiesEnum.BACKUP = MPCv2PartiesEnum.USER): Promise<{
824822
result: { signedMsg1: MPSTypes.MPSSignedMessage; encryptedRound1Session: string };
825823
ownGpgKeyPair: pgp.SerializedKeyPair<string>;
826824
counterPartyGpgKeyPair: pgp.SerializedKeyPair<string>;
@@ -839,32 +837,19 @@ describe('EddsaMPCv2Utils.createOfflineKeyGenRound2Share', () => {
839837
}
840838

841839
async function buildCounterPartyAndBitgoMsgs(
842-
userRound1Result: MPSTypes.MPSSignedMessage,
840+
_userRound1Result: MPSTypes.MPSSignedMessage,
843841
backupRound1Result: MPSTypes.MPSSignedMessage
844842
): Promise<{ bitgoMsg1: MPSTypes.MPSSignedMessage; counterPartyMsg1ForUser: MPSTypes.MPSSignedMessage }> {
845843
const bitgoGpgPrivKey = await pgp.readPrivateKey({ armoredKey: bitgoGpgKeyPair.privateKey });
846844

847-
// Build a real user DKG round1 to get the bitgo msg
848-
const userGpgPrivKey = await pgp.readPrivateKey({ armoredKey: userGpgKeyPair.privateKey });
849-
const [, ownUserSk] = await MPSComms.extractEd25519KeyPair(userGpgPrivKey);
850-
851-
const backupGpgPrivKey = await pgp.readPrivateKey({ armoredKey: backupGpgKeyPair.privateKey });
852-
const [, ownBackupSk] = await MPSComms.extractEd25519KeyPair(backupGpgPrivKey);
853-
854-
const bitgoGpgPubKeyObj = await pgp.readKey({ armoredKey: bitgoGpgKeyPair.publicKey });
855-
const bitgoPk = await MPSComms.extractEd25519PublicKey(bitgoGpgPubKeyObj);
856-
857845
const userGpgPubKeyObj = await pgp.readKey({ armoredKey: userGpgKeyPair.publicKey });
858846
const userPk = await MPSComms.extractEd25519PublicKey(userGpgPubKeyObj);
859847

860848
const backupGpgPubKeyObj = await pgp.readKey({ armoredKey: backupGpgKeyPair.publicKey });
861849
const backupPk = await MPSComms.extractEd25519PublicKey(backupGpgPubKeyObj);
862850

863851
const bitgoDkg = new EddsaMPSDkg.DKG(3, 2, MPCv2PartiesEnum.BITGO);
864-
await bitgoDkg.initDkg(
865-
(await MPSComms.extractEd25519KeyPair(bitgoGpgPrivKey))[1],
866-
[userPk, backupPk]
867-
);
852+
await bitgoDkg.initDkg((await MPSComms.extractEd25519KeyPair(bitgoGpgPrivKey))[1], [userPk, backupPk]);
868853
const bitgoRawMsg1 = bitgoDkg.getFirstMessage();
869854
const bitgoMsg1 = await MPSComms.detachSignMpsMessage(Buffer.from(bitgoRawMsg1.payload), bitgoGpgPrivKey);
870855

modules/sdk-lib-mpc/test/unit/tss/eddsa/dkg.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ describe('EdDSA MPS DKG', function () {
286286
const restoredBackup = new EddsaMPSDkg.DKG(3, 2, 1);
287287
const restoredBitgo = new EddsaMPSDkg.DKG(3, 2, 2);
288288

289-
restoredUser.restoreSession(userSession);
290-
restoredBackup.restoreSession(backupSession);
291-
restoredBitgo.restoreSession(bitgoSession);
289+
await restoredUser.restoreSession(userSession);
290+
await restoredBackup.restoreSession(backupSession);
291+
await restoredBitgo.restoreSession(bitgoSession);
292292

293293
assert.strictEqual(restoredUser.getState(), user.getState(), 'Restored state should match original');
294294
assert.strictEqual(restoredBackup.getState(), backup.getState(), 'Restored backup state should match original');

0 commit comments

Comments
 (0)