Import
Import takes a previously exported private key and runs an internal keygen that derives a fresh device-side share from those raw key bytes. The output is a wallet with the same keyId, public key, and blockchain address as the original — but the on-disk share bytes are new.
For the SDK contract see Import Key (Kotlin) and Import Key (Swift).
How the example does it
- Android
- iOS / macOS
vault/.../session/VaultSessionManager.kt
suspend fun importKeyshare(privateKey: ByteArray, keyType: KeyType): KeyResult {
val keyId = sessionFor(keyType).import(
keysharePrivateKey = privateKey,
rootChainCode = DEFAULT_CHAIN_CODE
).getOrThrow()
val publicKey = extractPublicKey(keyId)
return KeyResult(keyId, publicKey)
}
Vault/Session/VaultSessionManager.swift
func importKeyshare(privateKey: Data, type: KeyType) async throws -> KeygenResult {
let keyId = try await sessionForKeyType(type).`import`(
keysharePrivateKey: privateKey,
rootChainCode: Self.defaultChainCode
).get()
let publicKey = try await extractPublicKey(keyId: keyId)
return KeygenResult(keyId: keyId, publicKey: publicKey)
}
The SDK auto-persists the new keyshare via the registered storage client, same as keygen. The privateKey parameter is the raw hex bytes from the exported entry's exportDataHex field, and keyType comes from the JSON entry's keyType string.
