-
Notifications
You must be signed in to change notification settings - Fork 10
feat: refactor multicurve #217
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
base: v4
Are you sure you want to change the base?
Conversation
integrate multicurve tkey tests passed
fix tests add multicurve tests
src/interfaces.ts
Outdated
| // sign( | ||
| // data: Buffer, | ||
| // opts?: { | ||
| // hashed?: boolean; | ||
| // secp256k1Precompute?: Secp256k1PrecomputedClient; | ||
| // keyTweak?: BN; | ||
| // } | ||
| // ): Promise<Buffer>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not needed.
why does the core kit interface no longer have a sign method? isn't this the most important method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update with relevant function signatures and comments
src/mpcCoreKit.ts
Outdated
|
|
||
| public getTssData(args: { skipThrow: boolean; keyType?: KeyType } = { skipThrow: false }) { | ||
| const result = this.tkey.metadata.getTssData(args.keyType ?? this.keyType, TSS_TAG_DEFAULT); | ||
| public getTssData(args: { skipThrow?: boolean; keyType: KeyType }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this skipThrow flag looks super odd. if you want to skip an error, just catch and discard!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break the function to 2 functions for more clearity
src/mpcCoreKit.ts
Outdated
| if (this._sigType === "ed25519" && this.options.useDKG) { | ||
| throw CoreKitError.invalidConfig("DKG is not supported for ed25519 signature type"); | ||
| } | ||
| const nodeDetails = fetchLocalConfig(this.options.web3AuthNetwork, KeyType.ed25519); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you fix the key type to ed25519?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the nodedetails variables is used to get the metadata url.
It does not matter which keyType is used to get the node details.
We can replace with the spKeyType for consistency
src/mpcCoreKit.ts
Outdated
| if (this.supportedCurveKeyTypes.has(KeyType.ed25519)) { | ||
| const importTssBufEd25519 = importTssKey.ed25519 ? Buffer.from(importTssKey.ed25519, "hex") : undefined; | ||
| // check if key is in the tsslib and keytype exists | ||
| await this.tKey.initializeTss({ | ||
| importKey: importTssBufEd25519, | ||
| tssKeyType: KeyType.ed25519, | ||
| serverOpts: { | ||
| // selectedServers: [], | ||
| authSignatures: this.state.signatures, | ||
| }, | ||
| }); | ||
| } | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hu? why do you duplicate this part from below and nest it here? just move the below part out of the else and condition it like here!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is different for initialising first curve and 2nd curve.
during initializing 2nd curve, factorPub, and tssIndex are not allowed to be provided,
updating the logic and comment for easier reading
| private async copyOrCreateShare(newFactorTSSIndex: number, newFactorPub: Point) { | ||
| this.checkReady(); | ||
| const tssData = this.getTssData(); | ||
| const firstKeyType = this.getSupportedCurveKeyTypes()[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you use this a lot, I think you should create a dedicated function for it.
What's the logic behind always using the first key type here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I are trying to get tssIndex from getTssShare or factorPub from getTssData.
both curves should have the same tssIndex (for same factorKey) and factorPub
Using either curve's keyType will get the same value.
using the first as instance might configured with single curve keytype only
|
|
||
| const { tssIndex } = await this.getTssShare(factorKey); | ||
| const firstKeyType = this.getSupportedCurveKeyTypes()[0]; | ||
| const { tssIndex } = await this.getTssShare({ keyType: firstKeyType, factorkey: factorKey }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this wrong? What if you want to get the ed25519 share but first key type is secp256k1? Same applies to several other instances of first key type usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I are trying to get tssIndex from getTssShare or factorPub from getTssData.
both curves should have the same tssIndex (for same factorKey) and factorPub
Using either curve's keyType will get the same value.
using the first as instance might configured with single curve keytype only
|
i think it would be good to merge this into the multi curve branch and then review together. why are the two PRs separated? @ieow |
…TssTag feat: refactor setTssTag
remove unsed code and comment update new user comments and flow update comment
rename function name
The first pr is initial solution using setTkeyType to set active keyType Recent added new pr is support tkey's pr which add back the setTssTag instead of passing tag to most of the tkey tss function since the prs is merged in tkey side, mpc-corekit prs is also merged now there is only single pr in mpc core kit and tkey tss |
fix ed25519 with accountIndex 0 fix useClientGeneratedTSSKey fix typo
fix multicurve test to use new storage instance fix useClientGeneratedTSSKey bug
Motivation and Context
Jira Link:
In this pr, the mpc corekit will be keyTypes and sigType agnostic.
it will throw error only during signing if the required keyTypes and tssLib is not available.
all keyTypes for
check the added new tests on how it can be call for different signing scheme
Description
Refactor multicurve
How has this been tested?
Screenshots (if appropriate):
Types of changes
Checklist: