Not able to generate MPC key and add asset

Steps Followed

  • Created an device id using crypto.randomUUID()

  • Assigning wallet to that device

Exposed an API on backend and called the same from frontend using the device id generated, it creates a wallet and wallet accountID.

  • Instantiate fireblocks ncw connection from frontend to backend

Created event handlers, message handlers and instantiated a connection from frontend to backend for a device.
It calls rpc api exposed on backend with success.

  • Generate MPC keys

Set an algorithm MPC_CMP_ECDSA_SECP256K1 and call generateMpcKeys from the created instance.

It communicates to backend via connection created through exposed rpc API.

First - It requests backend via rpc API method - request_mpc_setup
this return with success response -
result: {
status: { MPC_CMP_ECDSA_SECP256K1: ‘62a58619-67c5-4f3d-9030-612f180904d3’ }

In the event handler too (for → key_descriptor_changed)
It gives key status as keyStatus : “SETUP”

Second - It requests backend via rpc API method - poll_mpc_msg
this too returns rpc response with success -

result: {
id: ‘5ff21c5aef0cbe81248c38b49e51c6977f5250416bddfb3f7fcc06e8bd1ecf75’,
rawMessage: ,
iat: 1713199762,

But, Here in event handler it gives error -
In the event handler too (for → key_descriptor_changed)
It gives key status as keyStatus : “ERROR”

And overall in mpc key generation process it gives an error -

Error: CosignerStorage is already in process

We are not able to get past this and do mpc key generation with success.

Hey @vivek , two points:

  1. Did you copy the storage implementation from the demo?
  2. Can you clear the storage and try again, using a new deviceId?

Yeah, @janlev
I copied the complete storage implementation from the demo.

And i am clearing the storage using clearAllStorage() provided by IFireblocksNCW

In Continuation to resolve this I tried another approach based on some further research on docs -

Link → Which says the event handler is optional.

Hence, i commented out the event handler part. And again tried to generate mpc keys.

And got error this error -

{message: ‘Certificate is not trusted.’, error: ‘forge.pki.UnknownCertificateAuthority’}

Please let me know what i might be doing wrong.

Also in the frontend constantly getting the below error
error ReferenceError: document is not defined

@vivek can you verify both backend and frontend are configured to Sandbox environments?
If you’re running our own web demo, the .env file should have:

Yeah, @janlev I am using sandbox env for both backend and frontend.

Just saw that sandbox enviornment has expired. I think that might be the reason why i am getting the mentioned error.