Chain is null when retrieving private key
I believe you are simply facing Keystore bugs. See this article for example: Android Security: The Forgetful Keystore. There are also numberous bug reports in Android tracker related to keystore, like AndroidKeyStore deleted after changing screen lock type.
Please use directly getKey method of KeyStore
private java.security.Key getSecretKey(Context context) throws Exception { return keyStore.getKey(XEALTH_KEY_ALIAS, null);}