Issue with tKey share generation and device share retrieval

I’m using @tkey/default v12.0.0, and testing on Firefox v102.8.0

After performing

await (tKey.serviceProvider as TorusServiceProvider).init({
            skipSw: true,
            skipPrefetch: true,
 })

and

await tKey.initialize()

after the triggerLogin flow (as per the tkey-redirect-flow-example in github).

Here, I am facing an issue of 2 kinds:

  1. when i sign in freshly (no shares have been generated prior and requiredShares value from tKey.getKeyDetails() is 0), then without using tKey.updateSDK() i cannot generate the device share (due to error 1103 “Metadata not found, SDK likely not initialized”)

  2. After a device share is generated and stored on the browser localStorage, signing in next time fails without updateSDK() call (as the requiredShare value is 1 but the share was not stored on the device, as the generateShare() call in step 1 fails).

  3. If I use updateSDK when freshly signing in, then the device share is generated and written to localStorage but next time I login (and requiredShares shows 1), the share in the localStorage is not being detected by tKey.

Please help. Thank you in advance.

@madhav Welcome Aboard!

Your issue has been forwarded to our Dev team and we will get back with further updates.

Could you share your tkey instantiation code and how you input and reconstruct the tkey ?

The example code works fine for me.
Did you try out the example code and does it works for you?

Yes, the example code is working for me, and i really need help understanding the difference in the flow between the example and my codebase, which i have attached in 5 screenshots:

web3auth_1




I’ve removed the clientId (both of google and web3auth’s) for the screenshot.
Note that i have never been able to achieve the log “Recovered share input successfully” as getDeviceShare() (this function is exactly as the one in the example) throws an error, with or without the updateSDK() logic.

The error is “could not find metadata, sdk likely not initialized” if the share was generated when requiredShares was 0 and “Device share not found” if the share was generated after updateSDK() when requiredShares was 0.

Both these errors happen in the case when requiredShares is 1. The private key generation happens perfectly when requiredShares is 0.

Hi @cherngwoei. Thank you so much for helping me put my question with more detail.

I’m still facing the error, I’ve just been scratching my head figuring out the bug I’ve made.

Please do let me know if any more detail is required.

Thank you in advance.