Skip to content

armgit / ente

Public Imported from GitHub
0

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

More

Manav Rathi1a6ae93a7ac0
diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.ts
index 935374208d..95e05f66a5 100644
--- a/web/packages/base/crypto/libsodium.ts
+++ b/web/packages/base/crypto/libsodium.ts
@@ -177,7 +177,29 @@ export async function fromHex(input: string) {
*
* "File" is not a term of art, it is just something we use to abbreviate
* "streaming encryption in one-shot mode".
+ *
+ * The distinction between Box and File is also handy since not only does the
+ * underlying algorithm differ, but also the terminology that libsodium use for
+ * the nonce.
+ *
+ * 1. When using the secretbox APIs, the nonce is called the "nonce", and needs
+ * to be provided by us (the caller).
+ *
+ * 2. When using the secretstream APIs, the nonce is internally generated by
+ * libsodium and provided by libsodium to us (the caller) as a "header".
+ *
+ * However, even for case 1, the functions we expose from libsodium.ts generate
+ * the nonce for the caller. So for higher level functions, the difference
+ * between Box and File encryption is:
+ *
+ * 1. Box uses Salsa, File uses ChaCha.
+ *
+ * 2. While both are one-shot, File should generally be used for data
+ * associated with an Ente object, and Box for the other cases.
+ *
+ * 3. Box returns a "nonce", while File returns a "header".
*/
+
/**
* Encrypt the given file data using the given (base64 encoded) key.
*