Minor refactor

This commit is contained in:
Vishnu Mohandas 2020-11-07 15:46:30 +05:30
parent 58610b7cdd
commit 241cfe5478

View file

@ -130,19 +130,16 @@ class CollectionsService {
Uint8List getCollectionKey(int collectionID) {
if (!_cachedKeys.containsKey(collectionID)) {
final collection = _collectionIDToCollections[collectionID];
var key;
final encryptedKey = Sodium.base642bin(collection.encryptedKey);
if (collection.owner.id == _config.getUserID()) {
final encryptedKey = Sodium.base642bin(collection.encryptedKey);
key = CryptoUtil.decryptSync(encryptedKey, _config.getKey(),
Sodium.base642bin(collection.keyDecryptionNonce));
_cachedKeys[collectionID] = CryptoUtil.decryptSync(encryptedKey,
_config.getKey(), Sodium.base642bin(collection.keyDecryptionNonce));
} else {
final encryptedKey = Sodium.base642bin(collection.encryptedKey);
key = CryptoUtil.openSealSync(
_cachedKeys[collectionID] = CryptoUtil.openSealSync(
encryptedKey,
Sodium.base642bin(_config.getKeyAttributes().publicKey),
_config.getSecretKey());
}
_cachedKeys[collectionID] = key;
}
return _cachedKeys[collectionID];
}