Skip to content

Commit 32bc1d0

Browse files
Marzooqaclaude
andcommitted
fix(sdk-lib-mpc): use MPSUtil.executeTillRound in derive tests
TICKET: WCI-390 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5b9b14b commit 32bc1d0

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

  • modules/sdk-lib-mpc/test/unit/tss/eddsa

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import assert from 'assert';
22
import { ed25519 } from '@noble/curves/ed25519';
3+
import { EddsaMPSDsg, MPSUtil } from '../../../../src/tss/eddsa-mps';
34
import { deriveUnhardenedMps } from '../../../../src/tss/eddsa-mps/derive';
4-
import { generateEdDsaDKGKeyShares, runEdDsaDSG } from './util';
5+
import { generateEdDsaDKGKeyShares } from './util';
56

67
const MESSAGE = Buffer.from('The Times 03/Jan/2009 Chancellor on brink of second bailout for banks');
78

@@ -63,28 +64,40 @@ describe('deriveUnhardenedMps', function () {
6364
});
6465

6566
describe('DSG signature cross-check against the public key derived by deriveUnhardenedMps', function () {
67+
let sigAtRoot: Buffer;
68+
let sigAtM0: Buffer;
69+
let sigAtM01: Buffer;
70+
71+
before(function () {
72+
const dsgA1 = new EddsaMPSDsg.DSG(0);
73+
MPSUtil.executeTillRound(3, dsgA1, new EddsaMPSDsg.DSG(2), userKeyShare, bitgoKeyShare, MESSAGE, 'm');
74+
sigAtRoot = dsgA1.getSignature();
75+
76+
const dsgA2 = new EddsaMPSDsg.DSG(0);
77+
MPSUtil.executeTillRound(3, dsgA2, new EddsaMPSDsg.DSG(2), userKeyShare, bitgoKeyShare, MESSAGE, 'm/0');
78+
sigAtM0 = dsgA2.getSignature();
79+
80+
const dsgA3 = new EddsaMPSDsg.DSG(0);
81+
MPSUtil.executeTillRound(3, dsgA3, new EddsaMPSDsg.DSG(2), userKeyShare, bitgoKeyShare, MESSAGE, 'm/0/1');
82+
sigAtM01 = dsgA3.getSignature();
83+
});
84+
6685
it('signature from DSG at "m" verifies against the root public key', function () {
67-
const { dsgA } = runEdDsaDSG(userKeyShare, bitgoKeyShare, 0, 2, MESSAGE, 'm');
68-
const sig = dsgA.getSignature();
69-
assert(ed25519.verify(sig, MESSAGE, rootPubKey), 'DSG at "m" should verify against the raw DKG public key');
86+
assert(ed25519.verify(sigAtRoot, MESSAGE, rootPubKey), 'DSG at "m" should verify against the raw DKG public key');
7087
});
7188

7289
it('signature from DSG at "m/0" verifies against deriveUnhardenedMps(commonKeychain, "m/0")', function () {
7390
const derivedPk = Buffer.from(deriveUnhardenedMps(commonKeychain, 'm/0').slice(0, 64), 'hex');
74-
const { dsgA } = runEdDsaDSG(userKeyShare, bitgoKeyShare, 0, 2, MESSAGE, 'm/0');
75-
const sig = dsgA.getSignature();
7691
assert(
77-
ed25519.verify(sig, MESSAGE, derivedPk),
92+
ed25519.verify(sigAtM0, MESSAGE, derivedPk),
7893
'DSG at "m/0" should verify against deriveUnhardenedMps result at "m/0"'
7994
);
8095
});
8196

8297
it('signature from DSG at "m/0/1" verifies against deriveUnhardenedMps(commonKeychain, "m/0/1")', function () {
8398
const derivedPk = Buffer.from(deriveUnhardenedMps(commonKeychain, 'm/0/1').slice(0, 64), 'hex');
84-
const { dsgA } = runEdDsaDSG(userKeyShare, bitgoKeyShare, 0, 2, MESSAGE, 'm/0/1');
85-
const sig = dsgA.getSignature();
8699
assert(
87-
ed25519.verify(sig, MESSAGE, derivedPk),
100+
ed25519.verify(sigAtM01, MESSAGE, derivedPk),
88101
'DSG at "m/0/1" should verify against deriveUnhardenedMps result at "m/0/1"'
89102
);
90103
});

0 commit comments

Comments
 (0)