Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: soft nonce implementation #6

Merged
merged 23 commits into from
Feb 23, 2024
Merged

feat: soft nonce implementation #6

merged 23 commits into from
Feb 23, 2024

Conversation

guru-web3
Copy link

No description provided.

packages/core/src/core.ts Outdated Show resolved Hide resolved
if (tssNonce !== undefined) this.tssNonces[tssTag] = tssNonce;
if (tssPolyCommits) this.tssPolyCommits[tssTag] = tssPolyCommits;
if (factorPubs) this.factorPubs[tssTag] = factorPubs;
if (factorEncs) this.factorEncs[tssTag] = factorEncs;
if (chainCode && !this.chainCode) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@himanshuchawla009 , Should we throw when chainCode exist and we try to update the chainCode?
or just ignore the update

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So chainCode should be once generated and saved , it should not be updated. But we shouldnt throw error as well, so error should be ignored.

packages/default/test/shared.js Outdated Show resolved Hide resolved
packages/core/src/core.ts Outdated Show resolved Hide resolved
packages/core/src/core.ts Outdated Show resolved Hide resolved
packages/core/src/core.ts Outdated Show resolved Hide resolved
packages/core/src/core.ts Outdated Show resolved Hide resolved
packages/core/src/core.ts Outdated Show resolved Hide resolved
packages/core/src/core.ts Outdated Show resolved Hide resolved
// we need to add the pub key nonce to the tssPub
const noncePub = ecCurve.keyFromPrivate(nonce.toString("hex")).getPublic();
const pubKeyPoint = ecCurve
.keyFromPublic({ x: this.getTSSCommits()[0].x.toString("hex"), y: this.getTSSCommits()[0].y.toString("hex") })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup this code, calculate "this.getTSSCommits()" once and use it , rather thn calling it everytime

if (tssNonce !== undefined) this.tssNonces[tssTag] = tssNonce;
if (tssPolyCommits) this.tssPolyCommits[tssTag] = tssPolyCommits;
if (factorPubs) this.factorPubs[tssTag] = factorPubs;
if (factorEncs) this.factorEncs[tssTag] = factorEncs;
if (chainCode && !this.chainCode) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So chainCode should be once generated and saved , it should not be updated. But we shouldnt throw error as well, so error should be ignored.

packages/core/package.json Outdated Show resolved Hide resolved
Copy link

@himanshuchawla009 himanshuchawla009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm


private async computeAccountNonce(index: number) {
// generation should occur during tkey.init, fails if accountSalt is absent
this._accountSalt = this._accountSalt || (await this.getTKeyStoreItem(TSS_MODULE, "accountSalt")).value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should getTkeyStore during reconstruct and assign to the accountSalt ( only get from tkey store if the accountSalt is undefined )

  • this will keep this function as sync function

// we need to add the pub key nonce to the tssPub
const noncePub = ecCurve.keyFromPrivate(nonce.toString("hex")).getPublic();
const pubKeyPoint = ecCurve.keyFromPublic({ x: tssCommits[0].x.toString("hex"), y: tssCommits[0].y.toString("hex") }).getPublic();
const dervicepubKeyPoint = pubKeyPoint.add(noncePub);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo derivedPubKeyPoint

@@ -186,6 +186,7 @@ class Metadata implements IMetadata {
tssNonce?: number;
tssPolyCommits?: Point[];
factorPubs?: Point[];
accountIndex?: number;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed rite?

Copy link

@ieow ieow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ieow ieow merged commit b6c02fc into master Feb 23, 2024
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants