diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 5bfa99b1..c6829684 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -623,17 +623,18 @@ 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; - } else { - const newSalt = generateSalt(); - await this._setTKeyStoreItem(TSS_MODULE, { - id: "accountSalt", - value: newSalt, - }); - this._accountSalt = newSalt; - await this._syncShareMetadata(); + if (Object.keys(this.metadata.tssPolyCommits).length > 0) { + const accountSalt = await this.getTKeyStoreItem(TSS_MODULE, "accountSalt"); + if (accountSalt && accountSalt?.value) { + this._accountSalt = accountSalt.value; + } else { + const newSalt = generateSalt(); + await this._setTKeyStoreItem(TSS_MODULE, { + id: "accountSalt", + value: newSalt, + }); + this._accountSalt = newSalt; + } } return { privKey, ...returnObject }; @@ -931,7 +932,6 @@ class ThresholdKey implements ITKey { id: "accountSalt", value: accountSalt, }); - await this._syncShareMetadata(); } catch (error) { this.tssTag = oldTag; throw error; diff --git a/packages/default/test/RefreshAndAccountIndex.js b/packages/default/test/RefreshAndAccountIndex.js index f732098d..f9b652f0 100644 --- a/packages/default/test/RefreshAndAccountIndex.js +++ b/packages/default/test/RefreshAndAccountIndex.js @@ -13,8 +13,8 @@ const metadataURL = getMetadataUrl(); // eslint-disable-next-line mocha/no-exports export const refreshAndAccountIndex = (customSP, manualSync, accountIndexBackwardCompatible) => { const mode = manualSync; - - describe("RefreshAndAccountIndex", function () { + const { useTSS } = customSP; + describe(`RefreshAndAccountIndex : useTss ${useTSS}, manualSync ${manualSync}, bcAccountIndex ${accountIndexBackwardCompatible}`, function () { it("#should be able to refresh tss shares", async function () { const sp = customSP; if (!sp.useTSS) this.skip(); @@ -160,36 +160,24 @@ export const refreshAndAccountIndex = (customSP, manualSync, accountIndexBackwar // 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); } }); });