Web3Auth / mpc-core-kit

16 stars 4 forks source link

Few Developer Experience Enhancements #178

Open yashovardhan opened 1 month ago

yashovardhan commented 1 month ago

A couple of minor changes that will help our MPC Core Kit Integration:

  1. Can we expose Point & secp256k1 from MPC Core Kit directly instead of fetching it from @tkey/common-types? It feels like an unnecessary addition just for using deleteShare function.

  2. Currently the WEB3AUTH_NETWORK object is like this

    export declare const WEB3AUTH_NETWORK: {
        readonly MAINNET: "sapphire_mainnet";
        readonly DEVNET: "sapphire_devnet";
    };

    This is inconsistent with our other SDKs and causes confusion. This was done earlier when sapphire was new in order to make sure people understand MPC only works with Sapphire networks. However it is quite well documented and the dashboard flow makes sure people make sapphire projects. In order to be consistent can we change it to:

    export declare const WEB3AUTH_NETWORK: {
        readonly SAPPHIRE_MAINNET: "sapphire_mainnet";
        readonly SAPPHIRE_DEVNET: "sapphire_devnet";
    };
  3. The deleteShare function currently has a lot of extra steps currently

    let factorPub: string | undefined;
        for (const [key, value] of Object.entries(coreKitInstance.getKeyDetails().shareDescriptions)) {
          if (value.length > 0) {
            const parsedData = JSON.parse(value[0]);
            if (parsedData.module === FactorKeyTypeShareDescription.SocialShare) {
              factorPub = key;
            }
          }
        }
    const pub = Point.fromSEC1(secp256k1, factorPub);
    await coreKitInstance.deleteFactor(pub);

    Can we make the process of grabbing a particular share with share description easy? Can getting a point be shifting directly within the deleteFactor function of the SDK? I'm thinking of something like:

    const factorPub = findFactorByShareDescription(FactorKeyTypeShareDescription.SocialShare) // should return an array of matching shares
    await coreKitInstance.deleteFactor(pub[0]);
  4. Additionally, can we have a listFactors function that grabs all the factors from share description and returns an object containing all the available shares?

ieow commented 1 month ago

@matthiasgeihs

matthiasgeihs commented 1 month ago

1.) Sure, nothing against this from my POV. Not sure if @himanshuchawla009 has an opinion?

2.) no problem with that either.

3.) sure, i think we can add such a function.

4.) you mean the secret shares? or the corresponding public keys? isn't that similar / the same as above? (maybe i don't get it)