fix: Cache the result of the self-signature check

This commit is contained in:
Sorunome 2020-12-23 10:52:39 +01:00
parent 294d82752a
commit 48904b3a1b
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
1 changed files with 13 additions and 9 deletions

View File

@ -369,15 +369,19 @@ class DeviceKeys extends SignableKey {
String get deviceDisplayName =>
unsigned != null ? unsigned['device_display_name'] : null;
bool get selfSigned => signatures
bool _validSelfSignature;
bool get selfSigned =>
_validSelfSignature ??
(_validSelfSignature = (signatures
?.tryGet<Map<String, dynamic>>(userId)
?.tryGet<String>('ed25519:$deviceId') ==
null
? false
// without libolm we still want to be able to add devices. In that case we ofc just can't
// verify the signature
: _verifySignature(ed25519Key, signatures[userId]['ed25519:$deviceId'],
isSignatureWithoutLibolmValid: true);
: _verifySignature(
ed25519Key, signatures[userId]['ed25519:$deviceId'],
isSignatureWithoutLibolmValid: true)));
@override
bool get blocked => super.blocked || !selfSigned;