π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Proxy
Manav Rathi52ee86af185e
diff --git a/web/packages/base/crypto/ente-impl.ts b/web/packages/base/crypto/ente-impl.tsindex 3ec10d2e12..2606b33976 100644--- a/web/packages/base/crypto/ente-impl.ts+++ b/web/packages/base/crypto/ente-impl.ts@@ -2,63 +2,33 @@import * as libsodium from "./libsodium";export const _toB64 = libsodium.toB64;-export const _toB64URLSafe = libsodium.toB64URLSafe;-export const _fromB64 = libsodium.fromB64;-export const _toHex = libsodium.toHex;-export const _fromHex = libsodium.fromHex;-export const _generateKey = libsodium.generateKey;-export const _generateBlobOrStreamKey = libsodium.generateBlobOrStreamKey;-export const _encryptBox = libsodium.encryptBox;-export const _encryptBlob = libsodium.encryptBlob;-export const _encryptBlobBytes = libsodium.encryptBlobBytes;-export const _encryptMetadataJSON = libsodium.encryptMetadataJSON;-export const _encryptStreamBytes = libsodium.encryptStreamBytes;-export const _initChunkEncryption = libsodium.initChunkEncryption;-export const _encryptStreamChunk = libsodium.encryptStreamChunk;-export const _decryptBoxBytes = libsodium.decryptBoxBytes;-export const _decryptBox = libsodium.decryptBox;-export const _decryptBlobBytes = libsodium.decryptBlobBytes;-export const _decryptBlob = libsodium.decryptBlob;-export const _decryptMetadataJSON = libsodium.decryptMetadataJSON;-export const _decryptStreamBytes = libsodium.decryptStreamBytes;-export const _initChunkDecryption = libsodium.initChunkDecryption;-export const _decryptStreamChunk = libsodium.decryptStreamChunk;-export const _chunkHashInit = libsodium.chunkHashInit;-export const _chunkHashUpdate = libsodium.chunkHashUpdate;-export const _chunkHashFinal = libsodium.chunkHashFinal;-export const _generateKeyPair = libsodium.generateKeyPair;-export const _boxSeal = libsodium.boxSeal;-export const _boxSealOpen = libsodium.boxSealOpen;-export const _deriveKey = libsodium.deriveKey;-export const _deriveSensitiveKey = libsodium.deriveSensitiveKey;-export const _deriveInteractiveKey = libsodium.deriveInteractiveKey;diff --git a/web/packages/base/crypto/index.ts b/web/packages/base/crypto/index.tsindex e91b7166fe..49b2842a92 100644--- a/web/packages/base/crypto/index.ts+++ b/web/packages/base/crypto/index.ts@@ -9,7 +9,7 @@* [Note: Crypto code hierarchy]** 1. ente-base/crypto (Crypto API for our code)- * 2. ente-base/crypto/libsodium (Lower level wrappers over libsodium)+ * 2. ente-base/crypto/libsodium (The actual implementation)* 3. libsodium-wrappers (JavaScript bindings to libsodium)** Our cryptography primitives are provided by libsodium, specifically, its@@ -23,9 +23,16 @@* ensure that sodium.ready has been called before accessing libsodium's APIs,* thus all the functions it exposes are async.*- * The highest layer is this file, `crypto/index.ts`. These are usually direct- * proxies (or simple compositions) of functionality exposed by- * `crypto/libsodium.ts`, but they automatically defer to a worker thread.+ * The highest layer is this file, `crypto/index.ts`. These are direct proxies+ * to functions exposed by `crypto/libsodium.ts`, but they automatically defer+ * to a worker thread if we're not already running on one.+ *+ * [Note: Using libsodium in worker thread]+ *+ * `crypto/ente-impl.ts` and `crypto/worker.ts` are logic-less internal files+ * meant to allow us to seamlessly use the the same API both from the main+ * thread or from a web worker whilst ensuring that the implementation never+ * runs on the main thread.** Cryptographic operations like encryption are CPU intensive and would cause* the UI to stutter if used directly on the main thread. To keep the UI smooth,