Skip to content

Add TSS support to TKey#268

Closed
matthiasgeihs wants to merge 167 commits intov13from
feat/tss
Closed

Add TSS support to TKey#268
matthiasgeihs wants to merge 167 commits intov13from
feat/tss

Conversation

@matthiasgeihs
Copy link
Contributor

@matthiasgeihs matthiasgeihs commented Mar 27, 2024

This PR adds TSS support to TKey, deprecating tkey-mpc. (Much of the code is copied from there.)

  • Augments Metadata to optionally contain TSS related data fields.
  • Adds TKeyTSS, a wrapper around TKey that provides functionality relevant to TSS.
  • Adds TSSTorusServiceProvider, a wrapper around TorusServiceProvider that additionally provides functionality relevant to TSS. (This is mainly for reading TSS related node details. Alternatively, this could be integrated with the original TorusServiceProvider?)

A corresponding WIP PR that shows the integration of this Module within MPC Core Kit is available at the MPC Core Kit repository: Web3Auth/mpc-core-kit#105.

metalurgical and others added 30 commits February 8, 2024 06:35
feat: update generatePrivate in Core
feat: Update Point in common-types to be curve independant
refactor: propagate KeyType through core and serviceprovider
feat: enable core tests secp256k1
…ivate

feat: replace eccryptro's generatePrivate
@matthiasgeihs
Copy link
Contributor Author

@ieow addressed comments and rebased.

Also changed the constructor to not require tssKeyType, using keyType as default.

There is one weird thing: For one account (importedusersecp256k1ed25519@example.com), the key reconstruction doesn't work reliably. I think depending on which servers are selected, it sometimes fails. It also prints share decryption Error: bad MAC after trying padded in these cases. (The error does go away if I change the account name to something different.) I think this may point to an error in the key assignment protocol? 🤷‍♂️

@matthiasgeihs
Copy link
Contributor Author

I couldn't figure out the issue with this one specific user. Maybe the user was initialized incorrectly and is bugged. To resolve this, I simply changed the user schema and now the tests work fine.

(The MAC error seems to be unrelated and is because torus.js in some cases pads the ciphertext, and therefore the MAC integrity check fails.)

I think this may be ready for merge? @ieow @himanshuchawla009

"typescript": "^5.2.2"
},
"optionalDependencies": {
"@nx/nx-linux-x64-gnu": "16.10.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

why this is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nrwl/nx#17767 (comment)

After rebuilding the package-lock, this issue came up. This is apparently the common way to solve this.


verifierId?: string;

sssNodeDetails: {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should move inlined interface to the type file also we should mark these class properties as private if they intend to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied this over from tkey-mpc. Actually, sssNodeDetails is not being used anywhere, so I removed it.

The properties are public somewhat intentionally (e.g., like custom auth also exposes the torus instance).

* Initializes this service provider instance. If `tssKeyType` is not
* provided, it defaults to the value of `keyType`.
*/
constructor(args: TorusServiceProviderArgs & { enableOneKey?: boolean; tssKeyType?: KeyType }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should just name it keyType for consistency

Copy link
Contributor Author

@matthiasgeihs matthiasgeihs May 2, 2024

Choose a reason for hiding this comment

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

TorusServiceProviderArgs already includes a variable keyType. tssKeyType is optional and is only there for the case, where you want keyType and tssKeyType be different. See the constructor comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

which should never be the case, as we discussed... we can use any key type internally but for a user facing interface it should be one type.

super(args);
const { customAuthArgs, enableOneKey, tssKeyType } = args;
this.tssKeyType = tssKeyType || this.keyType;
this.tssTorus = new TorusUtils({
Copy link
Contributor

Choose a reason for hiding this comment

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

why we need tssTorus in this class, cant we use parent torus class from customAuth instance available in parent class ?

Copy link
Contributor Author

@matthiasgeihs matthiasgeihs May 2, 2024

Choose a reason for hiding this comment

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

This is for the case where tssKeyType is different than keyType. We still support this. It would be actually quite a bit of work to remove this separation now. Although the default is to not specify tssKeyType and in this case it will just default to keyType, as described above.

Copy link
Contributor

@himanshuchawla009 himanshuchawla009 May 3, 2024

Choose a reason for hiding this comment

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

if tssKeyType is optional and doesnt have much real usecase significance we should just remove it. We can add it later if any usecases arises. It looks like a overkill scenario as of now, might make code a very difficult to maintain. We should just follow one rule:- Shares and finalKeys should be on keyType, metadata ops and keys should be on secp256k1.

@himanshuchawla009
Copy link
Contributor

already merged

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