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

# Eject a wallet

> Learn how to export private keys from the MPC system.

<Danger>
  **WARNING**: Ejecting private keys exposes the full private keys of your wallet. Once ejected, the security guarantees of MPC are lost. This operation should only be used when absolutely necessary, such as migrating to a different wallet provider.
</Danger>

## Private Key Ejection

The `ejectPrivateKeys` method exports the full private keys from the MPC system. This requires authentication using one of your backup methods.

### Eject with Password

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

final portal = Portal();

// Eject private keys using password authentication
final privateKeys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.password,
  password: 'YOUR-PASSWORD',
);

// privateKeys is a Map<String, String> with namespace -> private key
print('EVM private key: ${privateKeys['eip155']}');
print('Solana private key: ${privateKeys['solana']}');
```

### Eject with Passkey

```dart theme={null}
// Configure passkey storage first
await portal.configurePasskeyStorage(
  relyingPartyId: 'portalhq.io',
  relyingPartyOrigins: ['https://portalhq.io'],
);

// Eject private keys using passkey authentication
final privateKeys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.passkey,
);
```

### Eject with Google Drive

```dart theme={null}
// Configure Google Drive storage first
await portal.configureGoogleStorage(
  clientId: 'your-google-client-id',
);

// Eject private keys using Google Drive authentication
final privateKeys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.googleDrive,
);
```

### Eject with iCloud (iOS only)

```dart theme={null}
// Configure iCloud storage first
await portal.configureICloudStorage();

// Eject private keys using iCloud authentication
final privateKeys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.iCloud,
);
```

## Security Considerations

<Warning>
  After ejecting private keys:

  1. **Store them securely** - Never share or expose your private keys
  2. **Consider the wallet compromised** - The MPC security model no longer applies
  3. **Create a new wallet if needed** - For continued use with Portal, create a new MPC wallet
</Warning>

## Use Cases

Private key ejection should only be used in specific scenarios:

1. **Migration** - Moving to a different wallet provider
2. **Advanced users** - Who need direct access for specific operations
3. **Compliance** - Regulatory requirements that mandate key access

## Self-Managed Backups with Cipher Text

If you're using self-managed backups and have stored the cipher text yourself:

```dart theme={null}
final privateKeys = await portal.ejectPrivateKeys(
  method: PortalBackupMethod.password,
  password: 'YOUR-PASSWORD',
  cipherText: 'YOUR-STORED-CIPHER-TEXT',
);
```

**Related Documentation**

* [ejectPrivateKeys function reference](../reference/ejectprivatekeys)
