A zero-knowledge encrypted file vault where the server can never see your password or your files.
KGV is a client-server system that lets you store files in a remote vault without trusting the server. Two layers of cryptography make this possible:
-
Your password never leaves your machine. Authentication uses the Secure Remote Password (SRP) protocol — the server verifies you know the password through a mathematical proof, without ever receiving the password itself.
-
Your files are encrypted before upload. The client derives a strong 256-bit AES key from your password locally (using PBKDF2 with 480,000 iterations), encrypts your files with AES-256-GCM, and only sends the ciphertext. The server stores it as-is.
Bottom line: If the server is breached, the attacker gets nothing — no passwords (only SRP verifiers) and no readable files (only AES ciphertext they can't decrypt).
- Python 3.8 or higher
- pip (Python package manager)
cd /path/to/KGV
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtThis installs two packages:
srp— Secure Remote Password protocolcryptography— AES-256-GCM encryption and PBKDF2 key derivation
Open a terminal and run:
source venv/bin/activate
python3 kgv_server.pyYou'll see:
╔══════════════════════════════════════════════════════╗
║ KGV — Krypt Guard Vault | Server ║
║ Zero-Knowledge Encrypted Storage ║
╚══════════════════════════════════════════════════════╝
Listening on : 127.0.0.1:65432
Vault directory: /path/to/KGV/kgv_vault/
⚠ The server NEVER sees passwords or plaintext files.
Open a second terminal and run:
source venv/bin/activate
python3 kgv_client.pyYou'll see an interactive menu.
- Select option 1 from the menu.
- Enter a username and password.
- The client computes an SRP verifier and sends it to the server. Your password stays on your machine.
- Select option 2.
- Enter your credentials.
- The SRP handshake runs — both sides verify each other through mathematical proofs.
- On success, a local AES-256 key is derived from your password. This key never leaves your machine.
- Select option 3 (after logging in).
- Type a filename and the secret text.
- The text is encrypted locally with AES-256-GCM, then only the ciphertext is sent.
- Select option 4.
- Give the path to any file on your machine.
- The file is encrypted and uploaded as
<filename>.enc.
- Select option 5.
- Enter the filename.
- The ciphertext is downloaded and decrypted locally using your AES key.
- The decrypted file is saved to the
kgv_downloads/directory.
- Select option 6 to see all your encrypted files on the server.
- Select option 7.
- Enter the filename. Confirm the deletion.
KGV/
├── kgv_server.py # Vault server (SRP auth + ciphertext storage)
├── kgv_client.py # Interactive client (encryption + SRP)
├── kgv_test.py # Automated end-to-end test suite (11 tests)
├── requirements.txt # Python dependencies
├── README.md # This file
├── kgv_vault/ # (auto-created) Server stores encrypted blobs here
└── kgv_downloads/ # (auto-created) Client saves decrypted files here
This is useful for demonstrations, thesis defenses, or audits.
After uploading a file, open the kgv_vault/ folder. Every file is pure hexadecimal ciphertext — unreadable without the client's AES key.
cat kgv_vault/testuser_my_secret.enc
# Output: a3f7c2... (meaningless ciphertext)The server terminal will print messages like:
[✓] Registered user 'testuser' — verifier stored, password NEVER seen
[✓] Auth complete — 'testuser' verified (password NEVER transmitted)
[↑] Stored 'my_secret.enc' for 'testuser' — server has NO decryption key
The server code has:
- No password variable — only SRP verifiers (one-way mathematical values).
- No AES key — the key is derived only inside
kgv_client.py. - No decryption function — the server literally cannot decrypt the stored files.
python3 kgv_test.pyThis runs 11 automated checks including registration, authentication, encrypted upload, download, decryption, deletion, and unauthorized access rejection.
Client Server
│ │
│── REGISTER: salt + verifier ──────────→ │ Password NEVER sent
│ │ (only SRP verifier stored)
│ │
│── AUTH_STEP1: sends A ────────────────→ │
│←── Challenge: salt + B ────────────────│
│── AUTH_STEP2: sends M (proof) ────────→ │
│←── Mutual proof: HAMK ────────────────│
│ │
✓ Both sides verified. ✓
AandBare ephemeral public values.Mis a proof the client knows the password.HAMKis a proof the server knows the verifier.- The password itself is never part of any message.
Password ──→ PBKDF2 (480K iterations) ──→ 256-bit AES Key (local only)
│
Plaintext ──→ AES-256-GCM + random nonce ──→ Ciphertext ──→ Sent to server
- PBKDF2 with 480,000 iterations makes brute-force attacks infeasible.
- AES-256-GCM provides both encryption and tamper detection.
- A fresh random 96-bit nonce is generated for every encryption.
- The AES key exists only in client memory — it is never stored or sent.
| Feature | Description |
|---|---|
| Length-prefixed messaging | 4-byte header prevents TCP partial-read bugs |
| Input validation | Usernames, filenames, and hex values are validated |
| Filename sanitization | Path traversal attacks (../) are blocked |
| Socket timeouts | 5-minute idle timeout; 30-second connect timeout |
| Graceful shutdown | Server handles SIGINT/SIGTERM cleanly |
| Thread safety | User database protected by a mutex lock |
| Password masking | Passwords are hidden during input (via getpass) |
| Message size limit | 10 MB hard cap prevents memory exhaustion |
| Duplicate user check | Re-registering an existing username is rejected |
| Threat | Protected? | How |
|---|---|---|
| Server breach — passwords stolen | ✅ Yes | Server stores only SRP verifiers (one-way; not reversible) |
| Server breach — files stolen | ✅ Yes | Files are AES-256-GCM ciphertext; key only exists on client |
| Man-in-the-middle on login | ✅ Yes | SRP provides mutual authentication without transmitting the password |
| Replay attacks | ✅ Yes | SRP uses ephemeral values; AES-GCM uses random nonces |
| Brute-force password cracking | ✅ Yes | PBKDF2 with 480,000 iterations makes each guess very expensive |
| Path traversal attacks | ✅ Yes | Filenames are sanitized; ../ and / are rejected |
| Unauthorized file access | ✅ Yes | Every command except REGISTER requires a valid SRP session |
Make sure the server is running in a separate terminal, then:
source venv/bin/activate
python3 kgv_test.pyExpected output:
[KGV TEST] Connected to Krypt Guard Vault server
[KGV TEST] ✓ Registration successful
[KGV TEST] ✓ Duplicate registration correctly rejected
[KGV TEST] ✓ Auth Step 1 — challenge received
[KGV TEST] ✓ Auth Step 2 — zero-knowledge authentication complete
[KGV TEST] ✓ Encrypted upload successful
[KGV TEST] ✓ File listing OK: ['test_secret.enc']
[KGV TEST] ✓ Download & decrypt OK: TOP SECRET: The answer is 42.
[KGV TEST] ✓ Server stores pure ciphertext (114 hex chars)
[KGV TEST] ✓ File deletion successful
[KGV TEST] ✓ File list is empty after delete
[KGV TEST] ✓ Unauthenticated upload correctly rejected
[KGV TEST] ALL 11 TESTS PASSED ✓
This project is provided for educational and demonstration purposes.