getCryptoIdentityState method
Returns the current state of the crypto identity.
The crypto identity is initialized if key backup and cross signing
are correctly set up. You can initialize a new account by using
Client.initCryptoIdentity().
The crypto identity is connected if this device has all the secrets
cached locally. This usually includes that this device has signed itself.
You can use Client.restoreCryptoIdentity() to connect or
Client.initCryptoIdentity() to wipe the current identity in case of
that you lost your recovery key / passphrase and have no other way
to restore.
Implementation
Future<({bool initialized, bool connected})> getCryptoIdentityState() async {
await accountDataLoading;
await firstSyncReceived;
// Make sure we have the necessary account data types synced. Workaround for
// https://github.com/element-hq/synapse/issues/15500
for (final type in [
EventTypes.MegolmBackup,
EventTypes.CrossSigningSelfSigning,
EventTypes.CrossSigningUserSigning,
EventTypes.CrossSigningMasterKey,
]) {
accountData[type] ??=
BasicEvent(content: await getAccountData(userID!, type), type: type);
}
return (
initialized: (encryption?.keyManager.enabled ?? false) &&
(encryption?.crossSigning.enabled ?? false),
connected: ((await encryption?.keyManager.isCached()) ?? false) &&
((await encryption?.crossSigning.isCached()) ?? false),
);
}