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

# ejectPrivateKeys

> Export private keys from the MPC system.

## Function Signature

```dart theme={null}
Future<Map<String, String>> ejectPrivateKeys({
  required PortalBackupMethod method,
  String? password,
  String? cipherText,
  String? orgBackupShare,
  String? orgSolanaBackupShare,
})
```

## Description

Exports the full private keys from the MPC system. This requires authentication using one of your backup methods.

For Self-Managed Backups, pass the encrypted client share via `cipherText` and the raw custodian share(s) via `orgBackupShare` (secp256k1 / EVM) and `orgSolanaBackupShare` (ed25519 / Solana). Under Portal-Managed Backups these parameters are not required — Portal supplies the custodian share.

<Danger>
  **WARNING**: This operation exposes your full private keys. Once ejected, the security guarantees of MPC are lost. Use with extreme caution.
</Danger>

## Parameters

| Parameter              | Type                 | Required | Description                                                                                  |
| ---------------------- | -------------------- | -------- | -------------------------------------------------------------------------------------------- |
| `method`               | `PortalBackupMethod` | Yes      | The backup method to use for authentication                                                  |
| `password`             | `String`             | No       | Required when using `PortalBackupMethod.password`                                            |
| `cipherText`           | `String`             | No       | Required for Self-Managed Backups: the encrypted client backup share                         |
| `orgBackupShare`       | `String`             | No       | Required for Self-Managed Backups: raw custodian backup share for the secp256k1 / EVM curve  |
| `orgSolanaBackupShare` | `String`             | No       | Required for Self-Managed Backups: raw custodian backup share for the ed25519 / Solana curve |

## Returns

**`Map<String, String>`** - A map of namespace to private key:

| Key      | Description                  |
| -------- | ---------------------------- |
| `eip155` | The Ethereum/EVM private key |
| `solana` | The Solana private key       |

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Portal-Managed Backups: pass only method (and password when applicable).
final keys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.password,
  password: 'user-password',
);

// keys is a Map<String, String> keyed by namespace:
//   keys['eip155'] -> EVM private key
//   keys['solana'] -> Solana private key
//
// ⚠️ Never log or print the values. Hand them off to your secure export
// flow (e.g. show in a confirmation modal, encrypt for transfer to
// another wallet manager).
final evmKey = keys['eip155'];
final solanaKey = keys['solana'];
```

### Self-Managed Backups

```dart theme={null}
final keys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.password,
  password: 'user-password',
  cipherText: cipherText,
  orgBackupShare: orgBackupShare,
  orgSolanaBackupShare: orgSolanaBackupShare,
);
```

## Errors

| Code                    | Description                               |
| ----------------------- | ----------------------------------------- |
| `NOT_INITIALIZED`       | Portal was not initialized                |
| `EJECT_FAILED`          | The eject operation failed                |
| `INVALID_PASSWORD`      | The provided password is incorrect        |
| `AUTHENTICATION_FAILED` | Failed to authenticate with backup method |

## Related

* [Eject a wallet guide](../guide/eject-a-wallet)
* [backupWallet](./backupwallet)
* [getClient](./getclient)
