Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/sdk-core/src/bitgo/tss/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ const debug = require('debug')('bitgo:tss:common');

export function getBitgoSignatureShare(
signatureShares: SignatureShareRecord[],
signerShareType: SignatureShareType
signerShareType: SignatureShareType,
shareType: 'round1Output' | 'round2Output' | 'round3Output'
): SignatureShareRecord {
const bitgoShare = signatureShares.find(
(share) => share.from === SignatureShareType.BITGO && share.to === signerShareType
(share) =>
share.from === SignatureShareType.BITGO &&
share.to === signerShareType &&
JSON.parse(share.share).type === shareType
);
assert(bitgoShare, 'Missing BitGo signature share');
assert(bitgoShare, `Missing BitGo ${shareType} signature share`);
return bitgoShare;
}

Expand Down
19 changes: 4 additions & 15 deletions modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
? latestTxRequest.transactions![0].signatureShares
: latestTxRequest.messages![0].signatureShares;

const bitgoShareRoundOne = getBitgoSignatureShare(signatureShares1, signerShareType);
const bitgoShareRoundOne = getBitgoSignatureShare(signatureShares1, signerShareType, 'round1Output');
const parsedBitGoToUserSigShareRoundOne = decodeWithCodec(
EddsaMPCv2SignatureShareRound1Output,
JSON.parse(bitgoShareRoundOne.share),
Expand Down Expand Up @@ -508,7 +508,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
? latestTxRequest.transactions![0].signatureShares
: latestTxRequest.messages![0].signatureShares;

const bitgoShareRoundTwo = getBitgoSignatureShare(txRequestSignatureShares, signerShareType);
const bitgoShareRoundTwo = getBitgoSignatureShare(txRequestSignatureShares, signerShareType, 'round2Output');
const parsedBitGoToUserSigShareRoundTwo = decodeWithCodec(
EddsaMPCv2SignatureShareRound2Output,
JSON.parse(bitgoShareRoundTwo.share),
Expand Down Expand Up @@ -649,7 +649,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
const signatureShares = transactions[0].signatureShares;
assert(signatureShares, 'Missing signature shares in round 1 txRequest');

const bitgoShareRoundOne = getBitgoSignatureShare(signatureShares, SignatureShareType.USER);
const bitgoShareRoundOne = getBitgoSignatureShare(signatureShares, SignatureShareType.USER, 'round1Output');
const parsedBitGoToUserSigShareRoundOne = decodeWithCodec(
EddsaMPCv2SignatureShareRound1Output,
JSON.parse(bitgoShareRoundOne.share),
Expand Down Expand Up @@ -754,18 +754,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
const signatureShares = transactions[0].signatureShares;
assert(signatureShares, 'Missing signature shares in round 2 txRequest');

const bitgoShareRoundTwo = [...signatureShares].reverse().find((share) => {
if (share.from !== SignatureShareType.BITGO || share.to !== SignatureShareType.USER) {
return false;
}

try {
return JSON.parse(share.share).type === 'round2Output';
} catch {
return false;
}
});
assert(bitgoShareRoundTwo, 'Missing BitGo round 2 signature share');
const bitgoShareRoundTwo = getBitgoSignatureShare(signatureShares, SignatureShareType.USER, 'round2Output');

const parsedBitGoToUserSigShareRoundTwo = decodeWithCodec(
EddsaMPCv2SignatureShareRound2Output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ describe('EddsaMPCv2Utils.createOfflineRound2Share', () => {
encryptedUserGpgPrvKey: round1.encryptedUserGpgPrvKey,
encryptedRound1Session: round1.encryptedRound1Session,
}),
/Missing BitGo signature share/
/Missing BitGo round1Output signature share/
);
});

Expand Down Expand Up @@ -1114,7 +1114,7 @@ describe('EddsaMPCv2Utils.createOfflineRound3Share', () => {
encryptedUserGpgPrvKey: round1.encryptedUserGpgPrvKey,
encryptedRound2Session: round2.encryptedRound2Session,
}),
/Missing BitGo round 2 signature share/
/Missing BitGo round2Output signature share/
);
});

Expand Down
Loading