This project implements and evaluates a novel two-stage cryptographic hash that combines the chaotic step-counts of the Collatz Conjecture with the cryptographic strength of SHA-256. Each input integer is first mapped to an eight-byte “Collatz hash” (the XOR of the original number and its Collatz iteration count), then SHA-256 is applied to that intermediate—injecting extra entropy without altering standard security guarantees.
We provide four implementations:
- Sequential (
two_stage_sha256_sequential.c) - OpenMP (
omp1.c) — shared-memory multithreading - MPI (
mpi.c) — distributed-memory message passing - Hybrid MPI+OpenMP (
hybrid.c) — intra-node threading combined with inter-node distribution
Comprehensive scaling studies on a 16-core Skylake cluster demonstrate:
- Up to 6× speedup with OpenMP (16 threads, ~90 % efficiency)
- Modest gains up to 1.15× with MPI (4 ranks)
- 3× combined improvement with Hybrid (4 ranks × 4 threads)
Stage-wise timing and Amdahl’s Law analysis reveal that ~65 % of runtime is spent in Collatz sequence generation and ~35 % in SHA-256 mixing.
- Linux or Unix-like OS
- GCC 10.2+ (with OpenMP support)
- OpenSSL (dev headers & libs)
- OpenMPI 4.0.3+
make,git, Python 3, and standard build tools
For optimal performance:
- Disable hyper-threading (to avoid SMT sharing penalties)
- Enable NUMA-aware allocation (e.g.
numactl --interleave=all) - Use a fast interconnect (InfiniBand) for MPI runs
.
├── README.md
├── Makefile
├── bin/ # Compiled binaries
├── src/
│ ├── sequential.c
│ ├── omp1.c
│ ├── mpi.c
│ └── hybrid.c
├── results/ # Raw log files and CSVs
└── docs/
├── parallel-crypto-hash.tex
└── figures/ # PDF/PNG for paper inclusion
From the project root, run:
make allThis will compile and place executables into bin/:
bin/sequentialbin/openmpbin/mpibin/hybrid
You can also build individual targets:
make sequential # two_stage_sha256_sequential
make openmp # omp1
make mpi # mpi
make hybrid # hybridAll binaries accept optional start/end arguments; defaults are start=1000000, end=2000000.
./bin/sequential [start] [end]export OMP_NUM_THREADS=16
./bin/openmp [start] [end]mpirun -np 4 ./bin/mpi [start] [end]export OMP_NUM_THREADS=4
mpirun -np 4 ./bin/hybrid [start] [end]Each run prints:
- Stage 1 (Collatz) time
- Stage 2 (SHA-256) time
- Total compute time
- Final 32-byte digest
| Variant | Resources | Time (s) | Speedup | Efficiency |
|---|---|---|---|---|
| Sequential | 1 core | 1.080 | 1.00× | 100 % |
| OpenMP | 16 threads | 0.179 | 6.03× | 94 % |
| MPI | 4 ranks | 0.929 | 1.16× | 29 % |
| Hybrid | 4 ranks × 4 thr | 0.364 | 2.97× | 19 % |
Refer to the docs/parallel-crypto-hash.tex for full tables and graphs.
- Fork the repository.
- Clone your fork and create a feature branch:
git clone https://github.com/YourUsername/collatz-sha256-parallel.git cd collatz-sha256-parallel git checkout -b feature/awesome-improvement - Implement your changes, run tests/benchmarks.
- Push and open a Pull Request with a clear description and performance impact.