Skip to content

Commit

Permalink
fix(sdk-coin-eth): fix convert signature share to/from
Browse files Browse the repository at this point in the history
Ticket: bg-58807
  • Loading branch information
anshuldoshi committed Oct 3, 2022
1 parent 5abfcd8 commit 9aed51e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions modules/bitgo/test/v2/unit/tss/ecdsa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,11 @@ describe('Ecdsa tss helper functions tests', function () {

it('should successfully convert signature share to signature share record', function () {
const share = {
to: SignatureShareType.USER,
from: SignatureShareType.BITGO,
to: SignatureShareType.BITGO,
from: SignatureShareType.USER,
share: `${mockSShareFromUser.R}${ECDSAMethods.delimeter}${mockSShareFromUser.s}${ECDSAMethods.delimeter}${mockSShareFromUser.y}`,
} as SignatureShareRecord;
const signatureShare = ECDSAMethods.convertSignatureShare(mockSShareFromUser, ECDSAMethods.getParticipantIndex('bitgo'));
const signatureShare = ECDSAMethods.convertSignatureShare(mockSShareFromUser, ECDSAMethods.getParticipantIndex('user'), ECDSAMethods.getParticipantIndex('bitgo'));
signatureShare.from.should.equal(share.from);
signatureShare.to.should.equal(share.to);
signatureShare.share.should.equal(share.share);
Expand Down
10 changes: 7 additions & 3 deletions modules/sdk-core/src/bitgo/tss/ecdsa/ecdsa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export async function sendShareToBitgo(
break;
case SendShareType.SShare:
const sShare = share as SShare;
signatureShare = convertSignatureShare(sShare, 3);
signatureShare = convertSignatureShare(sShare, 1, 3);
await sendSignatureShare(bitgo, walletId, txRequestId, signatureShare, requestType, signerShare, 'ecdsa');
responseFromBitgo = sShare;
break;
Expand Down Expand Up @@ -573,9 +573,13 @@ export function parseCombinedSignature(share: SignatureShareRecord): Signature {
* @param share - Signature share
* @returns signature share record
*/
export function convertSignatureShare(share: SignatureShare, senderIndex: number): SignatureShareRecord {
export function convertSignatureShare(
share: SignatureShare,
senderIndex: number,
recipientIndex: number
): SignatureShareRecord {
return {
to: getParticipantFromIndex(share.i),
to: getParticipantFromIndex(recipientIndex),
from: getParticipantFromIndex(senderIndex),
share: `${share.R}${delimeter}${share.s}${delimeter}${share.y}`,
};
Expand Down

0 comments on commit 9aed51e

Please sign in to comment.