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
3 changes: 3 additions & 0 deletions modules/sdk-lib-mpc/src/tss/ecdsa-dkls/dsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export class Dsg {
if (this.dsgState !== DsgState.Uninitialized) {
throw Error('DSG session already initialized');
}
if (this.messageHash.length !== 32) {
throw Error(`Invalid messageHash length: expected 32 bytes (SHA-256), got ${this.messageHash.length}`);
}
if (!this.dklsWasm) {
await this.loadDklsWasm();
}
Expand Down
10 changes: 10 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 @@ -207,6 +207,16 @@ describe('DKLS Dsg 2x3', function () {
should.exist(convertedSignature);
});

it('should throw if messageHash is not 32 bytes', async function () {
const party = new DklsDsg.Dsg(fs.readFileSync(shareFiles[0]), 0, 'm', Buffer.alloc(31));
await party.init().should.be.rejectedWith(/Invalid messageHash length/);
});

it('should throw if messageHash is empty', async function () {
const party = new DklsDsg.Dsg(fs.readFileSync(shareFiles[0]), 0, 'm', Buffer.alloc(0));
await party.init().should.be.rejectedWith(/Invalid messageHash length/);
});

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