Blockchain Drive encrypts files in your browser before they are sent to the server. The encryption key is itself encrypted with your MetaMask wallet’s public key and stored alongside the file metadata. The server stores only ciphertext — it cannot read your files without your wallet’s approval.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ankit-bista/Final-Project/llms.txt
Use this file to discover all available pages before exploring further.
How encryption works
When you choose to encrypt a file, the following happens entirely in your browser:- A random 16-byte salt and a random 12-byte IV (initialization vector) are generated.
- Your password (or a key derived from your MetaMask wallet) is passed through PBKDF2 with SHA-256 to produce the encryption key.
- The file is encrypted using ChaCha20-Poly1305 (an authenticated stream cipher), producing ciphertext and an authentication tag.
- A keyed BLAKE2b tag is computed over the nonce, ciphertext, and cipher auth tag to provide an additional integrity check.
- The raw encryption key is encrypted with your wallet’s public key using
encryptForPublicKeyfromlib/file-cryptoand stored asownerEncryptedKeyin the file metadata.
Encryption methods
Two methods are available. Both use the same underlying cipher (ChaCha20-Poly1305) and key size (256-bit), but differ in PBKDF2 iteration count, which controls how long key derivation takes and therefore how resistant the key is to brute-force attacks.| Method | PBKDF2 iterations | Estimated speed | Best for |
|---|---|---|---|
| AES-128 | 10,000 | ~80 MB/s | Large files, frequent access |
| AES-256 | 100,000 | ~45 MB/s | Sensitive files, infrequent access |
Despite the names “AES-128” and “AES-256”, both methods use a 32-byte (256-bit) key with ChaCha20-Poly1305. The names reflect the security tier, not the cipher key size.
Security parameters
Random salt — 16 bytes
Random salt — 16 bytes
A fresh 16-byte random salt is generated for each encryption operation using
crypto.randomBytes(16). This ensures that two encryptions of the same file with the same password produce different keys and ciphertexts.Random IV — 12 bytes
Random IV — 12 bytes
The IV (nonce) for ChaCha20-Poly1305 is 12 bytes, generated with
crypto.randomBytes(12). It is stored in the file metadata and used during decryption.Authenticated encryption
Authenticated encryption
ChaCha20-Poly1305 is an AEAD (Authenticated Encryption with Additional Data) cipher. The 16-byte Poly1305 authentication tag ensures that any tampering with the ciphertext is detected before decryption proceeds.
Keyed BLAKE2b integrity tag
Keyed BLAKE2b integrity tag
A 256-bit BLAKE2b tag is computed over the nonce, ciphertext, and Poly1305 auth tag using the derived key. Decryption fails immediately if this tag does not match, before the cipher auth tag is even checked.
PBKDF2 key derivation
PBKDF2 key derivation
Keys are derived from passwords using PBKDF2-SHA256. AES-128 uses 10,000 iterations; AES-256 uses 100,000 iterations. The iteration count makes dictionary attacks significantly more expensive.
Uploading an encrypted file
Choose a method
Select AES-128 or AES-256 from the method dropdown. You can also request a time estimate from the server before committing.
Enter a password or use your wallet key
Enter a strong password, or choose the MetaMask option to derive the key from your connected wallet account. The app calls
encryptForPublicKey to wrap the raw key under your wallet’s public key.Downloading an encrypted file
App fetches crypto metadata
The app calls
GET /files/:id/crypto, which returns the algorithm, IV, and the version of the encrypted key appropriate for the requester — the owner’s wrapped key, or a re-encrypted key if the file was shared with you.MetaMask decrypts the key
The app calls
decryptWithMetaMask (from lib/file-crypto), which prompts your wallet to decrypt the wrapped key using your private key. You must approve this in the MetaMask extension.Crypto metadata endpoint
The/files/:id/crypto endpoint returns everything needed to decrypt a file. Recipients of shared encrypted files receive their own encryptedKey (re-encrypted for their public key); owners receive the ownerEncryptedKey.
Sharing encrypted files
When you share an encrypted file or drive, the app must re-encrypt the file’s raw key for the recipient’s public key so they can decrypt it with their own wallet. See Sharing for the full workflow. The re-encryption process usesencryptForPublicKey(recipientPublicKey, rawKey) from lib/file-crypto. The recipient’s public key is fetched from /share-target?identifier=<username>. If the recipient has never logged in with MetaMask, they will not have a public key registered and the share cannot include encrypted file access.