Web3Auth / mpc-core-kit

15 stars 4 forks source link

[v3] enableMFA throws error #145

Closed AyushBherwani1998 closed 1 month ago

AyushBherwani1998 commented 1 month ago

Description

enableMFA throws an error for both cases where we pass EnableMFAParams, or skip it.

await coreKitInstance.enableMFA({});
const factorKey = new BN(newFactorKeyHex, "hex");
await coreKitInstance.enableMFA({factorKey});

Error

{
"name": "CoreKitError",
"code": 1000,
"message": "undefined undefined error creating factor: tssShare.toBuffer is not a function"
}

Console log

TypeError: tssShare.toBuffer is not a function
    at TKeyTSS.addFactorPub (tss.esm.js:749:80)
    at async Web3AuthMPCCoreKit.copyOrCreateShare (mpcCoreKit.esm.js:1836:5)
    at async mpcCoreKit.esm.js:1385:7
    at async Web3AuthMPCCoreKit.atomicSync (mpcCoreKit.esm.js:1574:17)
    at async mpcCoreKit.esm.js:1332:38
    at async Web3AuthMPCCoreKit.atomicSync (mpcCoreKit.esm.js:1574:17)
    at async Proxy.enableMFA (Home.vue:227:9)
matthiasgeihs commented 1 month ago

reproducible using https://github.com/Web3Auth/web3auth-core-kit-examples/tree/mpc-core-kit-v3/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start

matthiasgeihs commented 1 month ago

The issue is that the BN object tssShare does not have the toBuffer function in this context. I think we may only assume this function to be available on Node.js. The solution is to use toArrayLike(Buffer, ...). Will need to update tkey for that.

matthiasgeihs commented 1 month ago

https://github.com/tkey/tkey/pull/279 should solve the issue

AyushBherwani1998 commented 1 month ago

Works fine in v3-alpha2 version.

matthiasgeihs commented 1 month ago

Resolved in #147