This project implements a two-party secure computation protocol using Homomorphic Encryption (HE), enabling privacy-preserving arithmetic operations on encrypted data. The protocol follows the client-server model where:
-
The Client encrypts input data and selects an operation.
-
The Server performs the desired operation without decrypting the data.
-
The encrypted result is sent back to the client.
Built with TenSEAL, the protocol supports multiple HE schemes (BFV, Paillier, CKKS) for integer and floating-point operations, featuring a user-friendly Tkinter GUI.
| Schemes | Supported Operations |
|---|---|
| CKKS | Addition, Subtraction, Multiplication, Division, Square, Cube, Percentage, Dot product, Matrix Multiplication |
| BFV | Addition, Subtraction, Multiplication, Square, Cube, Dot product, Matrix Multiplication |
| Paillier | Addition, Subtraction, Private set membership |
-
🚀 Multi-scheme Support:
BFV: Used only for integer arithmetic. Paillier: Used for additive homomorphic encryption. CKKS: Used for real or floating-point arithmetic. -
🔒 Secure Socket Communication:
Encrypted data transmission via socket programming. The server performs the computation on the encrypted data. -
🎨 Graphical User Interface:
Intuitive Tkinter-based client interface. Real-time encrypted result display. -
⚙️ Cross-platform Compatibility:
Tested on Windows and Linux environments.
-> https://www.python.org/downloads/
-
If pip is missing, do this:
-
Download get-pip.py from:
https://bootstrap.pypa.io/get-pip.py (Right-click → Save ) -
Open the Command Prompt where the file is saved.
Run this: python get-pip.py Upgrade pip: python -m pip install --upgrade pip
-
Install numpy
pip install numpy -
Install TenSEAL
pip install tenseal
ℹ️ Note: socket, pickle, and tkinter are built-in with Python on Windows, so no need for separate installation.
sudo apt update
sudo apt install python3
sudo apt update
sudo apt install python3-pip
sudo apt update
pip3 install numpy
pip3 install tenseal
sudo apt update
sudo apt-get install python3-tk
- Python 3
- TenSEAL✅ (Homomorphic Encryption Library)
- Socket Programming✅
- Tkinter✅ (GUI for Client)
- Pickle✅ (Serialization)
-
-
Start the Server
python3 server.py
Server runs on 127.0.0.1:12345 by default
-
-
-
Launch the Client GUI
python3 client.py
-
-
-
Perform Operations:
-
Enter the required data
-
Select the encryption scheme
-
Select the arithmatic operation (buttons auto-adjust based on scheme)
-
The final result is decrypted and it is shown in the output box of the GUI
-
-
| Operation | BFV | Paillier | CKKS |
|---|---|---|---|
| Addition | ✅ | ✅ | ✅ |
| Subtraction | ✅ | ✅ | ✅ |
| Multiplication | ✅ | ❌ | ✅ |
| Division | ❌ | ❌ | ✅ |
| Square / Cube | ✅ | ❌ | ✅ |
| Percentage | ❌ | ❌ | ✅ |
| Dot Product | ✅ | ❌ | ✅ |
| Private Set Membership | ✅ | ✅ | ❌ |
| Matrix multiplication | ✅ | ❌ | ✅ |
homomorphic-calculator/
├── client.py # GUI client application
├── server.py # HE computation server
├── README.md # This documentation
└── requirements.txt # Dependencies
| Issue | Solution |
|---|---|
| ImportError: No module named 'tenseal' | Run pip install tenseal |
| Socket connection errors | Verify the server is running before starting the client |
| Paillier division attempts | Use the CKKS scheme for division operations |
Ideal for:
-
Privacy-preserving cloud computations
-
Secure medical data analysis
-
Confidential financial modelling