ejectPrivateKeys
Extracts all private keys from the wallet using a specified backup method.
Function Signature
public func ejectPrivateKeys(
_ method: BackupMethods,
withCipherText: String? = nil,
andOrganizationBackupShare: String? = nil,
andOrganizationSolanaBackupShare: String? = nil
) async throws -> [PortalNamespace: String]
Parameters
method
: The backup method to use. Supported methods:.GoogleDrive
: Authenticate using Google Drive backup.iCloud
: Authenticate using iCloud backup.Password
: Authenticate using password.Passkey
: Authenticate using passkey.local
: Authenticate using local backup
withCipherText
: Optional cipher text from a previous backupandOrganizationBackupShare
: Optional backup share provided by the organization for EVM chainsandOrganizationSolanaBackupShare
: Optional backup share provided by the organization specifically for Solana
Returns
A dictionary mapping PortalNamespace
to private keys, where:
.eip155
key contains the Ethereum/EVM private key.solana
key contains the Solana private key
Throws
Various backup method-specific errors if authentication fails
Warning
Providing the custodian backup share to the client device puts both MPC shares on a single device, removing the multi-party security benefits of MPC. This operation should only be done for users who want to move off of MPC and into a single private key. Use portal.ejectPrivateKeys()
at your own risk!
Example Usage
do {
let privateKeys = try await portal.ejectPrivateKeys(
.iCloud,
withCipherText: backupCipherText,
andOrganizationBackupShare: orgBackupShare,
andOrganizationSolanaBackupShare: orgSolanaBackupShare
)
if let ethPrivateKey = privateKeys[.eip155] {
print("Ethereum private key: \(ethPrivateKey)")
}
if let solanaPrivateKey = privateKeys[.solana] {
print("Solana private key: \(solanaPrivateKey)")
}
} catch {
print("Error ejecting private keys: \(error)")
}
Last updated
Was this helpful?