Conversation
integrate multicurve tkey tests passed
fix tests add multicurve tests
| "@tkey/common-types": "file:../tkey/packages/common-types", | ||
| "@tkey/core": "file:../tkey/packages/core/tkey-core-15.2.1-alpha.0.tgz", | ||
| "@tkey/share-serialization": "^15.1.0", | ||
| "@tkey/storage-layer-torus": "^15.1.0", | ||
| "@tkey/tss": "^15.1.0", | ||
| "@tkey/storage-layer-torus": "file:../tkey/packages/storage-layer-torus/tkey-storage-layer-torus-15.2.1-alpha.0.tgz", | ||
| "@tkey/tss": "file:../tkey/packages/tss/tkey-tss-15.2.1-alpha.0.tgz", |
| "@toruslabs/openlogin-utils": "^8.2.1", | ||
| "@toruslabs/torus.js": "15.2.0-alpha.0", | ||
| "@toruslabs/session-manager": "^3.1.0", | ||
| "@toruslabs/torus.js": "file:../torus.js/toruslabs-torus.js-15.1.1.tgz", |
| // console.log(coreKitInstance.tKey.metadata) | ||
| // console.log(coreKitInstance.state); |
matthiasgeihs
left a comment
There was a problem hiding this comment.
as mentioned in the other PR, I think it would be better to merge the refactors into this one here, before we do further reviews.
also, i think it would be great to have an intro session with @ieow and the reviewers to get an overview of the changes, since all changes together make for a relatively large PR.
| /** | ||
| * @defaultValue `false` | ||
| * Set this flag to true to use the legacy flag for signing | ||
| * legacy flag do not support multicurve mode | ||
| * legacy ed25519 customAuth is only supported in legacy mode | ||
| * Note: This option is set to false by default. | ||
| */ |
There was a problem hiding this comment.
| /** | |
| * @defaultValue `false` | |
| * Set this flag to true to use the legacy flag for signing | |
| * legacy flag do not support multicurve mode | |
| * legacy ed25519 customAuth is only supported in legacy mode | |
| * Note: This option is set to false by default. | |
| */ | |
| /** | |
| * @defaultValue `false` | |
| * Set this flag to true to use the legacy mode. | |
| * Legacy mode does not support multi-curve. | |
| * CustomAuth with key type ed25519 is only supported in legacy mode. | |
| * Note: This option is set to false by default. | |
| */ |
I like that this has a comment, but it's a bit raw. could add some punctuation and revise language.
| public setTkeyType(tkeyType: KeyType) { | ||
| // check tkeyType is supported by tssLib | ||
| if (!this.supportedCurveKeyTypes.has(tkeyType)) throw CoreError.default("KeyType not supported, please provide valid tssLib"); | ||
| this._keyType = tkeyType; | ||
| } |
There was a problem hiding this comment.
You don't need this. Key type can be derived from sig type.
| } | ||
| ): Promise<Buffer> { | ||
| this.wasmLib = await this.loadTssWasm(); | ||
| // this.wasmLib = await this.loadTssWasm(); |
| const tkeyDetails = this.tKey.getKeyDetails(); | ||
| const tssPubKey = this.state.tssPubKey ? Point.fromSEC1(this.tkey.tssCurve, this.state.tssPubKey.toString("hex")) : undefined; | ||
| const tssCurve = getKeyCurve(this.keyType); | ||
| // TODO: fix me, should remove tssPubKey from state |
| // private async importTssKey(tssKey: string, factorPub: Point, newTSSIndex: TssShareType = TssShareType.DEVICE): Promise<void> { | ||
| // if (!this.state.signatures) { | ||
| // throw CoreKitError.signaturesNotPresent("Signatures not present in state when importing tss key."); | ||
| // } | ||
|
|
||
| await this.tKey.importTssKey( | ||
| { tag: this.tKey.tssTag, importKey: Buffer.from(tssKey, "hex"), factorPub, newTSSIndex }, | ||
| { authSignatures: this.state.signatures } | ||
| ); | ||
| } | ||
| // const keyType = this._keyType | ||
| // await this.tKey.importTssKey( | ||
| // { tssTag: this.tKey.tssTag, importKey: Buffer.from(tssKey, "hex"), factorPubs: [factorPub], newTSSIndexes: [newTSSIndex], tssKeyType: keyType }, | ||
| // { authSignatures: this.state.signatures } | ||
| // ); | ||
| // } |
| await coreKitInstance.tKey.getTSSShare(new BN(factorkey.factorKey, "hex"), { | ||
| accountIndex, | ||
| }); | ||
| await coreKitInstance.getTssShare(new BN(factorkey.factorKey, "hex") ,accountIndex); |
There was a problem hiding this comment.
nit: formatting ,accountIndex
| } | ||
| }); | ||
|
|
||
| console.log(coreKitInstance.keyType) |
There was a problem hiding this comment.
console log to be removed
|
|
||
|
|
||
| const recoverFactor = await instance.enableMFA({}) | ||
| console.log(recoverFactor); |
There was a problem hiding this comment.
console log to be removed
| import { AsyncMemoryStorage, criticalResetAccount, mockLogin } from "./setup"; | ||
| import { getKeyCurve } from "@toruslabs/torus.js"; | ||
| import { randomId } from "@toruslabs/customauth"; | ||
| import log from "loglevel"; |
| storage?: IAsyncStorage | IStorage; | ||
| email: string; | ||
| tssLib?: TssLibType; | ||
| resetAccount? : false |
| async function beforeTest() { | ||
| if (testVariable.resetAccount === false) { | ||
| log.debug("skipping reset account"); | ||
| return ; |
| if (!kit.supportsAccountIndex) { | ||
| indices = indices.filter((i) => i === 0); | ||
| } | ||
| const tssCurve = getKeyCurve(kit.keyType) |
| instance.setSigType("ed25519") | ||
| instance.setTkeyType(KeyType.ed25519) | ||
| const result3 = await instance.sign(Buffer.from(message), { hashed: false }) | ||
| const valided25519 = ed25519.verify(bytesToHex(result3), bytesToHex(Buffer.from(message)), bytesToHex( new Uint8Array(instance.getPubKeyEd25519()) ) ) |
|
adding this comment to highlight the formatting issues as there are too many of them to be mentioned individually |
| // check tkeyType is supported by tssLib | ||
| if (!this.supportedSigTypes.has(sigType)) throw CoreError.default("SigType not supported, please provide valid tssLib"); | ||
| this._sigType = sigType; | ||
| } |
There was a problem hiding this comment.
keyType should be updated with sigType for consistency
| if (this.options.legacyFlag) { | ||
| // Check for existing curve in tssData for legacy mode | ||
| const tssData = this.getTssData({ skipThrow: true }); | ||
| if (!tssData) throw CoreKitError.default("Legacy mode only support single curve, please congfiure with correct keyType"); |
There was a problem hiding this comment.
shouldn't we also check for tssData's existence in non-legacy mode?
| if (this.options.legacyFlag) { | ||
| // Check for existing curve in tssData for legacy mode | ||
| const tssData = this.getTssData({ skipThrow: true }); | ||
| if (!tssData) throw CoreKitError.default("Legacy mode only support single curve, please congfiure with correct keyType"); |
There was a problem hiding this comment.
shouldn't we check for tssData's existence in non-legacy mode?
| this.supportedSigTypes.add(tssLibItem.sigType as SigType); | ||
| }); | ||
| this._keyType = options.tssLibs[0].keyType as KeyType; | ||
| this._sigType = options.tssLibs[0].sigType as SigType; |
There was a problem hiding this comment.
why are these only storing a single key type and sig type?
|
Sorry for the confusion. |
integrate multicurve tkey
tests passed
Motivation and Context
Jira Link:
Description
How has this been tested?
Screenshots (if appropriate):
Types of changes
Checklist: