diff --git a/lib/src/client.dart b/lib/src/client.dart index 4cfeb84..0d5b1ad 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1684,7 +1684,6 @@ class Client { userId, deviceId, json.encode(entry.toJson()), - json.encode(entry.validSignatures), entry.verified, entry.blocked, )); @@ -1746,7 +1745,6 @@ class Client { userId, publicKey, json.encode(entry.toJson()), - json.encode(entry.validSignatures), entry.verified, entry.blocked, )); diff --git a/lib/src/database/database.dart b/lib/src/database/database.dart index f402068..9f6c264 100644 --- a/lib/src/database/database.dart +++ b/lib/src/database/database.dart @@ -46,7 +46,6 @@ class Database extends _$Database { if (from == 3) { await m.createTable(userCrossSigningKeys); await m.createIndex(userCrossSigningKeysIndex); - await m.addColumn(userDeviceKeysKey, userDeviceKeysKey.validSignatures); // mark all keys as outdated so that the cross signing keys will be fetched await m.issueCustomQuery('UPDATE user_device_keys SET outdated = true'); from++; diff --git a/lib/src/database/database.g.dart b/lib/src/database/database.g.dart index 0feeca1..daea006 100644 --- a/lib/src/database/database.g.dart +++ b/lib/src/database/database.g.dart @@ -699,7 +699,6 @@ class DbUserDeviceKeysKey extends DataClass final String userId; final String deviceId; final String content; - final String validSignatures; final bool verified; final bool blocked; DbUserDeviceKeysKey( @@ -707,7 +706,6 @@ class DbUserDeviceKeysKey extends DataClass @required this.userId, @required this.deviceId, @required this.content, - this.validSignatures, this.verified, this.blocked}); factory DbUserDeviceKeysKey.fromData( @@ -726,8 +724,6 @@ class DbUserDeviceKeysKey extends DataClass .mapFromDatabaseResponse(data['${effectivePrefix}device_id']), content: stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), - validSignatures: stringType - .mapFromDatabaseResponse(data['${effectivePrefix}valid_signatures']), verified: boolType.mapFromDatabaseResponse(data['${effectivePrefix}verified']), blocked: @@ -749,9 +745,6 @@ class DbUserDeviceKeysKey extends DataClass if (!nullToAbsent || content != null) { map['content'] = Variable(content); } - if (!nullToAbsent || validSignatures != null) { - map['valid_signatures'] = Variable(validSignatures); - } if (!nullToAbsent || verified != null) { map['verified'] = Variable(verified); } @@ -769,7 +762,6 @@ class DbUserDeviceKeysKey extends DataClass userId: serializer.fromJson(json['user_id']), deviceId: serializer.fromJson(json['device_id']), content: serializer.fromJson(json['content']), - validSignatures: serializer.fromJson(json['valid_signatures']), verified: serializer.fromJson(json['verified']), blocked: serializer.fromJson(json['blocked']), ); @@ -782,7 +774,6 @@ class DbUserDeviceKeysKey extends DataClass 'user_id': serializer.toJson(userId), 'device_id': serializer.toJson(deviceId), 'content': serializer.toJson(content), - 'valid_signatures': serializer.toJson(validSignatures), 'verified': serializer.toJson(verified), 'blocked': serializer.toJson(blocked), }; @@ -793,7 +784,6 @@ class DbUserDeviceKeysKey extends DataClass String userId, String deviceId, String content, - String validSignatures, bool verified, bool blocked}) => DbUserDeviceKeysKey( @@ -801,7 +791,6 @@ class DbUserDeviceKeysKey extends DataClass userId: userId ?? this.userId, deviceId: deviceId ?? this.deviceId, content: content ?? this.content, - validSignatures: validSignatures ?? this.validSignatures, verified: verified ?? this.verified, blocked: blocked ?? this.blocked, ); @@ -812,7 +801,6 @@ class DbUserDeviceKeysKey extends DataClass ..write('userId: $userId, ') ..write('deviceId: $deviceId, ') ..write('content: $content, ') - ..write('validSignatures: $validSignatures, ') ..write('verified: $verified, ') ..write('blocked: $blocked') ..write(')')) @@ -826,10 +814,8 @@ class DbUserDeviceKeysKey extends DataClass userId.hashCode, $mrjc( deviceId.hashCode, - $mrjc( - content.hashCode, - $mrjc(validSignatures.hashCode, - $mrjc(verified.hashCode, blocked.hashCode))))))); + $mrjc(content.hashCode, + $mrjc(verified.hashCode, blocked.hashCode)))))); @override bool operator ==(dynamic other) => identical(this, other) || @@ -838,7 +824,6 @@ class DbUserDeviceKeysKey extends DataClass other.userId == this.userId && other.deviceId == this.deviceId && other.content == this.content && - other.validSignatures == this.validSignatures && other.verified == this.verified && other.blocked == this.blocked); } @@ -848,7 +833,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { final Value userId; final Value deviceId; final Value content; - final Value validSignatures; final Value verified; final Value blocked; const UserDeviceKeysKeyCompanion({ @@ -856,7 +840,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { this.userId = const Value.absent(), this.deviceId = const Value.absent(), this.content = const Value.absent(), - this.validSignatures = const Value.absent(), this.verified = const Value.absent(), this.blocked = const Value.absent(), }); @@ -865,7 +848,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { @required String userId, @required String deviceId, @required String content, - this.validSignatures = const Value.absent(), this.verified = const Value.absent(), this.blocked = const Value.absent(), }) : clientId = Value(clientId), @@ -877,7 +859,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { Expression userId, Expression deviceId, Expression content, - Expression validSignatures, Expression verified, Expression blocked, }) { @@ -886,7 +867,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { if (userId != null) 'user_id': userId, if (deviceId != null) 'device_id': deviceId, if (content != null) 'content': content, - if (validSignatures != null) 'valid_signatures': validSignatures, if (verified != null) 'verified': verified, if (blocked != null) 'blocked': blocked, }); @@ -897,7 +877,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { Value userId, Value deviceId, Value content, - Value validSignatures, Value verified, Value blocked}) { return UserDeviceKeysKeyCompanion( @@ -905,7 +884,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { userId: userId ?? this.userId, deviceId: deviceId ?? this.deviceId, content: content ?? this.content, - validSignatures: validSignatures ?? this.validSignatures, verified: verified ?? this.verified, blocked: blocked ?? this.blocked, ); @@ -926,9 +904,6 @@ class UserDeviceKeysKeyCompanion extends UpdateCompanion { if (content.present) { map['content'] = Variable(content.value); } - if (validSignatures.present) { - map['valid_signatures'] = Variable(validSignatures.value); - } if (verified.present) { map['verified'] = Variable(verified.value); } @@ -976,16 +951,6 @@ class UserDeviceKeysKey extends Table $customConstraints: 'NOT NULL'); } - final VerificationMeta _validSignaturesMeta = - const VerificationMeta('validSignatures'); - GeneratedTextColumn _validSignatures; - GeneratedTextColumn get validSignatures => - _validSignatures ??= _constructValidSignatures(); - GeneratedTextColumn _constructValidSignatures() { - return GeneratedTextColumn('valid_signatures', $tableName, true, - $customConstraints: ''); - } - final VerificationMeta _verifiedMeta = const VerificationMeta('verified'); GeneratedBoolColumn _verified; GeneratedBoolColumn get verified => _verified ??= _constructVerified(); @@ -1006,7 +971,7 @@ class UserDeviceKeysKey extends Table @override List get $columns => - [clientId, userId, deviceId, content, validSignatures, verified, blocked]; + [clientId, userId, deviceId, content, verified, blocked]; @override UserDeviceKeysKey get asDslTable => this; @override @@ -1043,12 +1008,6 @@ class UserDeviceKeysKey extends Table } else if (isInserting) { context.missing(_contentMeta); } - if (data.containsKey('valid_signatures')) { - context.handle( - _validSignaturesMeta, - validSignatures.isAcceptableOrUnknown( - data['valid_signatures'], _validSignaturesMeta)); - } if (data.containsKey('verified')) { context.handle(_verifiedMeta, verified.isAcceptableOrUnknown(data['verified'], _verifiedMeta)); @@ -1086,7 +1045,6 @@ class DbUserCrossSigningKey extends DataClass final String userId; final String publicKey; final String content; - final String validSignatures; final bool verified; final bool blocked; DbUserCrossSigningKey( @@ -1094,7 +1052,6 @@ class DbUserCrossSigningKey extends DataClass @required this.userId, @required this.publicKey, @required this.content, - this.validSignatures, this.verified, this.blocked}); factory DbUserCrossSigningKey.fromData( @@ -1113,8 +1070,6 @@ class DbUserCrossSigningKey extends DataClass .mapFromDatabaseResponse(data['${effectivePrefix}public_key']), content: stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), - validSignatures: stringType - .mapFromDatabaseResponse(data['${effectivePrefix}valid_signatures']), verified: boolType.mapFromDatabaseResponse(data['${effectivePrefix}verified']), blocked: @@ -1136,9 +1091,6 @@ class DbUserCrossSigningKey extends DataClass if (!nullToAbsent || content != null) { map['content'] = Variable(content); } - if (!nullToAbsent || validSignatures != null) { - map['valid_signatures'] = Variable(validSignatures); - } if (!nullToAbsent || verified != null) { map['verified'] = Variable(verified); } @@ -1156,7 +1108,6 @@ class DbUserCrossSigningKey extends DataClass userId: serializer.fromJson(json['user_id']), publicKey: serializer.fromJson(json['public_key']), content: serializer.fromJson(json['content']), - validSignatures: serializer.fromJson(json['valid_signatures']), verified: serializer.fromJson(json['verified']), blocked: serializer.fromJson(json['blocked']), ); @@ -1169,7 +1120,6 @@ class DbUserCrossSigningKey extends DataClass 'user_id': serializer.toJson(userId), 'public_key': serializer.toJson(publicKey), 'content': serializer.toJson(content), - 'valid_signatures': serializer.toJson(validSignatures), 'verified': serializer.toJson(verified), 'blocked': serializer.toJson(blocked), }; @@ -1180,7 +1130,6 @@ class DbUserCrossSigningKey extends DataClass String userId, String publicKey, String content, - String validSignatures, bool verified, bool blocked}) => DbUserCrossSigningKey( @@ -1188,7 +1137,6 @@ class DbUserCrossSigningKey extends DataClass userId: userId ?? this.userId, publicKey: publicKey ?? this.publicKey, content: content ?? this.content, - validSignatures: validSignatures ?? this.validSignatures, verified: verified ?? this.verified, blocked: blocked ?? this.blocked, ); @@ -1199,7 +1147,6 @@ class DbUserCrossSigningKey extends DataClass ..write('userId: $userId, ') ..write('publicKey: $publicKey, ') ..write('content: $content, ') - ..write('validSignatures: $validSignatures, ') ..write('verified: $verified, ') ..write('blocked: $blocked') ..write(')')) @@ -1213,10 +1160,8 @@ class DbUserCrossSigningKey extends DataClass userId.hashCode, $mrjc( publicKey.hashCode, - $mrjc( - content.hashCode, - $mrjc(validSignatures.hashCode, - $mrjc(verified.hashCode, blocked.hashCode))))))); + $mrjc(content.hashCode, + $mrjc(verified.hashCode, blocked.hashCode)))))); @override bool operator ==(dynamic other) => identical(this, other) || @@ -1225,7 +1170,6 @@ class DbUserCrossSigningKey extends DataClass other.userId == this.userId && other.publicKey == this.publicKey && other.content == this.content && - other.validSignatures == this.validSignatures && other.verified == this.verified && other.blocked == this.blocked); } @@ -1236,7 +1180,6 @@ class UserCrossSigningKeysCompanion final Value userId; final Value publicKey; final Value content; - final Value validSignatures; final Value verified; final Value blocked; const UserCrossSigningKeysCompanion({ @@ -1244,7 +1187,6 @@ class UserCrossSigningKeysCompanion this.userId = const Value.absent(), this.publicKey = const Value.absent(), this.content = const Value.absent(), - this.validSignatures = const Value.absent(), this.verified = const Value.absent(), this.blocked = const Value.absent(), }); @@ -1253,7 +1195,6 @@ class UserCrossSigningKeysCompanion @required String userId, @required String publicKey, @required String content, - this.validSignatures = const Value.absent(), this.verified = const Value.absent(), this.blocked = const Value.absent(), }) : clientId = Value(clientId), @@ -1265,7 +1206,6 @@ class UserCrossSigningKeysCompanion Expression userId, Expression publicKey, Expression content, - Expression validSignatures, Expression verified, Expression blocked, }) { @@ -1274,7 +1214,6 @@ class UserCrossSigningKeysCompanion if (userId != null) 'user_id': userId, if (publicKey != null) 'public_key': publicKey, if (content != null) 'content': content, - if (validSignatures != null) 'valid_signatures': validSignatures, if (verified != null) 'verified': verified, if (blocked != null) 'blocked': blocked, }); @@ -1285,7 +1224,6 @@ class UserCrossSigningKeysCompanion Value userId, Value publicKey, Value content, - Value validSignatures, Value verified, Value blocked}) { return UserCrossSigningKeysCompanion( @@ -1293,7 +1231,6 @@ class UserCrossSigningKeysCompanion userId: userId ?? this.userId, publicKey: publicKey ?? this.publicKey, content: content ?? this.content, - validSignatures: validSignatures ?? this.validSignatures, verified: verified ?? this.verified, blocked: blocked ?? this.blocked, ); @@ -1314,9 +1251,6 @@ class UserCrossSigningKeysCompanion if (content.present) { map['content'] = Variable(content.value); } - if (validSignatures.present) { - map['valid_signatures'] = Variable(validSignatures.value); - } if (verified.present) { map['verified'] = Variable(verified.value); } @@ -1364,16 +1298,6 @@ class UserCrossSigningKeys extends Table $customConstraints: 'NOT NULL'); } - final VerificationMeta _validSignaturesMeta = - const VerificationMeta('validSignatures'); - GeneratedTextColumn _validSignatures; - GeneratedTextColumn get validSignatures => - _validSignatures ??= _constructValidSignatures(); - GeneratedTextColumn _constructValidSignatures() { - return GeneratedTextColumn('valid_signatures', $tableName, true, - $customConstraints: ''); - } - final VerificationMeta _verifiedMeta = const VerificationMeta('verified'); GeneratedBoolColumn _verified; GeneratedBoolColumn get verified => _verified ??= _constructVerified(); @@ -1393,15 +1317,8 @@ class UserCrossSigningKeys extends Table } @override - List get $columns => [ - clientId, - userId, - publicKey, - content, - validSignatures, - verified, - blocked - ]; + List get $columns => + [clientId, userId, publicKey, content, verified, blocked]; @override UserCrossSigningKeys get asDslTable => this; @override @@ -1438,12 +1355,6 @@ class UserCrossSigningKeys extends Table } else if (isInserting) { context.missing(_contentMeta); } - if (data.containsKey('valid_signatures')) { - context.handle( - _validSignaturesMeta, - validSignatures.isAcceptableOrUnknown( - data['valid_signatures'], _validSignaturesMeta)); - } if (data.containsKey('verified')) { context.handle(_verifiedMeta, verified.isAcceptableOrUnknown(data['verified'], _verifiedMeta)); @@ -5266,7 +5177,6 @@ abstract class _$Database extends GeneratedDatabase { userId: row.readString('user_id'), deviceId: row.readString('device_id'), content: row.readString('content'), - validSignatures: row.readString('valid_signatures'), verified: row.readBool('verified'), blocked: row.readBool('blocked'), ); @@ -5285,7 +5195,6 @@ abstract class _$Database extends GeneratedDatabase { userId: row.readString('user_id'), publicKey: row.readString('public_key'), content: row.readString('content'), - validSignatures: row.readString('valid_signatures'), verified: row.readBool('verified'), blocked: row.readBool('blocked'), ); @@ -5499,22 +5408,15 @@ abstract class _$Database extends GeneratedDatabase { ); } - Future storeUserDeviceKey( - int client_id, - String user_id, - String device_id, - String content, - String valid_signatures, - bool verified, - bool blocked) { + Future storeUserDeviceKey(int client_id, String user_id, + String device_id, String content, bool verified, bool blocked) { return customInsert( - 'INSERT OR REPLACE INTO user_device_keys_key (client_id, user_id, device_id, content, valid_signatures, verified, blocked) VALUES (:client_id, :user_id, :device_id, :content, :valid_signatures, :verified, :blocked)', + 'INSERT OR REPLACE INTO user_device_keys_key (client_id, user_id, device_id, content, verified, blocked) VALUES (:client_id, :user_id, :device_id, :content, :verified, :blocked)', variables: [ Variable.withInt(client_id), Variable.withString(user_id), Variable.withString(device_id), Variable.withString(content), - Variable.withString(valid_signatures), Variable.withBool(verified), Variable.withBool(blocked) ], @@ -5566,22 +5468,15 @@ abstract class _$Database extends GeneratedDatabase { ); } - Future storeUserCrossSigningKey( - int client_id, - String user_id, - String public_key, - String content, - String valid_signatures, - bool verified, - bool blocked) { + Future storeUserCrossSigningKey(int client_id, String user_id, + String public_key, String content, bool verified, bool blocked) { return customInsert( - 'INSERT OR REPLACE INTO user_cross_signing_keys (client_id, user_id, public_key, content, valid_signatures, verified, blocked) VALUES (:client_id, :user_id, :public_key, :content, :valid_signatures, :verified, :blocked)', + 'INSERT OR REPLACE INTO user_cross_signing_keys (client_id, user_id, public_key, content, verified, blocked) VALUES (:client_id, :user_id, :public_key, :content, :verified, :blocked)', variables: [ Variable.withInt(client_id), Variable.withString(user_id), Variable.withString(public_key), Variable.withString(content), - Variable.withString(valid_signatures), Variable.withBool(verified), Variable.withBool(blocked) ], diff --git a/lib/src/database/database.moor b/lib/src/database/database.moor index b26ea41..049c792 100644 --- a/lib/src/database/database.moor +++ b/lib/src/database/database.moor @@ -26,7 +26,6 @@ CREATE TABLE user_device_keys_key ( user_id TEXT NOT NULL, device_id TEXT NOT NULL, content TEXT NOT NULL, - valid_signatures TEXT, verified BOOLEAN DEFAULT false, blocked BOOLEAN DEFAULT false, UNIQUE(client_id, user_id, device_id) @@ -38,7 +37,6 @@ CREATE TABLE user_cross_signing_keys ( user_id TEXT NOT NULL, public_key TEXT NOT NULL, content TEXT NOT NULL, - valid_signatures TEXT, verified BOOLEAN DEFAULT false, blocked BOOLEAN DEFAULT false, UNIQUE(client_id, user_id, public_key) @@ -182,11 +180,11 @@ updateInboundGroupSessionIndexes: UPDATE inbound_group_sessions SET indexes = :i storeUserDeviceKeysInfo: INSERT OR REPLACE INTO user_device_keys (client_id, user_id, outdated) VALUES (:client_id, :user_id, :outdated); setVerifiedUserDeviceKey: UPDATE user_device_keys_key SET verified = :verified WHERE client_id = :client_id AND user_id = :user_id AND device_id = :device_id; setBlockedUserDeviceKey: UPDATE user_device_keys_key SET blocked = :blocked WHERE client_id = :client_id AND user_id = :user_id AND device_id = :device_id; -storeUserDeviceKey: INSERT OR REPLACE INTO user_device_keys_key (client_id, user_id, device_id, content, valid_signatures, verified, blocked) VALUES (:client_id, :user_id, :device_id, :content, :valid_signatures, :verified, :blocked); +storeUserDeviceKey: INSERT OR REPLACE INTO user_device_keys_key (client_id, user_id, device_id, content, verified, blocked) VALUES (:client_id, :user_id, :device_id, :content, :verified, :blocked); removeUserDeviceKey: DELETE FROM user_device_keys_key WHERE client_id = :client_id AND user_id = :user_id AND device_id = :device_id; setVerifiedUserCrossSigningKey: UPDATE user_cross_signing_keys SET verified = :verified WHERE client_id = :client_id AND user_id = :user_id AND public_key = :public_key; setBlockedUserCrossSigningKey: UPDATE user_cross_signing_keys SET blocked = :blocked WHERE client_id = :client_id AND user_id = :user_id AND public_key = :public_key; -storeUserCrossSigningKey: INSERT OR REPLACE INTO user_cross_signing_keys (client_id, user_id, public_key, content, valid_signatures, verified, blocked) VALUES (:client_id, :user_id, :public_key, :content, :valid_signatures, :verified, :blocked); +storeUserCrossSigningKey: INSERT OR REPLACE INTO user_cross_signing_keys (client_id, user_id, public_key, content, verified, blocked) VALUES (:client_id, :user_id, :public_key, :content, :verified, :blocked); removeUserCrossSigningKey: DELETE FROM user_cross_signing_keys WHERE client_id = :client_id AND user_id = :user_id AND public_key = :public_key; insertClient: INSERT INTO clients (name, homeserver_url, token, user_id, device_id, device_name, prev_batch, olm_account) VALUES (:name, :homeserver_url, :token, :user_id, :device_id, :device_name, :prev_batch, :olm_account); ensureRoomExists: INSERT OR IGNORE INTO rooms (client_id, room_id, membership) VALUES (:client_id, :room_id, :membership); diff --git a/lib/src/utils/device_keys_list.dart b/lib/src/utils/device_keys_list.dart index 1dcd71d..9d9bb5e 100644 --- a/lib/src/utils/device_keys_list.dart +++ b/lib/src/utils/device_keys_list.dart @@ -101,8 +101,10 @@ abstract class _SignedKey { String _getSigningContent() { final data = Map.from(content); + // some old data might have the custom verified and blocked keys data.remove('verified'); data.remove('blocked'); + // remove the keys not needed for signing data.remove('unsigned'); data.remove('signatures'); return String.fromCharCodes(canonicalJson.encode(data)); @@ -114,6 +116,9 @@ abstract class _SignedKey { try { olmutil.ed25519_verify(pubKey, _getSigningContent(), signature); valid = true; + } catch (_) { + // bad signature + valid = false; } finally { olmutil.free(); } @@ -157,12 +162,18 @@ abstract class _SignedKey { haveValidSignature = true; gotSignatureFromCache = true; } else if (validSignatures[otherUserId][fullKeyId] == false) { + haveValidSignature = false; gotSignatureFromCache = true; } } if (!gotSignatureFromCache) { // validate the signature manually haveValidSignature = _verifySignature(key.ed25519Key, signature); + validSignatures ??= {}; + if (!validSignatures.containsKey(otherUserId)) { + validSignatures[otherUserId] = {}; + } + validSignatures[otherUserId][fullKeyId] = haveValidSignature; } if (!haveValidSignature) { // no valid signature, this key is useless @@ -181,6 +192,17 @@ abstract class _SignedKey { } return false; } + + Map toJson() { + final data = Map.from(content); + // some old data may have the verified and blocked keys which are unneeded now + data.remove('verified'); + data.remove('blocked'); + return data; + } + + @override + String toString() => json.encode(toJson()); } class CrossSigningKey extends _SignedKey { @@ -208,13 +230,6 @@ class CrossSigningKey extends _SignedKey { usage = json['usage'].cast(); keys = json['keys'] != null ? Map.from(json['keys']) : null; signatures = json['signatures'] != null ? Map.from(json['signatures']) : null; - validSignatures = null; - if (dbEntry.validSignatures != null) { - final validSignaturesContent = Event.getMapFromPayload(dbEntry.validSignatures); - if (validSignaturesContent is Map) { - validSignatures = validSignaturesContent.cast(); - } - } _verified = dbEntry.verified; blocked = dbEntry.blocked; } @@ -228,28 +243,12 @@ class CrossSigningKey extends _SignedKey { signatures = json['signatures'] != null ? Map.from(json['signatures']) : null; - validSignatures = null; _verified = json['verified'] ?? false; blocked = json['blocked'] ?? false; if (keys != null) { identifier = keys.values.first; } } - - Map toJson() { - final data = Map.from(content); - data['user_id'] = userId; - data['usage'] = usage; - if (keys != null) { - data['keys'] = keys; - } - if (signatures != null) { - data['signatures'] = signatures; - } - data['verified'] = _verified; - data['blocked'] = blocked; - return data; - } } class DeviceKeys extends _SignedKey { @@ -291,13 +290,6 @@ class DeviceKeys extends _SignedKey { unsigned = json['unsigned'] != null ? Map.from(json['unsigned']) : null; - validSignatures = null; - if (dbEntry.validSignatures != null) { - final validSignaturesContent = Event.getMapFromPayload(dbEntry.validSignatures); - if (validSignaturesContent is Map) { - validSignatures = validSignaturesContent.cast(); - } - } _verified = dbEntry.verified; blocked = dbEntry.blocked; } @@ -319,25 +311,6 @@ class DeviceKeys extends _SignedKey { blocked = json['blocked'] ?? false; } - Map toJson() { - final data = Map.from(content); - data['user_id'] = userId; - data['device_id'] = deviceId; - data['algorithms'] = algorithms; - if (keys != null) { - data['keys'] = keys; - } - if (signatures != null) { - data['signatures'] = signatures; - } - if (unsigned != null) { - data['unsigned'] = unsigned; - } - data['verified'] = _verified; - data['blocked'] = blocked; - return data; - } - KeyVerification startVerification() { final request = KeyVerification(client: client, userId: userId, deviceId: deviceId); request.start();