Keychain

open class Keychain(keystore: KeyStoreWrapper = KeyStoreWrapper(), preferences: SharedPreferences? = null) : MobileStorageAdapter

The Keychain class provides secure storage for sensitive data, such as cryptographic shares and client metadata.

It uses a KeyStoreWrapper for encryption and decryption, and SharedPreferences for persistent storage.

Constructors

Link copied to clipboard
constructor(keystore: KeyStoreWrapper = KeyStoreWrapper(), preferences: SharedPreferences? = null)

Properties

Link copied to clipboard
open override var api: Api?

The API instance for making network requests.

Link copied to clipboard
open override var clientId: String?

The id for the client.

Functions

Link copied to clipboard
open suspend override fun availableRecoveryMethods(namespace: PortalNamespace): List<BackupMethods>

Gets the available recovery methods for a given PortalNamespace.

open suspend override fun availableRecoveryMethods(chainId: String?): List<BackupMethods>

Gets the available recovery methods for a given chain ID.

Link copied to clipboard
open override fun deleteAddress(): Boolean

Deprecated methods

Link copied to clipboard
open override fun deleteAllEntries(key: String): Boolean

Deletes all entries associated with a given key.

Link copied to clipboard
open override fun deleteDkgResult(): Boolean
Link copied to clipboard
open suspend override fun deleteShares()

Deletes the shares associated with the current client.

Link copied to clipboard
open suspend override fun doesWalletExist(namespace: PortalNamespace): Boolean

Checks if a wallet exists for a given PortalNamespace.

open suspend override fun doesWalletExist(chainId: String?): Boolean

Checks if a wallet exists for a given chain ID.

Link copied to clipboard
open suspend override fun getAddress(portalNamespace: PortalNamespace): String?

Retrieves the address associated with a specific PortalNamespace.

open suspend override fun getAddress(chainId: String): String?

Retrieves the address associated with a specific chain ID.

Link copied to clipboard
open suspend override fun getAddresses(): Map<PortalNamespace, String>

Retrieves all addresses stored in the Keychain.

Link copied to clipboard

Retrieves cached addresses.

Link copied to clipboard
open suspend override fun getMetadata(): PortalKeychainClientMetadata?

Retrieves the client metadata.

Link copied to clipboard
open suspend override fun getShare(namespace: PortalNamespace): PortalMpcGeneratedShare

Retrieves a cryptographic share for a specific PortalNamespace.

open suspend override fun getShare(chainId: String): PortalMpcGeneratedShare

Retrieves a cryptographic share for a specific chain ID.

Link copied to clipboard
open suspend override fun getShares(): PortalKeychainClientShares?

Retrieves the shares associated with the client.

Link copied to clipboard
open suspend override fun isWalletBackedUp(namespace: PortalNamespace): Boolean

Checks if a wallet is backed up for a given PortalNamespace.

open suspend override fun isWalletBackedUp(chainId: String?): Boolean

Checks if a wallet is backed up for a given chain ID.

Link copied to clipboard
open suspend override fun isWalletOnDevice(namespace: PortalNamespace): Result<Boolean>

Checks if a wallet's shares are present on the device for a given PortalNamespace.

open suspend override fun isWalletOnDevice(chainId: String?): Result<Boolean>

Checks if a wallet's shares are present on the device for a given chain ID.

Link copied to clipboard
open suspend override fun isWalletRecoverable(namespace: PortalNamespace): Boolean

Checks if a wallet is recoverable for a given PortalNamespace.

open suspend override fun isWalletRecoverable(chainId: String?): Boolean

Checks if a wallet is recoverable for a given chain ID.

Link copied to clipboard
open suspend override fun loadMetadata()

Loads the client's metadata and stores it in the preferences.

Link copied to clipboard
open suspend override fun storeMetadata(metadata: String)

Stores client metadata in the preferences.

Link copied to clipboard
open suspend override fun storeShares(shares: String)

Stores encrypted shares in the keychain.

Link copied to clipboard
open override fun validateOperations(): Boolean

Validates the core Keychain operations: write, read, and delete.