“We encrypt client-side” sounds like one line in a security checklist, next to TLS and password hashing. In practice, encrypting data before it leaves the machine that produced it is an architectural commitment. It changes what every other part of the system can assume about the data. If a server only ever sees ciphertext, it has to be designed as if it can’t be trusted with the content, because it can’t reconstruct it.
Encrypting at the server instead means the server sees plaintext at some point in its pipeline, even briefly. It encrypts before persisting, but it can read the data. With client-side encryption the server stores and moves bytes it cannot interpret, and every feature that would need to interpret them has to be redesigned around ciphertext or dropped.
What breaks first: deduplication
Deduplication is the clearest casualty. It is easy to build correctly against plaintext and easy to build wrong against ciphertext without noticing.
SecStore, a small erasure-coded object store, dedupes uploads by hashing the file and checking for an existing row with the same hash before doing any erasure-coding work:
# coordinator/main.py
async def core_upload(filename: str, file_bytes: bytes, k: int, n: int, encryption_iv: str = None):
content_hash = get_hash(file_bytes)
...
cursor.execute(
'SELECT file_id, version_id, original_size, padding_len, k, n, manifest '
'FROM files WHERE content_hash = ? LIMIT 1',
(content_hash,)
)
existing = cursor.fetchone()
if existing:
...
return {"message": "Deduplicated successfully", "filename": filename, "deduplicated": True}
Encryption happens on the client, before the HTTP upload, in client.py:
# client.py
def encrypt_data(data: bytes, key: bytes):
aesgcm = AESGCM(key)
iv = os.urandom(12)
ciphertext = aesgcm.encrypt(iv, data, None)
return iv, ciphertext
# client.py, upload()
iv, file_bytes = encrypt_data(file_bytes, key)
...
resp = requests.post(f"{COORDINATOR_URL}/upload/",
files={"file": (os.path.basename(args.local_path), file_bytes)},
data={"k": args.k, "n": args.n, ...})
By the time file_bytes reaches core_upload and gets hashed, it’s already ciphertext, so content_hash is a hash of the encrypted output. AES-GCM uses a fresh random 12-byte IV on every call to encrypt_data, so encrypting the exact same file twice produces two different ciphertexts and two different hashes. Upload the identical document twice with --encrypt, and the server has no way to know they’re the same file. Deduplication works on plaintext and silently stops doing anything once encryption is on. Nothing raises an error; the code always takes the “no match, store a new copy” branch.
This follows directly from the server never seeing the plaintext, so there is no bug to patch. Getting dedup back would mean deduplicating on a plaintext hash computed client-side and sent alongside the ciphertext, which trades some confidentiality (the server now learns which uploads share content, an information leak of its own) for the storage savings. You can’t have server-side dedup and a server that’s fully blind to content at the same time. You pick one, and it’s better to pick deliberately than to find out when the storage bill doesn’t match expectations.
What still works, because it never needed plaintext
SecStore’s erasure coding, integrity checks and replication topology work on ciphertext exactly as they would on plaintext. None of that logic interprets the bytes; it only splits them, checksums them and puts them back together:
# coordinator/main.py, download_file()
if isinstance(r, Exception) or r.status_code != 200 or get_hash(r.content) != meta_list[i]["hash"]:
missing.append(idx_list[i])
The per-chunk SHA-256 check works the same on plaintext or ciphertext, because it only asks “are these the bytes I wrote?” and never “what do these bytes mean?” In general, anything defined purely over the byte stream keeps working. Anything that needs to understand or compare content (deduplication, full-text search, thumbnail generation, virus scanning) stops working or has to move to the client.
What the server never has: the key
The AES-256 key is generated client-side and kept in a local keyring file; only the per-file IV travels with the upload, as a request field and later a response header:
# client.py
key = AESGCM.generate_key(bit_length=256)
key_b64 = base64.b64encode(key).decode()
print(f"[!] Generated new encryption key (Please copy/save this!): {key_b64}")
save_key(args.remote_path, key_b64)
The IV doesn’t need to be secret. GCM’s security depends on the key staying secret and the IV never repeating under the same key, so sending the IV to the server is safe. Sending the key is not: once the server has both ciphertext and key, whoever controls the server can decrypt on demand, and “client-side encryption” is just encryption in transit. A coordinator that’s compromised, subpoenaed or misconfigured to log request bodies still can’t produce plaintext, because it never had the key.
Deciding up front
Choosing client-side encryption is a different kind of decision from AES-256 versus AES-128 or GCM versus CBC. It decides which component may understand the data, and it has to be made before you design any feature that wants to inspect, index or deduplicate that data on the server. If you choose it, the server is infrastructure for opaque bytes: it can store, replicate and verify them, and it can never answer a question that requires reading them. A feature request that assumes the server can see the content is a request to reopen that decision, and it should be treated as one instead of being quietly built as a compromise.