Generate MPC Keys Issue With IOS Sdk

I’m not setting up any certificate to generate MPCKeys through Fireblocks SDK, but I’m still getting a certificate error on my RPC message while I’m trying to generate MPCKeys.

Getting Certificate Error while trying to generatingMPCkeys using iOS Fireblocks sdk
generatingMPCKey response,I received a log stating “generateMPCKeys continuation completed,” but the status still shows as false in the RPC message.

The steps I have already attempted are:

  1. GenerateDeviceid
  2. create a wallet (Sending a device ID request and retrieving the wallet ID from the response.)
    3.Initializing the SDK :
    a.deviceid
    b.message handler (handleoutgoingmessage getting RPC Message as payload.)
    c.keystorage
    d.Event handler

4.GenerateMPCKey (Sending a device ID request and retrieving the “generateMPCKeys continuation completed” from the response.)
but the status still shows as false in the RPC message.

What am I missing here?

Error Log -

{"method":"report_event","headers":{"platformType":"iOS","sdkVersion":"2.7.0","mpcVersion":"6","physicalDeviceId":"31e98120-ccc1-4015-8b37-09defee76067"},"params":[{"type":"FailedToDownloadCertificate_","stacktraces":[],"metadata":{"deviceId":"7c768ba6-3aba-4465-9ffd-5b559e1ce6c7","timezone":"IST","device":"arm64","iosVersion":"17.4","environment":"sandbox","hasCMPKey":false,"onboardedRecovery":false,"completedMPC":false,"uptime":"timeval(tv_sec: 1723092797, tv_usec: 586250)","previousEvents":["2024-08-08T11:11:33.168+05:30"]},"logs":[{"level":"INFO","message":"Report for FailedToDownloadCertificate_ is not allowed. Last report was sent at 2024-08-08 05:41:33 +0000 and next report will be allowed at 2024-08-08 06:41:33 +0000","isoTimestamp":"2024-08-08T05:41:33.168Z"},{"level":"INFO","message":"Did send event: keyId: , algorithm: MPC_EDDSA_ED25519, keyStatus: ERROR. Error: Failed to download certificates - code: 101). - runningMethod: not defined","isoTimestamp":"2024-08-08T05:41:33.166Z"},{"message":"Did send event: keyId: , algorithm: MPC_ECDSA_SECP256K1, keyStatus: ERROR. Error: Failed to download certificates - code: 101). - runningMethod: not defined","isoTimestamp":"2024-08-08T05:41:33.163Z","level":"INFO"},{"isoTimestamp":"2024-08-08T05:41:33.161Z","level":"ERROR","message":"Unexpected error"},{"message":"Networking Error","isoTimestamp":"2024-08-08T05:41:33.161Z","level":"ERROR"},{"level":"ERROR","isoTimestamp":"2024-08-08T05:41:33.161Z","message":"Error in get_service_certificates - FireblocksError(message: \"The data couldn’t be read because it isn’t in the correct format.\", code: 100, reportKey: \"The data couldn’t be read because it isn’t in the correct format.\")"},{"isoTimestamp":"2024-08-08T05:41:33.160Z","message":"OutgoingManager did reach maximum retries - get_cloud_cosigner_certificate","level":"INFO"},{"message":"MEASURE - get_cloud_cosigner_certificate ended","isoTimestamp":"2024-08-08T05:41:33.159Z","level":"ERROR"},{"isoTimestamp":"2024-08-08T05:41:33.159Z","message":"Networking Error","level":"ERROR"},{"isoTimestamp":"2024-08-08T05:41:33.159Z","message":"OutgoingManager did reach maximum retries - get_service_certificates","level":"INFO"},{"message":"MEASURE - get_service_certificates ended","isoTimestamp":"2024-08-08T05:41:33.158Z","level":"ERROR"},{"message":"get_cloud_cosigner_certificate","isoTimestamp":"2024-08-08T05:41:33.156Z","level":"INFO"},{"level":"INFO","isoTimestamp":"2024-08-08T05:41:33.155Z","message":"FireblocksSDK.UpgradeCloudCosignerPlayerCertificateStep - run upgrade on version: 2.7.0"},{"level":"INFO","isoTimestamp":"2024-08-08T05:41:33.155Z","message":"get_service_certificates"},{"level":"INFO","isoTimestamp":"2024-08-08T05:41:33.153Z","message":"FireblocksSDK.UpgradeClientVersionStep - skip upgrade on version: 2.7.0"},{"level":"INFO","isoTimestamp":"2024-08-08T05:41:33.153Z","message":"Step Succeeded: PRE_REGISTER"},{"message":"Error in get_service_certificates - FireblocksError(message: \"The data couldn’t be read because it isn’t in the correct format.\", code: 100, reportKey: \"The data couldn’t be read because it isn’t in the correct format.\")","level":"ERROR","isoTimestamp":"2024-08-08T05:41:33.148Z"},{"isoTimestamp":"2024-08-08T05:41:33.145Z","level":"ERROR","message":"Networking Error"},{"message":"OutgoingManager did reach maximum retries - get_service_certificates","isoTimestamp":"2024-08-08T05:41:33.145Z","level":"INFO"},{"message":"Did send event: keyId: , algorithm: MPC_EDDSA_ED25519, keyStatus: INITIATED. Error: ). - runningMethod: GENERATE_MPC_KEYS","level":"INFO","isoTimestamp":"2024-08-08T05:41:33.144Z"},{"message":"MEASURE - get_service_certificates ended","level":"ERROR","isoTimestamp":"2024-08-08T05:41:33.144Z"},{"isoTimestamp":"2024-08-08T05:41:33.141Z","level":"INFO","message":"Did send event: keyId: , algorithm: MPC_ECDSA_SECP256K1, keyStatus: INITIATED. Error: ). - runningMethod: GENERATE_MPC_KEYS"},{"level":"INFO","isoTimestamp":"2024-08-08T05:41:33.139Z","message":"get_service_certificates"},{"level":"INFO","message":"starting flow:

ONBOARDING_REPO","isoTimestamp":"2024-08-08T05:41:33.138Z"},{"level":"INFO","message":"FireblocksSDK.DownloadServiceCertificateUpgradeStep - run upgrade on version: 2.7.0","isoTimestamp":"2024-08-08T05:41:33.136Z"},{"message":"Environment: sandbox","isoTimestamp":"2024-08-08T05:41:33.130Z","level":"INFO"},{"isoTimestamp":"2024-08-08T05:41:33.129Z","level":"INFO","message":"### App Details ###\nDevice: arm64\niOS version: 17.4\n######################"}],"level":"ERROR","code":101,"message":"Failed to download certificates"}]}```

Hi Tan
It appears you are generating MPC keys correctly, and there is an issue with the sandbox workspace that is causing the failed RPC calls.

Are you using the NCW Signer API user you created on the Sandbox to generateMPC?

Yeah , so the thing is for the KeyStorageProvider(deviceId: self.deviceId) i am doing this on a ios simulator so dont have biometrics in it, so i am directly saving it using
self.saveToKeychain(keys: keys, callback: callback)
.

 func store(keys: [String : Data], callback: @escaping ([String : Bool]) -> ()) {
       self.saveToKeychain(keys: keys, callback: callback)
       // AppLoggerManager.shared.logger()?.log("\n📣📣📣📣\ngenerateMpcKeys started store: \(Date()) - keys: \(keys.keys)\n📣📣📣📣")
        //biometricStatus { status in
           // if status == .ready {
            //    self.saveToKeychain(keys: keys, callback: callback)
            //} else {
            //    DispatchQueue.main.async {
              //      AppLoggerManager.shared.logger()?.log("\n📣📣📣📣\ngenerateMpcKeys started store: \(Date()) - biometric not ready\n📣📣📣📣")
              //      callback([:])
             //   }
          //  }
        //}

    }

I think it is not storing the keys correctly … so in the next step when i am doing sign tx for a pending signature tx it is simply giving me error

can you please guide on how to resolve this !

Ok this worked for biometric status

 #if targetEnvironment(simulator)
        status(.ready)
#else

Can you have this in docs too ?

Hi tan, yes I see that worked for biometric, in the docs Also we have a iOS demo app where you can see iOS code for how to initialize the iOS SDK and generate keys with proper storage handling for the keys in a live app GitHub - fireblocks/ncw-ios-demo