Fractal Crypt-Hash (FCH) is an experimental cryptographic hash function based on a fractal (self-similar) recursive structure rather than traditional round-based compression.
FCH is a research / experimental hash design and reference implementation. It has not undergone broad public cryptanalysis or independent security review.
Do not use FCH in production or for security-critical purposes, including (but not limited to):
- authentication, signatures, tokens, or MACs
- password hashing / key derivation
- integrity checks where adversaries exist
- any scenario where a broken hash causes harm
This repository is intended for learning, experimentation, benchmarking, and discussion.
Unlike conventional hash functions that rely on repeated rounds, FCH achieves diffusion through recursive fractal decomposition.
A small change in the input propagates:
- locally at leaf nodes,
- recursively through variable n-way splits,
- and globally at the root via recompression.
- Fractal recursive hash structure
- Variable n-way (2–6) pattern-based splitting
- Order-dependent tree recombination
- Minimal non-linearity at leaf level (XOR / ADD / ROTATE / S-box)
- Recompression at each internal node
- Deterministic, non-keyed hash function
| Variant | Output Size | Internal State |
|---|---|---|
| FCH-256 | 256 bits | 4 × uint64 |
| FCH-512 | 512 bits | 8 × uint64 |
uint8_t out256[32];
uint8_t out512[64];
fch_hash_256(data, len, out256);
fch_hash_512(data, len, out512);FCH also provides a buffered streaming API: data is accumulated in memory and hashed on finalization.
#include "fch_stream.h"
fch256_ctx ctx;
fch256_init(&ctx);
fch256_update(&ctx, chunk1, chunk1_len);
fch256_update(&ctx, chunk2, chunk2_len);
fch256_final(&ctx, out256);
fch256_free(&ctx);Build the CLI:
cd build
make allHash a file:
./fch -256 path/to/file
./fch -512 path/to/fileHash stdin:
cat path/to/file | ./fch -256The implementation includes:
- Statistical avalanche tests (length/bit diffusion)
- Determinism tests (same input → same output)
- Boundary condition tests
- Structural invariant tests (split coverage)
The reference implementation includes extensive tests for determinism, boundary conditions, structural invariants, and statistical diffusion behavior.
Test programs:
tests/test_avalanche.ctests/test_consistency.ctests/test_boundaries.ctests/test_invariants.ctests/test_vectors.c
Build/run:
cd build
make test
./test_consistency
./test_boundaries
./test_invariants
./test_avalanche
./test_vectorsIf make is unavailable (Windows), you can compile directly with gcc:
gcc -Wall -Wextra -O2 -Iinclude tests/test_consistency.c src/*.c -o build/test_consistency.exe
gcc -Wall -Wextra -O2 -Iinclude tests/test_boundaries.c src/*.c -o build/test_boundaries.exe
gcc -Wall -Wextra -O2 -Iinclude tests/test_invariants.c src/*.c -o build/test_invariants.exe
gcc -Wall -Wextra -O2 -Iinclude tests/test_avalanche.c src/*.c -o build/test_avalanche.exe
gcc -Wall -Wextra -O2 -Iinclude tests/test_vectors.c src/*.c -o build/test_vectors.exe
gcc -Wall -Wextra -O2 -Iinclude tools/fch.c src/*.c -o build/fch.exe
build\\fch.exe -256 README.md