AndroidKeystoreWalletStore
Durable WalletStore for Android: records are encrypted with an AES-GCM key held in the Android Keystore, and Jetpack DataStore owns the file. The Apple counterpart is KeychainWalletStore.
Be precise about what this protects. A record binds a party to a key handle, and for AndroidKeystoreSigningDriver that handle is a keystore alias — the private key itself never leaves StrongBox or the TEE either way. Encrypting the file protects the binding's integrity and keeps the party id (a pseudonymous on-ledger identity) out of plain storage; it is not what keeps signing keys secret.
Two deliberate choices:
DataStore, not
EncryptedSharedPreferences. Jetpack Security's crypto library is deprecated as ofsecurity-crypto1.1.0-alpha07, with a history of keyset-corruption crashes and main-thread violations. DataStore is the current Jetpack storage layer: writes are atomic, one writer per file is enforced, and all I/O is off the main thread. This class supplies the encryption DataStore does not do itself.No silent corruption recovery. A store that can't be read raises WalletStoreUnreadableException rather than resetting to empty, since a wallet that quietly forgets its party will onboard a second identity.
Exclude the file from cloud backup. The Keystore key is device-bound and cannot be backed up, so a restored copy on a new device is undecryptable. Set android:allowBackup="false" (what a wallet generally wants) or exclude the store file in your backup rules.
DataStore permits only one active instance per file, so instances for the same path share one under the hood; construct them freely.
Requires API 26: WalletRecord.createdAt is a java.time.Instant. Below that, enable core library desugaring in the consuming app.
Parameters
name of the store file inside filesDir.
Android Keystore alias for the AES key that wraps it.
Types
Functions
Releases the DataStore this process holds for the file, along with the in-memory copy of its contents. The next operation reopens it, so calling this is never required in normal use — reach for it when something outside the store is about to touch the file, or to drop decrypted records from memory.