Failed to confirm keys in GENERATE_MPC_KEYS

When doing generateMpcKeys
Getting this error

{
    "method": "GENERATE_MPC_KEYS",
    "eventType": "FB.MPC.MPC_CMP_ECDSA_SECP256K1.ERROR",
    "eventMessage": "Failed to generate MPC keys, algorithm=MPC_CMP_ECDSA_SECP256K1 status=ERROR keyId=null"
}

and then it do API call completed {method: 'poll_key_confirmation'} and then result into this error

{
    "error": {
        "_key": "FAILED_TO_CONFIRM_KEY"
    }
    at ZA._waitForKeyConfirmation (http://localhost:3002/node_modules
}

After which the key status for it is marked as error
{algorithm: 'MPC_CMP_EDDSA_ED25519', keyId: null, keyStatus: 'ERROR'}

Also in the process of mpc generation this logs multiple time for some reason

Failed to generate MPC keys: Error: Fireblocks API returned an error: Unsuported operation

{
    "method": "stop_mpc_key_setup",
    "error": {
        "message": "Unsuported operation",
        "code": -1
    }
}

{method: 'GENERATE_MPC_KEYS', eventType: 'FB.API.stop_mpc_key_setup.-1', eventMessage: 'Fireblocks API returned an error: Unsuported operation'}

Due to this not able to generate the keys for the user and it just fails, can someone help on this issue

Hello @tan

There are a few things that need to be done before Generating MPC Keys. First, you must ensure you initialize the SDK if you are using the ncw-js SDK or iOS SDK.

Scroll down on this developer guide on initializing the SDK Initializing the SDK

If you have already done so, please tell me which SDK you are using so I can better help here.

Hey @Mohammed , Yup its already initialized , using the @fireblocks/ncw-js-sdk in react app

 const fireblocksNCW = await FireblocksNCWFactory({
    env: "sandbox",
    logLevel: "INFO",
    deviceId,
    messagesHandler,
    eventsHandler,
    secureStorageProvider,
    logger,
  });

SDK initialized: oB {_fireblocksNCW: cB, _telemetryManager: iB}

So after the sdk is initialized successfully i am simply doing this

const ALGORITHMS = new Set<TMPCAlgorithm>([
          //
          "MPC_CMP_ECDSA_SECP256K1",
          "MPC_CMP_EDDSA_ED25519",
        ]);
await sdk.generateMPCKeys(ALGORITHMS);

in the process of generateMPCKeys i am getting the above err.

Also if i reload the page and do the generateMpcKeys again then

{
    "method": "get_all_keys"
}

it does a get all keys and on the next step it does a stop_mpc_key_setup which also results in an error

{method: 'GENERATE_MPC_KEYS', eventType: 'FB.API.stop_mpc_key_setup.-1', eventMessage: 'Fireblocks API returned an error: Unsuported operation'}

But the thing is mpc keys never were saved on user device or in this case generated … so why stop mpc key setup also ?

These are the logs when generateMPCKeys is called … don’t understand why this stop_mpc_key_setup is called just after getting MPC setup already in progress and then it throws that Unsupported Operation for stop_mpc_key_setup

and then after these calls i also do status update using
keysStatus?.MPC_CMP_ECDSA_SECP256K1?.keyStatus

Where keyStatus i get from the eventHandler

case "key_descriptor_changed":
          updateKeysStatus((prevKeysStatus) => ({
            ...prevKeysStatus,
            [event.keyDescriptor.algorithm]: event.keyDescriptor,
          }));
          console.log("Key descriptor changed:", event.keyDescriptor);
          break;

So keystatus goes to 73% i.e SETUP_COMPLETE status but then later on it fails and never becomes READY status , as shown in the below log it throws an error again

"level": "ERROR", "message": "MPCSetupManager _handleMessage crashed", "isoTimestamp": "2024-08-01T22:38:55.703Z", "metadata": { "error": { "stack": "Error: Failed to confirm keys\n at ZA._waitForKeyConfirmation (http://localhost:3002/node_modules/.vite/deps/@fireblocks_ncw-js-sdk.js?v=02ccaa39:8902:40)

Thank you for sharing this info, I want to check if you are on latest version of the ncw js SDK(v12.4.1). This error could be related to how state is being managed on the front-end

I recommend taking a look at the code examples on how to complete the setup with a react demo

Here is the code for the backend GitHub - fireblocks/ncw-backend-demo: Fireblocks Non custodial wallet demo backend
Here is the live link to the webapp Fireblocks Js cosigner

It is possible that your workspace is not configured to support this algorithm. Can you share the name of the Workspace so I can check on that?

Got this one fixed @Mohammed , thanks for the help though :raised_hands:

1 Like

Awesome! Do you mind sharing how you resolved this/what was the issue?

Updated the sdks to latest versions … and the function to call the mpc generateKey was doing it 2 times instead of one … so on the second call i think the sdk is trying to stop_mpc_key_setup which resulted in that Unsuported operation (i think sdk should handle that function also) and thats why whole key generation process was failing

Hi, so upgrading to latest version solved the issue?
What are the first digits/letters of the API key you used for this action?