> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Backup and recovery with CoinCover

> Combine Dynamic offline recovery with CoinCover so a user can regain an embedded wallet on their own device after an identity check, without Dynamic or your backend ever holding both recovery shares.

CoinCover provides identity-verified backup and recovery. This guide connects it to Dynamic [offline recovery](https://www.dynamic.xyz/docs/embedded-wallets/mpc/offline-recovery.md) for [MPC-backed](https://www.dynamic.xyz/docs/embedded-wallets/mpc/overview.md) embedded wallets. The user's recovery share stays in their own Google Drive, and the second recovery share is delivered to CoinCover, which releases it only after the user passes an identity check.

CoinCover's own [Dynamic partner guide](https://developer.coincover.com/partner-guides/dynamic) describes the same flow from its side, and its [retail integration guide](https://developer.coincover.com/retail-recovery/integration-guide) documents the verification and key APIs that this page refers to. CoinCover's [UI components](https://developer.coincover.com/retail-recovery/ui-components) guide covers embedding the Identity SDK in your app.

## How the pieces fit together

Offline recovery creates a 2-of-2 pair of recovery shares that is separate from the wallet's regular key shares. With CoinCover, the two shares are held as follows:

| Share | Where it lives | Who can read it |
| - | - | - |
| Share 1 | Encrypted in the user's Google Drive | The user, through the SDK |
| Share 2 | Held by CoinCover, encrypted to a key generated for the user | Only CoinCover's secure enclave, until a verified recovery re-encrypts it |

Your backend never receives either share. It starts identity verifications, requests keys and recoveries from CoinCover on the user's behalf, and relays the responses.

## Before you begin

* A CoinCover account with the retail integration enabled for your Dynamic environment.
* [Google Drive backup](https://www.dynamic.xyz/docs/embedded-wallets/mpc/backup.md) configured for your environment, because Share 1 is stored there.
* A backend that can call the CoinCover APIs with your CoinCover credentials. Keep those credentials in a secrets manager or environment variables, never in the app.

## Connect Dynamic to CoinCover

You do this once for each Dynamic environment.

**1. Get a webhook URL from CoinCover**

CoinCover issues a webhook URL for your Dynamic environment during onboarding.

**2. Enable offline recovery in Dynamic**

In the [Dynamic Console](https://console.dynamic.xyz/dashboard), go to **Wallets > Embedded Wallets > Backup & Recovery**, turn on **Developer Recovery Share**, and set the **Share Delivery** webhook URL to the URL from CoinCover. Follow [Configure offline recovery](https://www.dynamic.xyz/docs/embedded-wallets/mpc/offline-recovery.md#configure-offline-recovery) for the remaining fields.

**3. Subscribe to the offline recovery event**

In the Dynamic Console, go to [**Developers > Webhooks**](https://console.dynamic.xyz/dashboard/developer/webhooks), add a webhook with the CoinCover URL, and subscribe it to the `wallet.offlineRecovery.created` event. See [Webhook events](https://www.dynamic.xyz/docs/platform/console/webhooks/event-types.md) for the event list.

**4. Send the webhook details to CoinCover**

Share the webhook ID, its signing secret, and your environment ID with CoinCover. CoinCover uses them to verify the `x-dynamic-signature-256` header on each delivery, as described in [Signature validation](https://www.dynamic.xyz/docs/platform/console/webhooks/setup.md#signature-validation), and to accept shares only from your environment.

## Back up a user's wallet

**1. Verify the user's identity**

Your backend calls `POST /v1/verification/start` with an identifier for the user, and your app launches the CoinCover Identity SDK with the returned `verification_id`. The user completes the check in your app, for example with an identity document and a selfie. Continue once the verification status is `APPROVED`.

**2. Request a key for the user**

Your backend calls `POST /v1/key/generate` with the user's identifier and the approved `verification_id`. CoinCover generates an RSA key pair inside its secure enclave and returns the public key as hex-encoded SPKI, together with a signature.

**3. Verify the key signature**

Check the signature against CoinCover's published JWKS before you use the key, as described in CoinCover's [Validating key signatures](https://developer.coincover.com/guides/validating-key-signatures) guide. This confirms the key came from CoinCover and was not substituted in transit.

**4. Create the offline recovery shares**

Convert the public key to base64 and pass it to the Dynamic SDK as `recoveryEncryptionPublicKey`. Dynamic stores Share 1 in the user's Google Drive, encrypts Share 2 to the CoinCover key, and delivers it to the webhook.

```typescript theme={"system"}
import { createWaasOfflineRecoveryShares } from '@dynamic-labs-sdk/client/waas';

// walletAccount: the WalletAccount from the Dynamic client
// coinCoverKeyHex: the hex-encoded SPKI public key from POST /v1/key/generate,
// which your backend has already checked against CoinCover's JWKS
const keyBytes = Uint8Array.from(
  coinCoverKeyHex.match(/../g)!.map((pair) => parseInt(pair, 16)),
);
const coinCoverPublicKey = btoa(String.fromCharCode(...keyBytes));

await createWaasOfflineRecoveryShares({
  walletAccount,
  recoveryEncryptionPublicKey: coinCoverPublicKey,
});
```

Dynamic requires an RSA public key of 2048 bits or larger, supplied base64-encoded. We strongly recommend passing an `mfaToken` from step-up authentication as well, as described in [Request a recovery share](https://www.dynamic.xyz/docs/embedded-wallets/mpc/offline-recovery.md#request-a-recovery-share).

When CoinCover receives the webhook, it identifies the user from the key the share is encrypted to, confirms inside its enclave that the share can be decrypted, and stores the encrypted share against that user.

## Recover a wallet

Use recovery when the user has lost access to their wallet or when Dynamic is unavailable. It runs between the user's device, your backend, and CoinCover, and it does not call Dynamic.

**1. Verify the user's identity again**

Your backend starts a new verification with the same user identifier and the user completes it in your app. CoinCover compares it with the verification captured at backup to confirm it is the same person. Recovery proceeds only once the status is `APPROVED`, and CoinCover treats each approved verification as authorization for a single recovery.

**2. Generate a one-time key on the device**

The app generates an RSA key pair for this recovery only. The private key stays on the device under the platform's secure key handling and is never stored or transmitted, and only the public key goes to your backend.

**3. Request Share 2 from CoinCover**

Your backend calls `POST /v1/backup/recover` with the approved `verification_id` and the one-time public key as `rsa_public_key`. CoinCover decrypts Share 2 in its enclave, re-encrypts it to the one-time key, and returns it. Your backend relays the response but cannot decrypt it.

**4. Rebuild the wallet key**

The app decrypts Share 2 with the one-time private key, reads Share 1 from the user's Google Drive, and combines the two with `offlineExportKey`, as shown in [Recovery](https://www.dynamic.xyz/docs/embedded-wallets/mpc/offline-recovery.md#recovery). The app then discards the one-time key.

The result is that the user holds the wallet's private key on their own device. Treat that key as sensitive material, because anything that can read it can move the wallet's funds, and do not log it or send it to your backend.

For a working implementation of the share decryption and export, see the [example recovery tool](https://github.com/dynamic-labs-oss/offline-recovery).

## Security considerations

* CoinCover is responsible for verifying the user's identity and for protecting the private key, which it uses only inside its secure enclave. Your application is responsible for starting verifications honestly, checking the key signature, and keeping its CoinCover credentials secret.
* Outside CoinCover's enclave, only the user's device can read Share 2 during recovery, and the one-time key exists only for that recovery.
* Offline recovery can combine the two shares without Dynamic, so protect Share 1 by keeping the user's Google account secure and requiring step-up authentication before you create recovery shares.
* When offline recovery is enabled, users cannot use Google Drive as a regular cloud backup.

## Related

> [card] [Offline recovery](https://www.dynamic.xyz/docs/embedded-wallets/mpc/offline-recovery.md)
>
> How the recovery shares are created, delivered, and combined.

> [card] [Wallet backup](https://www.dynamic.xyz/docs/embedded-wallets/mpc/backup.md)
>
> How Google Drive backup works and how to enable it.

> [card] [Embedded wallet webhooks](https://www.dynamic.xyz/docs/embedded-wallets/webhooks.md)
>
> Events that Dynamic sends about wallets, including offline recovery.

> [card] [CoinCover partner guide](https://developer.coincover.com/partner-guides/dynamic)
>
> The same integration described from CoinCover's side.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.