Skip to content

Commit

Permalink
fix: remove syncMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Feb 23, 2024
1 parent 0d78a92 commit ee82873
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
24 changes: 12 additions & 12 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -931,7 +932,6 @@ class ThresholdKey implements ITKey {
id: "accountSalt",
value: accountSalt,
});
await this._syncShareMetadata();
} catch (error) {
this.tssTag = oldTag;
throw error;
Expand Down
16 changes: 2 additions & 14 deletions packages/default/test/RefreshAndAccountIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
});
});
Expand Down

0 comments on commit ee82873

Please sign in to comment.