decryptDataWithKey

fun decryptDataWithKey(key: String, encryptedData: String): String?

The decrypted value, or null when the Keystore could not decrypt it.

null is narrower than "any failure": it means the decryption itself did not produce a value — a lost key, a Keystore fault, a payload that decodes but does not decrypt. Two failures are raised instead of reported, because a caller reading null as "nothing stored" would be wrong about both:

Throws

when encryptedData is not valid Base64, so a corrupt entry is not mistaken for an absent one — for an MPC share those are very different outcomes.

— KeyPermanentlyInvalidatedException among them — when the key exists but can no longer be used, which is only visible from the throw.

Callers that act on the failure — deleting the entry, say — want tryDecryptDataWithKey instead: a null here covers a permanently lost key and a Keystore that stuttered alike, and treating the second as the first destroys readable data.