From 11af4f2d73a77151e4a219780dfb6ce274a37fde Mon Sep 17 00:00:00 2001 From: ieow Date: Fri, 23 Feb 2024 15:27:46 +0800 Subject: [PATCH] fix: support backward compatible --- packages/core/src/core.ts | 17 +- .../default/test/RefreshAndAccountIndex.js | 195 ++++++++++++++++++ packages/default/test/helpers.js | 14 +- packages/default/test/shared.js | 179 ++-------------- 4 files changed, 235 insertions(+), 170 deletions(-) create mode 100644 packages/default/test/RefreshAndAccountIndex.js diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 06695368..5bfa99b1 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -305,7 +305,7 @@ class ThresholdKey implements ITKey { if (useTSS) { const { factorEncs, factorPubs, tssPolyCommits } = await this._initializeNewTSSKey(this.tssTag, deviceTSSShare, factorPub, deviceTSSIndex); const accountSalt = generateSalt(); - this._setTKeyStoreItem(TSS_MODULE, { + await this._setTKeyStoreItem(TSS_MODULE, { id: "accountSalt", value: accountSalt, }); @@ -621,9 +621,20 @@ class ThresholdKey implements ITKey { ); } + // only valid for use Tss // assign account salt from tKey store if it exists const accountSalt = await this.getTKeyStoreItem(TSS_MODULE, "accountSalt"); - if (accountSalt && accountSalt?.value) this._accountSalt = accountSalt.value; + if (accountSalt && accountSalt?.value) { + this._accountSalt = accountSalt.value; + } else { + const newSalt = generateSalt(); + await this._setTKeyStoreItem(TSS_MODULE, { + id: "accountSalt", + value: newSalt, + }); + this._accountSalt = newSalt; + await this._syncShareMetadata(); + } return { privKey, ...returnObject }; } @@ -916,7 +927,7 @@ class ThresholdKey implements ITKey { factorPubs, factorEncs, }); - this._setTKeyStoreItem(TSS_MODULE, { + await this._setTKeyStoreItem(TSS_MODULE, { id: "accountSalt", value: accountSalt, }); diff --git a/packages/default/test/RefreshAndAccountIndex.js b/packages/default/test/RefreshAndAccountIndex.js new file mode 100644 index 00000000..361db3f8 --- /dev/null +++ b/packages/default/test/RefreshAndAccountIndex.js @@ -0,0 +1,195 @@ +import { ecCurve, getPubKeyPoint } from "@tkey-mpc/common-types"; +import { generatePrivate } from "@toruslabs/eccrypto"; +import { fail, notEqual, rejects, strictEqual } from "assert"; +import BN from "bn.js"; + +import ThresholdKey from "../src/index"; +import { assignTssDkgKeys, computeIndexedPrivateKey, fetchPostboxKeyAndSigs, getMetadataUrl, initStorageLayer } from "./helpers"; + +const TSS_MODULE = "tssModule"; +const metadataURL = getMetadataUrl(); + +// eslint-disable-next-line mocha/no-exports +export const refreshAndAccountIndex = (customSP, manualSync, accountIndexBackwardCompatible) => { + const mode = manualSync; + + describe.only("RefreshAndAccountIndex", function () { + it("#should be able to refresh tss shares", async function () { + const sp = customSP; + if (!sp.useTSS) this.skip(); + + const deviceTSSShare = new BN(generatePrivate()); + const deviceTSSIndex = 2; + + sp.verifierName = "torus-test-health"; + sp.verifierId = "test19@example.com"; + const testId = sp.getVerifierNameVerifierId(); + const { signatures, postboxkey } = await fetchPostboxKeyAndSigs({ + serviceProvider: sp, + verifierName: sp.verifierName, + verifierId: sp.verifierId, + }); + sp.postboxKey = postboxkey; + const { serverDKGPrivKeys } = await assignTssDkgKeys({ + serviceProvider: sp, + verifierName: sp.verifierName, + verifierId: sp.verifierId, + maxTSSNonceToSimulate: 3, + }); + + const storageLayer = initStorageLayer({ hostUrl: metadataURL }); + const tb0 = new ThresholdKey({ serviceProvider: sp, storageLayer, manualSync: mode }); + + // accountSalt is absent, required for nonce generation + // can be only initialize with tkey.initialize(); + rejects(async () => { + tb0.computeAccountNonce(1); + }); + // factor key needs to passed from outside of tKey + const factorKey = new BN(generatePrivate()); + const factorPub = getPubKeyPoint(factorKey); + + await tb0.initialize({ useTSS: true, factorPub, deviceTSSShare, deviceTSSIndex }); + await tb0.reconstructKey(); + + // Test for backward compatibility ( accountSalt is absent for old account ) + if (accountIndexBackwardCompatible) { + await tb0._deleteTKeyStoreItem(TSS_MODULE, "accountSalt"); + } + + const newShare = await tb0.generateNewShare(); + await tb0.syncLocalMetadataTransitions(); + + const tb1 = new ThresholdKey({ serviceProvider: sp, storageLayer, manualSync: mode }); + await tb1.initialize({ useTSS: true, factorPub, deviceTSSShare, deviceTSSIndex }); + + // const newShare = await tb1.generateNewShare(); + await tb1.inputShareStoreSafe(newShare.newShareStores[newShare.newShareIndex.toString("hex")]); + const reconstructedKey = await tb1.reconstructKey(); + + if (tb1.privKey.cmp(reconstructedKey.privKey) !== 0) { + fail("key should be able to be reconstructed"); + } + + const tssPrivKey1 = await computeIndexedPrivateKey(tb1, factorKey, serverDKGPrivKeys[0], 1); + const tssPubKeyIndex0 = ecCurve.keyFromPrivate(tssPrivKey1).getPublic(); + + const pubKey1 = tb1.getTSSPub(1); + strictEqual(tssPubKeyIndex0.x.toString(16, 64), pubKey1.x.toString(16, 64)); + strictEqual(tssPubKeyIndex0.y.toString(16, 64), pubKey1.y.toString(16, 64)); + + const factorKey1 = new BN(generatePrivate()); + const factorPub1 = getPubKeyPoint(factorKey1); + + const factorPubs1 = [factorPub, factorPub1]; + const { serverEndpoints, serverPubKeys } = await sp.getRSSNodeDetails(); + const { tssShare: retrievedTSSShare1, tssIndex: retrievedTSSIdx1 } = await tb1.getTSSShare(factorKey); + await tb1._refreshTSSShares(true, retrievedTSSShare1, retrievedTSSIdx1, factorPubs1, [2, 3], testId, { + serverThreshold: 3, + selectedServers: [1, 2, 3], + serverEndpoints, + serverPubKeys, + authSignatures: signatures, + }); + await tb1.syncLocalMetadataTransitions(); + + const tssPrivKeyIndex1 = await computeIndexedPrivateKey(tb1, factorKey, serverDKGPrivKeys[1], 1); + const tssPrivKeyIndex2 = await computeIndexedPrivateKey(tb1, factorKey, serverDKGPrivKeys[1], 2); + + const tssPubKeyIndex1 = ecCurve.keyFromPrivate(tssPrivKeyIndex1).getPublic(); + + const pubKeyIndex1 = tb1.getTSSPub(1); + strictEqual(tssPubKeyIndex1.x.toString(16, 64), pubKeyIndex1.x.toString(16, 64)); + strictEqual(tssPubKeyIndex1.y.toString(16, 64), pubKeyIndex1.y.toString(16, 64)); + + const tb2 = new ThresholdKey({ serviceProvider: sp, storageLayer, manualSync: mode }); + await tb2.initialize({ useTSS: true, factorPub }); + await tb2.inputShareStoreSafe(newShare.newShareStores[newShare.newShareIndex.toString("hex")]); + await tb2.reconstructKey(); + + const tssPrivKeytb2Index2 = await computeIndexedPrivateKey(tb2, factorKey, serverDKGPrivKeys[1], 2); + strictEqual(tssPrivKeyIndex2.toString("hex"), tssPrivKeytb2Index2.toString("hex")); + + const tssPubKeytb2Index2 = getPubKeyPoint(tssPrivKeytb2Index2); + const pubKey2Index2 = tb2.getTSSPub(2); + + strictEqual(tssPubKeytb2Index2.x.toString(16, 64), pubKey2Index2.x.toString(16, 64)); + strictEqual(tssPubKeytb2Index2.y.toString(16, 64), pubKey2Index2.y.toString(16, 64)); + + // // test tss refresh + const factorKey2 = new BN(generatePrivate()); + const factorPub2 = getPubKeyPoint(factorKey2); + + const factorPubs2 = [factorPub, factorPub2]; + const { tssShare: retrievedTSS3, tssIndex: retrievedTSSIndex3 } = await tb2.getTSSShare(factorKey); + await tb2._refreshTSSShares(true, retrievedTSS3, retrievedTSSIndex3, factorPubs2, [2, 3], testId, { + serverThreshold: 3, + selectedServers: [1, 2, 3], + serverEndpoints, + serverPubKeys, + authSignatures: signatures, + }); + + // test case to ensure nonce mechanism + { + // make sure derived pub key is different from the index 0 key + notEqual(tssPubKeyIndex0.x.toString(16, 64), tssPubKeytb2Index2.x.toString(16, 64)); + notEqual(tssPubKeyIndex0.y.toString(16, 64), tssPubKeytb2Index2.y.toString(16, 64)); + + const { tssShare: retrievedTSS } = await tb2.getTSSShare(factorKey); + const tssSharePub = ecCurve.keyFromPrivate(retrievedTSS.toString("hex")).getPublic(); + const { tssShare: retrievedTSSIndex1 } = await tb2.getTSSShare(factorKey, { accountIndex: 1 }); + const tssSharePubIndex1 = ecCurve.keyFromPrivate(retrievedTSSIndex1.toString("hex")).getPublic(); + + const nonce = tb2.computeAccountNonce(1); + const noncePub = ecCurve.keyFromPrivate(nonce.toString("hex")).getPublic(); + const tssShareDerived = tssSharePub.add(noncePub); + + strictEqual(tssShareDerived.getX().toString("hex"), tssSharePubIndex1.getX().toString("hex")); + strictEqual(tssShareDerived.getY().toString("hex"), tssSharePubIndex1.getY().toString("hex")); + + const { tssShare: retrievedTSS31 } = await tb2.getTSSShare(factorKey, { accountIndex: 2 }); + const tssSharePub3 = ecCurve.keyFromPrivate(retrievedTSS31.toString("hex")).getPublic(); + const nonce2 = tb2.computeAccountNonce(2); + const noncePub2 = ecCurve.keyFromPrivate(nonce2.toString("hex")).getPublic(); + const tssShareDerived2 = tssSharePub.add(noncePub2); + strictEqual(tssShareDerived2.getX().toString("hex"), tssSharePub3.getX().toString("hex")); + strictEqual(tssShareDerived2.getY().toString("hex"), tssSharePub3.getY().toString("hex")); + } + + // check for account 1 and 2 after refresh share ( tb1 only refresh once ) + { + const { tssShare: newTSS, tssIndex } = await tb1.getTSSShare(factorKey, { accountIndex: 1 }); + const computedKey = await computeIndexedPrivateKey(tb1, factorKey, serverDKGPrivKeys[1], 1); + strictEqual(tssPrivKey1.toString(16, 64), computedKey.toString(16, 64)); + // eslint-disable-next-line no-console + console.log("newTSS", newTSS.toString("hex"), tssIndex); + } + + { + const { tssShare: newTSS, tssIndex } = await tb1.getTSSShare(factorKey, { accountIndex: 2 }); + const computedKey = await computeIndexedPrivateKey(tb1, factorKey, serverDKGPrivKeys[1], 2); + strictEqual(tssPrivKeyIndex2.toString(16, 64), computedKey.toString(16, 64)); + // eslint-disable-next-line no-console + console.log("newTSS", newTSS.toString("hex"), tssIndex); + } + + // check for account 1 and 2 after refresh share ( tb2 only refresh twice ) + { + const { tssShare: newTSS2, tssIndex } = await tb2.getTSSShare(factorKey2, { accountIndex: 1 }); + const computedKey = await computeIndexedPrivateKey(tb2, factorKey2, serverDKGPrivKeys[2], 1); + strictEqual(tssPrivKey1.toString(16, 64), computedKey.toString(16, 64)); + // eslint-disable-next-line no-console + console.log("newTSS2", newTSS2.toString("hex"), tssIndex); + } + + { + const { tssShare: newTSS2, tssIndex } = await tb2.getTSSShare(factorKey2, { accountIndex: 2 }); + const computedKey = await computeIndexedPrivateKey(tb2, factorKey2, serverDKGPrivKeys[2], 2); + strictEqual(tssPrivKeytb2Index2.toString(16, 64), computedKey.toString(16, 64)); + // eslint-disable-next-line no-console + console.log("newTSS2", newTSS2.toString("hex"), tssIndex); + } + }); + }); +}; diff --git a/packages/default/test/helpers.js b/packages/default/test/helpers.js index bba6014f..dff60b4e 100644 --- a/packages/default/test/helpers.js +++ b/packages/default/test/helpers.js @@ -1,9 +1,8 @@ -import { ecCurve, getPubKeyPoint, Point } from "@tkey-mpc/common-types"; +import { ecCurve, generatePrivate, getPubKeyPoint, Point } from "@tkey-mpc/common-types"; import ServiceProviderBase from "@tkey-mpc/service-provider-base"; import ServiceProviderTorus from "@tkey-mpc/service-provider-torus"; import TorusStorageLayer, { MockStorageLayer } from "@tkey-mpc/storage-layer-torus"; -import { generatePrivate } from "@toruslabs/eccrypto"; -import { generatePolynomial, getShare, hexPoint, MockServer, postEndpoint } from "@toruslabs/rss-client"; +import { generatePolynomial, getLagrangeCoeffs, getShare, hexPoint, MockServer, postEndpoint } from "@toruslabs/rss-client"; // eslint-disable-next-line import/no-extraneous-dependencies import Torus from "@toruslabs/torus.js"; import BN from "bn.js"; @@ -197,3 +196,12 @@ export async function assignTssDkgKeys(opts) { // serverDKGPubKeys, }; } + +export async function computeIndexedPrivateKey(tkey, factorKey, serverDKGPrivKeys, accountIndex) { + const { tssShare: retrievedTSS1, tssIndex: retrievedTSSIndex1 } = await tkey.getTSSShare(factorKey, { accountIndex }); + const tssPrivKey1 = getLagrangeCoeffs([1, retrievedTSSIndex1], 1) + .mul(serverDKGPrivKeys.add(tkey.computeAccountNonce(accountIndex))) + .add(getLagrangeCoeffs([1, retrievedTSSIndex1], retrievedTSSIndex1).mul(retrievedTSS1)) + .umod(ecCurve.n); + return tssPrivKey1; +} diff --git a/packages/default/test/shared.js b/packages/default/test/shared.js index ec2d28c1..25022b67 100644 --- a/packages/default/test/shared.js +++ b/packages/default/test/shared.js @@ -22,7 +22,17 @@ import stringify from "json-stable-stringify"; import { createSandbox } from "sinon"; import ThresholdKey from "../src/index"; -import { assignTssDkgKeys, fetchPostboxKeyAndSigs, getMetadataUrl, getServiceProvider, initStorageLayer, isMocked, setupTSSMocks } from "./helpers"; +import { + assignTssDkgKeys, + computeIndexedPrivateKey, + fetchPostboxKeyAndSigs, + getMetadataUrl, + getServiceProvider, + initStorageLayer, + isMocked, + setupTSSMocks, +} from "./helpers"; +import { refreshAndAccountIndex } from "./RefreshAndAccountIndex"; const rejects = async (fn, error, msg) => { let f = () => {}; @@ -67,172 +77,13 @@ function compareReconstructedKeys(a, b, message) { export const sharedTestCases = (mode, torusSP, storageLayer) => { const customSP = torusSP; const customSL = storageLayer; - describe("TSS tests", function () { - it("#should be able to refresh tss shares", async function () { - const sp = customSP; - if (!sp.useTSS) this.skip(); - - const deviceTSSShare = new BN(generatePrivate()); - const deviceTSSIndex = 2; - - sp.verifierName = "torus-test-health"; - sp.verifierId = "test19@example.com"; - const testId = sp.getVerifierNameVerifierId(); - const { signatures, postboxkey } = await fetchPostboxKeyAndSigs({ - serviceProvider: sp, - verifierName: sp.verifierName, - verifierId: sp.verifierId, - }); - sp.postboxKey = postboxkey; - const { serverDKGPrivKeys } = await assignTssDkgKeys({ - serviceProvider: sp, - verifierName: sp.verifierName, - verifierId: sp.verifierId, - maxTSSNonceToSimulate: 2, - }); - const storageLayer = initStorageLayer({ hostUrl: metadataURL }); - const tb1 = new ThresholdKey({ serviceProvider: sp, storageLayer, manualSync: mode }); - - // accountSalt is absent, required for nonce generation - // can be only initialize with tkey.initialize(); - rejects(async () => { - tb1.computeAccountNonce(1); - }); - // factor key needs to passed from outside of tKey - const factorKey = new BN(generatePrivate()); - const factorPub = getPubKeyPoint(factorKey); - - await tb1.initialize({ useTSS: true, factorPub, deviceTSSShare, deviceTSSIndex }); - const newShare = await tb1.generateNewShare(); - const reconstructedKey = await tb1.reconstructKey(); - await tb1.syncLocalMetadataTransitions(); - if (tb1.privKey.cmp(reconstructedKey.privKey) !== 0) { - fail("key should be able to be reconstructed"); - } - const { tssShare: retrievedTSS1, tssIndex: retrievedTSSIndex1 } = await tb1.getTSSShare(factorKey, { accountIndex: 1 }); - const tssPrivKey1 = getLagrangeCoeffs([1, retrievedTSSIndex1], 1) - .mul(serverDKGPrivKeys[0].add(tb1.computeAccountNonce(1))) - .add(getLagrangeCoeffs([1, retrievedTSSIndex1], retrievedTSSIndex1).mul(retrievedTSS1)) - .umod(ecCurve.n); - const tssPubKey1 = ecCurve.keyFromPrivate(tssPrivKey1).getPublic(); - - const pubKey1 = tb1.getTSSPub(1); - strictEqual(tssPubKey1.x.toString(16, 64), pubKey1.x.toString(16, 64)); - strictEqual(tssPubKey1.y.toString(16, 64), pubKey1.y.toString(16, 64)); - - const factorKey1 = new BN(generatePrivate()); - const factorPub1 = getPubKeyPoint(factorKey1); - - const factorPubs1 = [factorPub, factorPub1]; - const { serverEndpoints, serverPubKeys } = await sp.getRSSNodeDetails(); - const { tssShare: retrievedTSSShare1, tssIndex: retrievedTSSIdx1 } = await tb1.getTSSShare(factorKey); - await tb1._refreshTSSShares(true, retrievedTSSShare1, retrievedTSSIdx1, factorPubs1, [2, 3], testId, { - serverThreshold: 3, - selectedServers: [1, 2, 3], - serverEndpoints, - serverPubKeys, - authSignatures: signatures, - }); - - const tb2 = new ThresholdKey({ serviceProvider: sp, storageLayer, manualSync: mode }); - await tb2.initialize({ useTSS: true, factorPub }); - await tb2.inputShareStoreSafe(newShare.newShareStores[newShare.newShareIndex.toString("hex")]); - await tb2.reconstructKey(); - - const { tssShare: retrievedTSS2, tssIndex: retrievedTSSIndex2 } = await tb2.getTSSShare(factorKey, { accountIndex: 2 }); - const tssPrivKey2 = getLagrangeCoeffs([1, retrievedTSSIndex2], 1) - .mul(serverDKGPrivKeys[0].add(tb1.computeAccountNonce(2))) - .add(getLagrangeCoeffs([1, retrievedTSSIndex2], retrievedTSSIndex2).mul(retrievedTSS2)) - .umod(ecCurve.n); - const tssPubKey2 = getPubKeyPoint(tssPrivKey2); - const pubKey2 = tb1.getTSSPub(2); + // backward compatibility test + refreshAndAccountIndex(customSP, mode, true); - strictEqual(tssPubKey2.x.toString(16, 64), pubKey2.x.toString(16, 64)); - strictEqual(tssPubKey2.y.toString(16, 64), pubKey2.y.toString(16, 64)); - - // // test tss refresh - const factorKey2 = new BN(generatePrivate()); - const factorPub2 = getPubKeyPoint(factorKey2); + refreshAndAccountIndex(customSP, mode, false); - const factorPubs2 = [factorPub, factorPub2]; - const { tssShare: retrievedTSS3, tssIndex: retrievedTSSIndex3 } = await tb2.getTSSShare(factorKey); - await tb2._refreshTSSShares(true, retrievedTSS3, retrievedTSSIndex3, factorPubs2, [2, 3], testId, { - serverThreshold: 3, - selectedServers: [1, 2, 3], - serverEndpoints, - serverPubKeys, - authSignatures: signatures, - }); - - // test case to ensure nonce mechanism - { - notEqual(tssPubKey1.x.toString(16, 64), tssPubKey2.x.toString(16, 64)); - notEqual(tssPubKey1.y.toString(16, 64), tssPubKey2.y.toString(16, 64)); - - const { tssShare: retrievedTSS } = await tb2.getTSSShare(factorKey); - const tssSharePub = ecCurve.keyFromPrivate(retrievedTSS.toString("hex")).getPublic(); - const { tssShare: retrievedTSS2 } = await tb2.getTSSShare(factorKey, { accountIndex: 1 }); - const tssSharePub2 = ecCurve.keyFromPrivate(retrievedTSS2.toString("hex")).getPublic(); - const nonce = tb1.computeAccountNonce(1); - const noncePub = ecCurve.keyFromPrivate(nonce.toString("hex")).getPublic(); - const tssShareDerived = tssSharePub.add(noncePub); - strictEqual(tssShareDerived.getX().toString("hex"), tssSharePub2.getX().toString("hex")); - strictEqual(tssShareDerived.getY().toString("hex"), tssSharePub2.getY().toString("hex")); - - const { tssShare: retrievedTSS3 } = await tb2.getTSSShare(factorKey, { accountIndex: 2 }); - const tssSharePub3 = ecCurve.keyFromPrivate(retrievedTSS3.toString("hex")).getPublic(); - const nonce2 = tb1.computeAccountNonce(2); - const noncePub2 = ecCurve.keyFromPrivate(nonce2.toString("hex")).getPublic(); - const tssShareDerived2 = tssSharePub.add(noncePub2); - strictEqual(tssShareDerived2.getX().toString("hex"), tssSharePub3.getX().toString("hex")); - strictEqual(tssShareDerived2.getY().toString("hex"), tssSharePub3.getY().toString("hex")); - } - - { - const { tssShare: newTSS, tssIndex } = await tb1.getTSSShare(factorKey, { accountIndex: 1 }); - const newTSSPrivKey = getLagrangeCoeffs([1, 2], 1) - .mul(new BN(serverDKGPrivKeys[1], "hex").add(tb1.computeAccountNonce(1))) - .add(getLagrangeCoeffs([1, 2], 2).mul(newTSS)) - .umod(ecCurve.n); - strictEqual(tssPrivKey1.toString(16, 64), newTSSPrivKey.toString(16, 64)); - // eslint-disable-next-line no-console - console.log("newTSS", newTSS.toString("hex"), tssIndex); - } - - { - const { tssShare: newTSS2, tssIndex } = await tb2.getTSSShare(factorKey2, { accountIndex: 1 }); - const newTSSPrivKey = getLagrangeCoeffs([1, 3], 1) - .mul(new BN(serverDKGPrivKeys[1], "hex").add(tb1.computeAccountNonce(1))) - .add(getLagrangeCoeffs([1, 3], 3).mul(newTSS2)) - .umod(ecCurve.n); - strictEqual(tssPrivKey1.toString(16, 64), newTSSPrivKey.toString(16, 64)); - // eslint-disable-next-line no-console - console.log("newTSS2", newTSS2.toString("hex"), tssIndex); - } - - { - const { tssShare: newTSS, tssIndex } = await tb2.getTSSShare(factorKey, { accountIndex: 2 }); - const newTSSPrivKey = getLagrangeCoeffs([1, 2], 1) - .mul(new BN(serverDKGPrivKeys[1], "hex").add(tb2.computeAccountNonce(2))) - .add(getLagrangeCoeffs([1, 2], 2).mul(newTSS)) - .umod(ecCurve.n); - strictEqual(tssPrivKey2.toString(16, 64), newTSSPrivKey.toString(16, 64)); - // eslint-disable-next-line no-console - console.log("newTSS", newTSS.toString("hex"), tssIndex); - } - - { - const { tssShare: newTSS2, tssIndex } = await tb2.getTSSShare(factorKey2, { accountIndex: 2 }); - const newTSSPrivKey = getLagrangeCoeffs([1, 3], 1) - .mul(new BN(serverDKGPrivKeys[1], "hex").add(tb1.computeAccountNonce(2))) - .add(getLagrangeCoeffs([1, 3], 3).mul(newTSS2)) - .umod(ecCurve.n); - strictEqual(tssPrivKey2.toString(16, 64), newTSSPrivKey.toString(16, 64)); - // eslint-disable-next-line no-console - console.log("newTSS2", newTSS2.toString("hex"), tssIndex); - } - }); + describe("TSS tests", function () { it("#should be able to reconstruct tssShare from factor key (tss2) when initializing a key with useTSS true", async function () { const sp = customSP; if (!sp.useTSS) this.skip();