LogoLogo
SupportGithubSign InGet Access
  • Introduction
  • GETTING STARTED
    • SDK Quick Start
    • API Quick Start
  • Guides
    • Web
      • Create a wallet
      • Send tokens
      • Sign a transaction
      • Simulate a transaction
      • Back up a wallet
      • Recover a wallet
      • Cross-device sessions
      • Manage wallet lifecycle states
      • Web authentication methods
      • Perform swaps
      • Add custom signature hooks
      • MPC progress callbacks
      • Portal API methods
      • Configure a custom subdomain
      • Eject a wallet
      • Using the EIP-1193 Provider
      • Legacy documentation
        • Back up a wallet
          • Backup Options
        • Recover a wallet
    • iOS
      • Create a wallet
      • Send tokens
      • Sign a transaction
      • Simulate a transaction
      • Back up a wallet
      • Recover a wallet
      • Cross-device sessions
      • Manage wallet lifecycle states
      • Connect with WalletConnect
      • Build a WebView
      • Perform swaps
      • Add custom signature hooks
      • MPC progress callbacks
      • Portal API methods
      • Manage ERC20 tokens
      • Eject a wallet
      • Legacy documentation
        • Back up a wallet
          • Backup Options
          • Passkey + Enclave Storage
        • Recover a wallet
      • Troubleshooting Tips
      • Feature Flags
    • Android
      • Create a wallet
      • Send tokens
      • Sign a transaction
      • Simulate a transaction
      • Back up a wallet
      • Recover a wallet
      • Cross-device sessions
      • Manage wallet lifecycle states
      • Connect with WalletConnect
      • Build a WebView
      • Perform swaps
      • Add custom signature hooks
      • MPC progress callbacks
      • Portal API methods
      • Eject a wallet
      • Legacy documentation
        • Back up a wallet
          • Backup Options
        • Recover a wallet
    • React Native
      • Create a wallet
      • Send tokens
      • Sign a transaction
      • Simulate a transaction
      • Back up a wallet
      • Recover a wallet
      • Cross-device sessions
      • Manage wallet lifecycle states
      • Connect with WalletConnect
      • Build a WebView
      • Perform swaps
      • Add custom signature hooks
      • MPC progress callbacks
      • Portal API methods
      • Eject a wallet
      • Legacy documentation
        • Back up a wallet
          • Backup Options
        • Recover a wallet
    • Enclave MPC API
      • Create a client
      • Create a wallet
      • Send tokens
      • Sign Ethereum transactions
      • Sign Solana transactions
      • Sign Tron transactions
      • Sign Stellar Transaction
      • Concurrent Transactions
      • Back up a wallet
      • Eject a wallet
  • Reference
    • iOS
      • createWallet
      • backupWallet
      • recoverWallet
      • ejectPrivateKeys
      • registerBackupMethod
      • setGDriveConfiguration
      • setPasskeyConfiguration
      • setPasskeyAuthenticationAnchor
      • setPassword
      • availableRecoveryMethods
      • doesWalletExist
      • isWalletBackedUp
      • isWalletOnDevice
      • isWalletRecoverable
      • getBalances
      • getAssets
      • getNftAssets
      • getTransactions
      • sendSol
      • evaluateTransaction
      • buildEip155Transaction
      • buildSolanaTransaction
      • getWalletCapabilities
    • Android
      • Reference Documentation
    • React Native
      • @portal-hq/core
      • Storage adapters
        • Cloud storage
          • @portal-hq/gdrive-storage
          • @portal-hq/icloud-storage
        • Mobile storage
          • @portal-hq/keychain
          • @portal-hq/mobile-key-values
    • Enclave MPC API
      • V1 endpoints
    • Client API
      • V3 endpoints
      • V1 endpoints
    • Custodian API
      • V3 endpoints
      • V1 endpoints
    • Swaps API
      • V3 endpoints
      • V1 endpoints
  • Resources
    • Flutter
      • iOS
      • Android
    • Error codes
      • Overview
      • Legacy Documentation
        • MPC errors
        • Network errors
        • General errors
        • Encryption errors
        • Portal Connect errors
    • Portal's MPC architecture
    • Authentication and API Keys
    • Self-Managed Backups
    • Alert Webhooks
    • Wallet lifecycle
    • Backup options
      • Password/PIN
      • GDrive
      • iCloud
      • Passkey + Enclave
    • WalletConnect metadata
    • Advanced security scanning
    • Account abstraction
    • Security firewall
    • Eject
    • Security
    • Blockchain support
    • Chain ID formatting
    • Testnet faucets
    • Going to Production
    • Rate Limits
    • Multi-backup migration guide
    • Multi-wallet migration guides
      • Migrating from Android SDK v3.x.x to v4.x.x
      • Migrating from iOS SDK v3.0.x to v3.2.x
  • Support
    • Changelog
      • Android
      • iOS
      • React Native
      • Web
      • Past Releases
        • 2024 Releases
        • 2023 Releases
    • Celo Hackathon Hub
    • Glossary
Powered by GitBook
On this page
  • Ejecting a Wallet
  • With Portal-Managed Backups
  • With Self-Managed Backups

Was this helpful?

Edit on GitHub
  1. Guides
  2. Enclave MPC API

Eject a wallet

The eject feature allows a user to construct a private key that can be imported into another wallet manager, such as MetaMask.

PreviousBack up a walletNextiOS

Last updated 1 month ago

Was this helpful?

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.

Ejecting a Wallet

To eject the private keys for your wallets, the two matching backup shares need to be combined. This is done by fetching the backup shares and then inputing them into the eject function in the NPM package.

With Portal-Managed Backups

To eject the private keys for your wallet, the two matching backup shares need to be combined.

  • Client Backup Shares - The client backup shares that are encrypted and stored with Portal.

  • Custodian Backup Shares - The custodian backup shares that are encrypted and stored with Portal.

The general steps here are to:

  1. Get the Portal client's details and derive their SECP256K1 and ED25519 wallets.

  2. Retrieve the Portal client's client backup shares and custodian backup shares.

  3. Eject the Portal client's wallets and get their private keys.

Below is an example of how you might do this using TypeScript.

import axios from 'axios'
import eject from '@portal-hq/eject-js'

const clientId = 'example-client-id'

// Get the Portal client.
const { data: clientDetails } = await axios.get(`https://api.portalhq.io/api/v3/custodians/me/clients/${clientId}`)

// Get the Portal client's wallets.
const secp256k1Wallet = clientDetails.wallets.find((wallet) => wallet.curve === 'SECP256K1')
const ed25519Wallet = clientDetails.wallets.find((wallet) => wallet.curve === 'ED25519')

// Get the raw custodian backup shares.
const secp256k1Shares = await axios.get(`https://api.portalhq.io/api/v3/custodians/me/clients/${clientId}/wallets/${secp256k1Wallet.id}/ejectable-backup-shares`)
const ed25519Shares = await axios.get(`https://api.portalhq.io/api/v3/custodians/me/clients/${clientId}/wallets/${secp256k1Wallet.id}/ejectable-backup-shares`)

// Retrieve the client backup shares from your backend stored during backup.
const secp256k1ClientShare = await retrieveSecp256k1ClientBackupShare(clientId)
const ed25519ClientShare = await retrieveEd25519ClientBackupShare(clientId)

// Derive the custodian backup shares.
const secp256k1CustodianShare = secp256k1Shares.custodianBackupShare
const ed25519CustodianShare = ed25519Shares.custodianBackupShare

// Recover the SECP256K1 private key (EVM).
const secp256k1PrivateKey = await eject.recoverSecp256k1Key(secp256k1ClientShare, secp256k1CustodianShare)

// Recover the ED25519 private key (Solana)
const ed25519PrivateKey = await eject.recoverEd25519Key(ed25519ClientShare, ed25519CustodianShare)

SECP256K1 is the curve used by Ethereum and ED25519 is the curve used by Solana.

With Self-Managed Backups

To eject the private keys for your wallet, the two matching backup shares need to be combined.

  • Client Backup Shares - The client backup shares that you stored on your backend.

  • Custodian Backup Shares - The custodian backup shares that you stored on your backend.

import eject from '@portal-hq/eject-js'

// Fetch the client backup shares from your backend stored during backup.
const secp256k1ClientShare = await fetchSecp256k1ClientBackupShare()
const ed25519ClientShare = await fetchEd25519ClientBackupShare()

// Fetch the custodian backup share for the user from your API stored during backup.
const secp256k1CustodianShare = await fetchSecp256k1CustodianBackupShare()
const ed25519CustodianShare = await fetchSecp256k1CustodianBackupShare()

// Recover a secp256k1 private key (EVM)
const secp256k1PrivateKey = await eject.recoverSecp256k1Key(secp256k1ClientShare, secp256k1CustodianShare)

// Recover an ed25519 private key (Solana)
const ed25519PrivateKey = await eject.recoverEd25519Key(ed25519ClientShare, ed25519CustodianShare)

SECP256K1 is the curve used by Ethereum and ED25519 is the curve used by Solana.

And that's it!

You can learn more about signing algorithms and curves .

You can learn more about signing algorithms and curves .

@portal-hq/eject-js
here
here