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