A next-generation cryptographic hash library built for speed, security, and quantum resistance.
Dirac Hashes is a project aimed at developing and testing high-performance cryptographic hash functions that are resistant to quantum computing attacks. This repository contains a Python package implementing quantum-resistant hash functions, digital signature schemes, and key encapsulation mechanisms (KEM), plus tools for testing and comparing their performance.
- Quantum-resistant hash algorithms:
- Improved (default, recommended)
- Grover
- Shor
- Hybrid
- Improved Grover
- Improved Shor
- Post-quantum signature schemes:
- Dilithium (NIST standard)
- SPHINCS+
- Lamport
- Key Encapsulation Mechanisms (KEM):
- Kyber (NIST standard)
- Web-based testing interface with performance visualization
- Simple Python API for integration into other projects
Install the package from PyPI:
pip install dirac-hashesInstall directly from GitHub:
pip install git+https://github.com/mk0dz/dirac-hashes.gitOr install from source:
git clone https://github.com/mk0dz/dirac-hashes.git
cd dirac-hashes
pip install -e .For development, install the dev dependencies:
pip install -r requirements-dev.txtfrom quantum_hash.dirac import DiracHash
from quantum_hash.signatures.dilithium import DilithiumSignature
# Generate a hash
message = "Hello, quantum world!"
hash_value = DiracHash.hash(message)
print(f"Hash: {hash_value.hex()}")
# Generate a key pair
dilithium = DilithiumSignature()
private_key, public_key = dilithium.generate_keypair()
# Sign a message
signature = dilithium.sign(message.encode(), private_key)
# Verify the signature
is_valid = dilithium.verify(message.encode(), signature, public_key)
print(f"Signature valid: {is_valid}")For more examples, see the examples directory.
dirac-hashes/
├── deployment/ # Docker and deployment files
├── docs/ # Documentation files
├── examples/ # Example scripts
├── src/ # Python package source
│ └── quantum_hash/ # Main package
│ ├── core/ # Core algorithms
│ ├── signatures/ # Signature schemes
│ ├── kem/ # Key encapsulation
│ └── utils/ # Utility functions
├── tests/ # Test suite
├── tools/ # Benchmark and demo tools
├── web/ # Web interface and API
├── README.md # This file
└── setup.py # Package setup
To run the web interface locally:
-
Install dependencies:
pip install -r requirements-dev.txt
-
Run the API server:
python web/run_api.py
-
In another terminal, serve the frontend:
python web/serve_frontend.py
-
Open
http://localhost:8000in your browser
Run performance benchmarks:
python tools/benchmark.pyRun the interactive demo:
python tools/demo.pyDocker files are provided in the deployment directory for containerized deployment:
docker build -t dirac-hashes -f deployment/Dockerfile .
docker run -p 8000:8000 -p 8080:8080 dirac-hashesOr use Docker Compose:
docker-compose -f deployment/docker-compose.yml up- Implementation of Dirac hash algorithms in Rust and WebAssembly
- Integration with Solana blockchain for high-performance verification
- Command-line tools for batch processing
- Integration tests for cryptographic properties
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.