Mpc

open class Mpc(api: Api, apiKey: String, keychain: MobileStorageAdapter, apiHost: String = "api.portalhq.io", featureFlags: FeatureFlags? = null, host: String = "mpc.portalhq.io", mpc: PortalMobileMpc? = null, version: String = "v6")

Mpc is a class that handles Multi-Party Computation (MPC) operations, providing functionality for generating, backing up, recovering, and ejecting private keys for various blockchain networks. It interacts with an external API, a local keychain, and various cloud storage adapters to manage cryptographic shares securely.

This class supports generating and managing wallets for multiple curves like SECP256K1 (Ethereum) and ED25519 (Solana).

Constructors

Link copied to clipboard
constructor(api: Api, apiKey: String, keychain: MobileStorageAdapter, apiHost: String = "api.portalhq.io", featureFlags: FeatureFlags? = null, host: String = "mpc.portalhq.io", mpc: PortalMobileMpc? = null, version: String = "v6")

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend fun backup(backupMethod: BackupMethods = BackupMethods.Gdrive, progress: (status: MpcStatus) -> Unit = {}): BackupWalletResponse

Initiates a backup process for the wallet using the specified backup method.

Link copied to clipboard

Configures the Google Drive storage for backup.

Link copied to clipboard
fun configurePasskeyStorage(relyingPartyId: String, relyingPartyOrigins: List<String>, webAuthnHost: String = "https://backup.web.portalhq.io")

Configures the Passkey storage for backup.

Link copied to clipboard
open suspend fun ejectPrivateKey(clientBackupCiphertext: String? = null, orgBackupShare: String? = null, backupMethod: BackupMethods): String

Ejects the private key from the MPC storage using the provided backup method.

Link copied to clipboard
open suspend fun ejectPrivateKeys(clientBackupCiphertext: String? = null, orgBackupShare: String? = null, orgSolanaBackupShare: String? = null, backupMethod: BackupMethods): Map<PortalNamespace, String>

Ejects multiple private keys from the MPC storage using the provided backup method.

Link copied to clipboard
suspend fun generateSolanaWallet(progress: (status: MpcStatus) -> Unit = {}): Result<String>

Generates a new Solana wallet for the client, ensuring that an Ethereum wallet already exists.

Link copied to clipboard
open suspend fun generateWallets(progress: (status: MpcStatus) -> Unit = {}): Map<PortalNamespace, String>

Generates new wallets for both SECP256K1 and ED25519 curves using Multi-Party Computation (MPC).

Link copied to clipboard

Retrieves the CloudStorageAdapter associated with the specified backup method.

Link copied to clipboard
open suspend fun isWebSocketAllowed(mpcHost: String): Boolean

Checks whether WebSocket connections are allowed for the given MPC host.

Link copied to clipboard
open suspend fun recover(cipherText: String? = null, backupMethod: BackupMethods = BackupMethods.Gdrive, progress: (status: MpcStatus) -> Unit = {}): String

Recovers the MPC shares for the user's wallet.

Link copied to clipboard

Registers a backup method with a corresponding cloud storage adapter.

Link copied to clipboard
fun setPassword(password: String)

Sets the password for the password-based backup method.