> ## 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,
})
```

## Description

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

<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       | For self-managed backups                          |

## 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();

// Eject with password
final privateKeys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.password,
  password: 'user-password',
);

print('EVM private key: ${privateKeys['eip155']}');
print('Solana private key: ${privateKeys['solana']}');
```

### With Other Methods

```dart theme={null}
// With passkey
await portal.configurePasskeyStorage(
  relyingPartyId: 'portalhq.io',
  relyingPartyOrigins: ['https://portalhq.io'],
);
final keys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.passkey,
);

// With Google Drive
await portal.configureGoogleStorage(clientId: 'your-client-id');
final keys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.googleDrive,
);
```

## 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)
