> ## Documentation Index
> Fetch the complete documentation index at: https://cobo.com/developers/llms.txt
> Use this file to discover all available pages before exploring further.

# Recover private keys

> This operation recovers the full private keys for the specified addresses using recovery key shares imported via the [Import recovery key share](https://www.cobo.com/developers/v2/developer-tools/ucw-sdk/ucwrecoverkey-class/import-recovery-key-share) operation.

<Tip>
  Try [Cobo WaaS Skill](/v2/guides/overview/cobo-waas-skill) in your AI coding assistant (Claude Code, Cursor, etc.). Describe your needs in natural language to auto-generate production-ready SDK code and debug faster 🚀
</Tip>

<CodeGroup>
  ```Swift iOS theme={null}
  public func recoverPrivateKeys(addressInfos: [AddressInfo]) throws -> [PrivateKeyInfo]
  ```

  ```Dart Flutter theme={null}
  Future<List<PrivateKeyInfo>> recoverPrivateKeys(List<AddressInfo> addressInfos) async
  ```
</CodeGroup>

<RequestExample>
  ```Swift iOS theme={null}
  let addressInfos: [AddressInfo] = [
      AddressInfo(bip32Path: "m/44/1/1/0/0", pubKey: "xpub6FRrW2AzsDQcVQPNCCQgiB7xSQ9UseQfrRCJdD9qjWswrNBmY1MysLdMYxpWbB1mnGJTwLCZWCfA4ko2kQNN37CPSzidD1c9aZCBXjTzfQn")
      AddressInfo(bip32Path: "m/44/1/1/0/1", pubKey: "xpub6FRrW2AzsDQcZahYm2GgsDz7VtqgkvNwR58boDejvwSuCYZ2ZRVvqP6Gaqef6hMGxKtkvj3PfcRxagKSycuh6XX7kJ3Bzc2vUrEAA4at5Jc")
  ]

  do {
      let privateKeyInfos = try recoverKey?.recoverPrivateKeys(addressInfos: addressInfos)
      if let privateKeyInfos = privateKeyInfos {
          for privateKeyInfo in privateKeyInfos {
              print("Private Key Info: \(privateKeyInfo)")
          }
      } else {
          print("Failed to recover private keys.")
      }
  } catch {
      print("Error: \(error)")
  }
  ```

  ```Dart Flutter theme={null}
  final List<AddressInfo> addressInfos = [
      AddressInfo(
          bip32Path: "m/44/1/1/0/0",
          pubKey: "xpub6FRrW2AzsDQcVQPNCCQgiB7xSQ9UseQfrRCJdD9qjWswrNBmY1MysLdMYxpWbB1mnGJTwLCZWCfA4ko2kQNN37CPSzidD1c9aZCBXjTzfQn"
      ),
      AddressInfo(
          bip32Path: "m/44/1/1/0/1",
          pubKey: "xpub6FRrW2AzsDQcZahYm2GgsDz7VtqgkvNwR58boDejvwSuCYZ2ZRVvqP6Gaqef6hMGxKtkvj3PfcRxagKSycuh6XX7kJ3Bzc2vUrEAA4at5Jc"
      ),
  ];

  try {
      final privateKeyInfos = await recoverKey?.recoverPrivateKeys(addressInfos: addressInfos);
      for (final privateKeyInfo in privateKeyInfos) {
          print("Private Key Info: $privateKeyInfo");
      }
  } catch (error) {
      print("Error: $error");
  }
  ```
</RequestExample>

## Parameters

<ParamField path="addressInfos" type="object[]">
  A list of address information objects, each containing the BIP32 path and the optional root extended public key, required to recover the corresponding private keys.

  <Expandable title="child attributes">
    <ParamField path="bip32Path" type="string">
      The BIP32 path of the address.
      For example: `m/44/1/1/0/0`.
    </ParamField>

    <ParamField path="publicKey" type="string">
      The extended public key of the address. This parameter is optional and can be left empty. If provided, the derived public key will be compared against this value during the key derivation process. A mismatch will result in an error.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="privateKeyInfos" type="object[]">
  The list of objects containing the recovered private keys and their corresponding addresses.

  <Expandable title="child attributes">
    <ResponseField name="bip32Path" type="string">
      The BIP32 path for the address.
      For example: `m/44/1/1/0/0`.
    </ResponseField>

    <ResponseField name="publicKey" type="string">
      The extended public key for the address.
      For example: `xpub6FRrW2AzsDQcVQPNCCQgiB7xSQ9UseQfrRCJdD9qjWswrNBmY1MysLdMYxpWbB1mnGJTwLCZWCfA4ko2kQNN37CPSzidD1c9aZCBXjTzfQn`.
    </ResponseField>

    <ResponseField name="privateKey" type="object">
      Different formats of private keys corresponding to the address.

      <Expandable title="child attributes">
        <ResponseField name="extPrivateKey" type="string">
          The root extended private key.
        </ResponseField>

        <ResponseField name="hexPrivateKey" type="string">
          The private key in hexadecimal format.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>
