A quantum-safe cryptographic signature implementation for the Samsung Gen AI Hack, utilizing post-quantum cryptography algorithms to sign and verify digital images.
This project implements quantum-resistant digital signatures using the Dilithium2 algorithm from the Open Quantum Safe (OQS) library. It provides functionality to sign images and verify their authenticity, protecting against tampering even in a post-quantum computing era.
- Quantum-Safe Signatures: Uses Dilithium2 algorithm for post-quantum security
- Image Signing: Sign JPEG images with quantum-resistant signatures
- Signature Verification: Verify image authenticity and detect tampering
- Cross-Platform: Works on Windows, Linux, and macOS
- Modern Python: Built with Python 3.13 and managed with uv
- Python 3.13 or higher
- Git (for cloning dependencies)
- C compiler (for building liboqs-python):
- Linux: gcc or clang
- Windows: Visual Studio Build Tools or MinGW
- macOS: Xcode Command Line Tools
To run this project, you will need to have the liboqs library compiled and installed on your system. You can find instructions on how to do this in the official liboqs GitHub repository.
Please be aware that you might encounter some issues while compiling the library.
You will also need to install the Python dependencies:
pip install -r requirements.txtuv is a fast Python package installer and resolver. Install it using one of the following methods:
curl -LsSf https://astral.sh/uv/install.sh | shpowershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"pip install uvbrew install uvAfter installation, verify uv is installed:
uv --versiongit clone https://github.com/raptor7197/signed-with-quantum.git
cd signed-with-quantumThe project requires Python 3.13. uv will automatically handle the Python version if you have it installed. Otherwise:
uv python install 3.13- Linux: Use your package manager or pyenv
- Windows: Download from python.org
- macOS: Use Homebrew (
brew install python@3.13) or download from python.org
uv will automatically create a virtual environment and install all dependencies:
# This single command creates .venv and installs all dependencies
uv syncThis command will:
- Create a
.venvdirectory with a Python 3.13 virtual environment - Install all dependencies from
pyproject.toml - Clone and build
liboqs-pythonfrom GitHub - Generate/update the
uv.lockfile
While uv can run commands directly in the virtual environment, you can also activate it manually:
source .venv/bin/activate.venv\Scripts\activate.bat.venv\Scripts\Activate.ps1/quantum-signers/backend/
├───.dockerignore
├───.gitignore
├───.python-version
├───Dockerfile
├───main.py
├───pyproject.toml
├───README.md
├───requirements.txt
├───test_implementation_with_image.py
├───test_implementation.py
└───images/
├───test_image_2.jpeg
└───test_image_for_wtv.jpeg
You can run Python scripts directly with uv without activating the virtual environment:
# Run the image signing example
uv run python main.py
# Run the test implementation
uv run python test_implementation.py
# Run the test implementation with Image
uv run python test_implementation_with_image.py
If you've activated the virtual environment:
# Run the image signing example
python main.py
# Run the test implementation
python test_implementation.pyfrom PIL import Image
import io
import oqs
# Load an image
img = Image.open("images/test_image_2.jpeg")
buffer = io.BytesIO()
img.save(buffer, format="JPEG")
image_bytes = buffer.getvalue()
# Create signature
with oqs.Signature("Dilithium2") as signer:
public_key = signer.generate_keypair()
signature = signer.sign(image_bytes)
# Verify signature
valid = signer.verify(image_bytes, signature, public_key)
print("Signature valid?", valid)To add new dependencies to the project:
# Add a production dependency
uv add package-name
# Add a development dependency
uv add --dev package-name
# Add a specific version
uv add "package-name>=1.0.0"# Update all dependencies to their latest compatible versions
uv sync --upgrade
# Update a specific package
uv add --upgrade package-name# Run tests with uv
uv run python -m pytest
# Or with activated environment
python -m pytestIf the liboqs-python build fails, ensure you have the required build tools: This Library has to be compiled from scratch from the Github repo so... This has been Included in the Dockerfile.
cd ..
git clone https://github.com/open-quantum-safe/oqs-python.git
cd oqs-python
pip install .
Linux:
sudo apt-get install build-essential cmake # Debian/Ubuntu
sudo dnf install gcc cmake make # Fedora
sudo pacman -S base-devel cmake # ArchWindows: Install Visual Studio Build Tools or MinGW-w64
macOS:
xcode-select --installIf uv can't find Python 3.13:
# Install Python 3.13 with uv
uv python install 3.13
# Or specify the Python path explicitly
uv venv --python /path/to/python3.13Run PowerShell as Administrator or adjust execution policy:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserEnsure the virtual environment exists:
# Recreate the virtual environment
uv venv --python 3.13
# Then sync dependencies
uv syncIf you encounter persistent issues:
# Remove virtual environment and lock file
rm -rf .venv uv.lock # Linux/macOS
rmdir /s .venv && del uv.lock # Windows CMD
# Reinstall everything
uv syncThe project uses the following main dependencies:
- liboqs-python: Post-quantum cryptography library (installed from GitHub, not PyPI)
- oqs (>=0.10.2): Open Quantum Safe Python bindings for post-quantum algorithms
- Pillow (>=11.3.0): Python Imaging Library for image processing
Other dependencies may be specified in pyproject.toml as needed for development or testing.
After Deploying the Backend you have to add the backend address field in the app and if you are running it locally (recommended) you should have the ip address with the port number
To run the application, you can use the following command:
uvicorn main:app --host 0.0.0.0 --port 8000After building the application, you will need to link the backend to the frontend by providing the backend URL to the frontend application. Click on the settings Icon in the application and it will lead you to the backend link input box.
A Dockerfile is provided for containerizing the application. However, there might be some issues with the library compilation and the Dockerfile when deploying the application.