Skip to content
Merged
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
2 changes: 1 addition & 1 deletion modules/sdk-lib-mpc/src/tss/ecdsa-dkls/dsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class Dsg {
*/
endSession(): void {
if (this._signature) {
new Error('Session already ended because combined signature was produced.');
throw new Error('Session already ended because combined signature was produced.');
}
if (this.dsgSession) {
this.dsgSession.free();
Expand Down
23 changes: 23 additions & 0 deletions modules/sdk-lib-mpc/test/unit/tss/ecdsa/dklsDsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,29 @@ describe('DKLS Dsg 2x3', function () {
await party.init().should.be.rejectedWith(/Invalid messageHash length/);
});

it('should throw in endSession() when signature has already been produced', async function () {
const vector = vectors[0];
const party1 = new DklsDsg.Dsg(
fs.readFileSync(shareFiles[vector.party1]),
vector.party1,
vector.derivationPath,
crypto.createHash('sha256').update(Buffer.from(vector.msgToSign, 'hex')).digest()
);
const party2 = new DklsDsg.Dsg(
fs.readFileSync(shareFiles[vector.party2]),
vector.party2,
vector.derivationPath,
crypto.createHash('sha256').update(Buffer.from(vector.msgToSign, 'hex')).digest()
);
const round4Messages = await executeTillRound(4, party1, party2);
party1.handleIncomingMessages({
p2pMessages: [],
broadcastMessages: round4Messages[1].broadcastMessages,
});
should.exist(party1.signature);
(() => party1.endSession()).should.throw('Session already ended because combined signature was produced.');
});

it(`should fail when signing two different messages`, async function () {
const party1 = new DklsDsg.Dsg(
fs.readFileSync(`${__dirname}/fixtures/userShare`),
Expand Down
Loading