Skip to content

Commit

Permalink
fix: edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
guru-web3 committed Feb 7, 2024
1 parent cea9d89 commit 454e164
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ThresholdKey implements ITKey {
if (!chainCode) {
throw CoreError.default("chainCode is absent, required for nonce generation");
}
return new BN(keccak256(Buffer.from(`${index}${chainCode}`)).slice(2), "hex").umod(ecCurve.curve.n);
return index && index > 0 ? new BN(keccak256(Buffer.from(`${index}${chainCode}`)).slice(2), "hex").umod(ecCurve.curve.n) : new BN(0);
}

generateSalt(length = 32) {
Expand Down Expand Up @@ -913,12 +913,15 @@ class ThresholdKey implements ITKey {
serverEncs: refreshResponse.serverFactorEncs,
};
}
const chainCode = this.generateSalt();

this.metadata.addTSSData({
tssTag: this.tssTag,
tssNonce: newTssNonce,
tssPolyCommits: newTSSCommits,
factorPubs,
factorEncs,
chainCode,
});
await this._syncShareMetadata();
} catch (error) {
Expand Down

0 comments on commit 454e164

Please sign in to comment.