Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Conv

Manav Rathib707b3e3dcf2
diff --git a/web/packages/base/crypto/index.ts b/web/packages/base/crypto/index.ts
index b9949fc030..1e623deba1 100644
--- a/web/packages/base/crypto/index.ts
+++ b/web/packages/base/crypto/index.ts
@@ -426,14 +426,12 @@ export const boxSeal = (data: string, publicKey: string): Promise<string> =>
*/
export const boxSealOpen = (
encryptedData: string,
- publicKey: string,
- secretKey: string,
+ keyPair: KeyPair,
): Promise<string> =>
inWorker()
- ? ei._boxSealOpen(encryptedData, publicKey, secretKey)
- : sharedWorker().then((w) =>
- w.boxSealOpen(encryptedData, publicKey, secretKey),
- );
+ ? ei._boxSealOpen(encryptedData, keyPair)
+ : sharedWorker().then((w) => w.boxSealOpen(encryptedData, keyPair));
+
/**
* Variant of {@link boxSealOpen} that returns the decrypted bytes as it is
* (without encoding them to base64).
diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.ts
index 906e8246b7..9f4d52e71d 100644
--- a/web/packages/base/crypto/libsodium.ts
+++ b/web/packages/base/crypto/libsodium.ts
@@ -780,20 +780,8 @@ export const boxSealOpenBytes = async (
* A variant of {@link boxSealOpenBytes} that returns the result as a base64
* string.
*/
-export const boxSealOpen = async (
- encryptedData: string,
- publicKey: string,
- secretKey: string,
-) => {
- await sodium.ready;
- return toB64(
- sodium.crypto_box_seal_open(
- await fromB64(encryptedData),
- await fromB64(publicKey),
- await fromB64(secretKey),
- ),
- );
-};
+export const boxSealOpen = async (encryptedData: string, keyPair: KeyPair) =>
+ toB64(await boxSealOpenBytes(encryptedData, keyPair));
/**
* Generate a new randomly generated 128-bit salt suitable for use with the key
diff --git a/web/packages/new/photos/services/collections.ts b/web/packages/new/photos/services/collections.ts
index 3613615220..198903c0b8 100644
--- a/web/packages/new/photos/services/collections.ts
+++ b/web/packages/new/photos/services/collections.ts
@@ -32,6 +32,7 @@ import { getData } from "ente-shared/storage/localStorage";
import { getToken } from "ente-shared/storage/localStorage/helpers";
import { getActualKey } from "ente-shared/user";
import { isHiddenCollection } from "./collection";
+import { ensureUserKeyPair } from "./user";
const COLLECTION_TABLE = "collections";
const HIDDEN_COLLECTION_IDS = "hidden-collection-ids";
@@ -210,18 +211,9 @@ export const getCollectionWithSecrets = async (
masterKey,
);
} else {
- const keyAttributes = getData("keyAttributes");
- const secretKey = await cryptoWorker.decryptBox(
- {
- encryptedData: keyAttributes.encryptedSecretKey,
- nonce: keyAttributes.secretKeyDecryptionNonce,
- },
- masterKey,
- );
collectionKey = await cryptoWorker.boxSealOpen(
collection.encryptedKey,
- keyAttributes.publicKey,
- secretKey,
+ await ensureUserKeyPair(),
);
}
const collectionName =