simplify key signing a tad
This commit is contained in:
parent
b4e83caa89
commit
45232be3a0
|
@ -123,14 +123,8 @@ class CrossSigning {
|
||||||
if (key == null || signedWith == null || signature == null) {
|
if (key == null || signedWith == null || signature == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final signedKey = signedKeys.firstWhere(
|
final signedKey = key.cloneForSigning();
|
||||||
(k) => k.userId == key.userId && k.identifier == key.identifier,
|
|
||||||
orElse: () => null) ??
|
|
||||||
key.cloneForSigning();
|
|
||||||
signedKey.signatures ??= <String, Map<String, String>>{};
|
|
||||||
if (!signedKey.signatures.containsKey(signedWith.userId)) {
|
|
||||||
signedKey.signatures[signedWith.userId] = <String, String>{};
|
signedKey.signatures[signedWith.userId] = <String, String>{};
|
||||||
}
|
|
||||||
signedKey.signatures[signedWith.userId]
|
signedKey.signatures[signedWith.userId]
|
||||||
['ed25519:${signedWith.identifier}'] = signature;
|
['ed25519:${signedWith.identifier}'] = signature;
|
||||||
signedKeys.add(signedKey);
|
signedKeys.add(signedKey);
|
||||||
|
|
|
@ -125,6 +125,7 @@ abstract class SignableKey extends MatrixSignableKey {
|
||||||
MatrixSignableKey cloneForSigning() {
|
MatrixSignableKey cloneForSigning() {
|
||||||
final newKey =
|
final newKey =
|
||||||
MatrixSignableKey.fromJson(Map<String, dynamic>.from(toJson()));
|
MatrixSignableKey.fromJson(Map<String, dynamic>.from(toJson()));
|
||||||
|
newKey.signatures ??= <String, Map<String, String>>{};
|
||||||
newKey.signatures.clear();
|
newKey.signatures.clear();
|
||||||
return newKey;
|
return newKey;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue