diff --git a/lib/encryption/cross_signing.dart b/lib/encryption/cross_signing.dart index e4d8bc9..6154088 100644 --- a/lib/encryption/cross_signing.dart +++ b/lib/encryption/cross_signing.dart @@ -123,14 +123,8 @@ class CrossSigning { if (key == null || signedWith == null || signature == null) { return; } - final signedKey = signedKeys.firstWhere( - (k) => k.userId == key.userId && k.identifier == key.identifier, - orElse: () => null) ?? - key.cloneForSigning(); - signedKey.signatures ??= >{}; - if (!signedKey.signatures.containsKey(signedWith.userId)) { - signedKey.signatures[signedWith.userId] = {}; - } + final signedKey = key.cloneForSigning(); + signedKey.signatures[signedWith.userId] = {}; signedKey.signatures[signedWith.userId] ['ed25519:${signedWith.identifier}'] = signature; signedKeys.add(signedKey); diff --git a/lib/src/utils/device_keys_list.dart b/lib/src/utils/device_keys_list.dart index 27ee9f7..2159d51 100644 --- a/lib/src/utils/device_keys_list.dart +++ b/lib/src/utils/device_keys_list.dart @@ -125,6 +125,7 @@ abstract class SignableKey extends MatrixSignableKey { MatrixSignableKey cloneForSigning() { final newKey = MatrixSignableKey.fromJson(Map.from(toJson())); + newKey.signatures ??= >{}; newKey.signatures.clear(); return newKey; }