Quantum-resistant hash functions and post-quantum cryptography for blockchain
Project description
Dirac Hashes
A next-generation cryptographic hash library built for speed, security, and quantum resistance.
About
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.
Features
- 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
Installation
Python Package
Install the package from PyPI:
pip install dirac-hashes
Install directly from GitHub:
pip install git+https://github.com/mk0dz/dirac-hashes.git
Or install from source:
git clone https://github.com/mk0dz/dirac-hashes.git
cd dirac-hashes
pip install -e .
Development Setup
For development, install the dev dependencies:
pip install -r requirements-dev.txt
Quick Start
from 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.
Project Structure
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
Web Interface
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
Tools
Benchmarking
Run performance benchmarks:
python tools/benchmark.py
Demo
Run the interactive demo:
python tools/demo.py
Docker Deployment
Docker 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-hashes
Or use Docker Compose:
docker-compose -f deployment/docker-compose.yml up
Future Development
- 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
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dirac_hashes-0.1.2.tar.gz.
File metadata
- Download URL: dirac_hashes-0.1.2.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1849fbd831fa32a51b11c3453aff004ff88d9fb0c4fb4fe82bcd1e83f7fec45
|
|
| MD5 |
8a579e06c27bc4c09a37e86ce380f333
|
|
| BLAKE2b-256 |
fd034fe96094bbab64429ece19c67cce7afc5cdcf497bafc66905f2643487e8c
|
Provenance
The following attestation bundles were made for dirac_hashes-0.1.2.tar.gz:
Publisher:
publish.yml on mk0dz/dirac-hashes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirac_hashes-0.1.2.tar.gz -
Subject digest:
d1849fbd831fa32a51b11c3453aff004ff88d9fb0c4fb4fe82bcd1e83f7fec45 - Sigstore transparency entry: 205069511
- Sigstore integration time:
-
Permalink:
mk0dz/dirac-hashes@e144413bc3c19401eeab52542d8285a2ab02a4da -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mk0dz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e144413bc3c19401eeab52542d8285a2ab02a4da -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dirac_hashes-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dirac_hashes-0.1.2-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
533024616b5a2d3432f9868b044188aa32a38af2311521bf5294aaaf25d65979
|
|
| MD5 |
dff26a395fe4558882bd56228d9ad2c1
|
|
| BLAKE2b-256 |
7a1dc912fb9b4ac67a0021c9d98edd8565abc7e330fcd2c03ea28dad51e999f8
|
Provenance
The following attestation bundles were made for dirac_hashes-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on mk0dz/dirac-hashes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirac_hashes-0.1.2-py3-none-any.whl -
Subject digest:
533024616b5a2d3432f9868b044188aa32a38af2311521bf5294aaaf25d65979 - Sigstore transparency entry: 205069513
- Sigstore integration time:
-
Permalink:
mk0dz/dirac-hashes@e144413bc3c19401eeab52542d8285a2ab02a4da -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mk0dz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e144413bc3c19401eeab52542d8285a2ab02a4da -
Trigger Event:
workflow_dispatch
-
Statement type: