Function Signature
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.
WARNING: This operation exposes your full private keys. Once ejected, the security guarantees of MPC are lost. Use with extreme caution.
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
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
// 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 |