[Motorola Edge 40 Pro  / Moto X40 (China)] mxz55:
Unfortunately (and contrary to as @ThE_MarD believed.. he said it didn't occur for him anymore.. idk why), it's not fixed.. it took a while to re-appear but it did, first sign was the same type of PIN failure that i described earlier (phone claims input is wrong, but it's not.. only a reboot will allow you to enter your code successfully) and eventually the apps that were prone to keystore crashes, and loss of app data, returned to this state.

I did a full firmware upgrade with Motorola Rescue tool, before clean installing LineageOS

Preview of grep "keystore" after the issue occured:

Line 30525: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: java.security.InvalidKeyException: Keystore operation failed
Line 30526: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:130)
Line 30527: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:154)
Line 30528: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:339)
Line 30529: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:234)
Line 30536: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at mozilla.components.lib.dataprotect.Keystore.createDecryptCipher(Keystore.kt:21)
Line 30537: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at mozilla.components.lib.dataprotect.Keystore.decryptBytes(Keystore.kt:33)
Line 30554: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: Caused by: android.security.KeyStoreException: -49 (internal Keystore code: -49 message: In create_operation: Failed to begin operation.
Line 30557: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: 0: In KeystoreSecurityLevel::upgrade_keyblob_if_required_with.
Line 30559: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: 2: Error::Km(ErrorCode(-49))) (public error code: 10 internal Keystore code: -49)
Line 30560: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:369)
Line 30561: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.KeyStoreSecurityLevel.createOperation(KeyStoreSecurityLevel.java:120)
Line 30562: 08-25 03:07:42.830 24010 28307 E SecurePreferencesImpl23: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:334)
Line 30573: 08-25 03:07:42.840 1320 1351 E keystore2: keystore2::error: In create_operation: Failed to begin operation.
Line 30574: 08-25 03:07:42.840 1320 1351 E keystore2:
Line 30575: 08-25 03:07:42.840 1320 1351 E keystore2: Caused by:
Line 30576: 08-25 03:07:42.840 1320 1351 E keystore2: 0: In KeystoreSecurityLevel::upgrade_keyblob_if_required_with.
Line 30577: 08-25 03:07:42.840 1320 1351 E keystore2: 1: In utils::upgrade_keyblob_if_required_with: Calling km_op.
Line 30578: 08-25 03:07:42.840 1320 1351 E keystore2: 2: Error::Km(ErrorCode(-49))
Line 30581: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: java.security.InvalidKeyException: Keystore operation failed
Line 30582: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:130)
Line 30583: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:154)
Line 30584: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:339)
Line 30585: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:171)
Line 30609: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: Caused by: android.security.KeyStoreException: -49 (internal Keystore code: -49 message: In create_operation: Failed to begin operation.
Line 30612: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: 0: In KeystoreSecurityLevel::upgrade_keyblob_if_required_with.
Line 30614: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: 2: Error::Km(ErrorCode(-49))) (public error code: 10 internal Keystore code: -49)
Line 30615: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:369)
Line 30616: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.KeyStoreSecurityLevel.createOperation(KeyStoreSecurityLevel.java:120)
Line 30617: 08-25 03:07:42.840 24010 28307 E ExceptionHandler: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:334)
Line 30619: 08-25 03:07:42.842 24010 28307 I mozac/CrashReporter: Received crash: UncaughtExceptionCrash(timestamp=1692925662841, throwable=java.security.InvalidKeyException: Keystore operation failed, breadcrumbs=[Breadcrumb(message=onCreate(), data={recreated=false, intent=android.intent.action.MAIN, instance=265159562}, category=HomeActivity, level=INFO, type=DEFAULT, date=Fri Aug 25 03:07:42 GMT+02:00 2023), Breadcrumb(message=Changing to fragment homeFragment, isCustomTab: false, data={}, category=DestinationChanged, level=INFO, type=DEFAULT, date=Fri Aug 25 03:07:42 GMT+02:00 2023), Breadcrumb(message=onStart(), data={instance=265159562}, category=HomeActivity, level=INFO, type=DEFAULT, date=Fri Aug 25 03:07:42 GMT+02:00 2023), Breadcrumb(message=onResume(), data={instance=265159562}, category=HomeActivity, level=INFO, type=DEFAULT, date=Fri Aug 25 03:07:42 GMT+02:00 2023)], uuid=9a7d6a42-5ba0-43b1-8e33-91bd1e413762)
Line 30643: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: java.security.InvalidKeyException: Keystore operation failed
Line 30644: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:130)
Line 30645: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:154)
Line 30646: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:339)
Line 30647: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:171)
Line 30671: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: Caused by: android.security.KeyStoreException: -49 (internal Keystore code: -49 message: In create_operation: Failed to begin operation.
Line 30674: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: 0: In KeystoreSecurityLevel::upgrade_keyblob_if_required_with.
Line 30676: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: 2: Error::Km(ErrorCode(-49))) (public error code: 10 internal Keystore code: -49)
Line 30677: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:369)
Line 30678: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.KeyStoreSecurityLevel.createOperation(KeyStoreSecurityLevel.java:120)
Line 30679: 08-25 03:07:42.865 24010 28307 E AndroidRuntime: at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:334)

Full grep: https://pastebin.com/s3UB1QDA

Edit:

KmError -49 in our log turns out to stand for: KM_ERROR_SECURE_HW_COMMUNICATION_FAILED and i found a very similar issue, with only the value of that code being different, at: https://issuetracker.google.com/issues/240455040

Would turning off a flag KEYSTORE_OPERATION_CREATION_MAY_FAIL give us temporary relief?

intro to its documentation:

fyi @SGCMarkus