This project implements a file system where clients can upload directories containing files to a server, and later download and verify these files using a Merkle tree for integrity checks. The system ensures that files are not tampered with during storage or transmission.
The client application provides an interactive CLI for uploading directories and downloading files.
- The files to be uploaded are located in
./client/cmd/local_files
. - The client will upload all files in the directory to the server and delete the local copies.
- The client will compute a Merkle tree root hash and save it to
merkle_root.txt
.
- Enter the name of the file to download.
- The client will download the file and the Merkle proof from the server.
- The client will verify the file integrity using the Merkle proof and the root hash stored in
merkle_root.txt
.
The server handles file uploads and downloads.
- URL:
/upload
- Method:
POST
- Description: Accepts file uploads and updates the Merkle tree with the file hash.
- URL:
/download/{fileName}
- Method:
GET
- Description: Provides the requested file and its Merkle proof.
Nginx is configured as a reverse proxy to handle client requests securely and efficiently.
- Configuration: The Nginx configuration is located in the
nginx/nginx.conf
file. - HTTPS: Nginx is set up with a self-signed certificate for dev environment HTTPS communication.
- Proxying: Nginx forwards incoming client requests to the backend Go server, ensuring that clients cannot access the server directly.
- Go 1.18 or later
- Docker
- Docker Compose
After cloning the repo open a terminal on its root and:
Launch the docker-compose containing the nginx and server containers
docker-compose up
Then open a separate terminal on the repo root and:
Run the client application
cd client/cmd
go run main.go
After having both the server and client running, interact with the CLI on the client terminal to :
- Upload the
local_files
directory, containing the filesf1
,f2
andf3
. - Succsessfully download and verify the
f1
file from the server. - On a separate terminal, log into the server container to tamper with the
f2
file. - Back on the CLI ,download the
f2
file and verify that we can't compute the original merkle tree root hash with the returned proof.