Skip to main content

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

ParameterTypeRequiredDescription
methodPortalBackupMethodYesThe backup method to use for authentication
passwordStringNoRequired when using PortalBackupMethod.password
cipherTextStringNoFor self-managed backups

Returns

Map<String, String> - A map of namespace to private key:
KeyDescription
eip155The Ethereum/EVM private key
solanaThe 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

CodeDescription
NOT_INITIALIZEDPortal was not initialized
EJECT_FAILEDThe eject operation failed
INVALID_PASSWORDThe provided password is incorrect
AUTHENTICATION_FAILEDFailed to authenticate with backup method