Skip to content

Koreapanda4444/Fractal-Crypt-Hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fractal Crypt-Hash (FCH)

Fractal Crypt-Hash (FCH) is an experimental cryptographic hash function based on a fractal (self-similar) recursive structure rather than traditional round-based compression.


Security Notice (Read First)

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.


Overview

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.

Features

  • 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

Supported Variants

Variant Output Size Internal State
FCH-256 256 bits 4 × uint64
FCH-512 512 bits 8 × uint64

Usage

uint8_t out256[32];
uint8_t out512[64];

fch_hash_256(data, len, out256);
fch_hash_512(data, len, out512);

Buffered streaming API

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);

CLI

Build the CLI:

cd build
make all

Hash a file:

./fch -256 path/to/file
./fch -512 path/to/file

Hash stdin:

cat path/to/file | ./fch -256

Testing

The 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.c
  • tests/test_consistency.c
  • tests/test_boundaries.c
  • tests/test_invariants.c
  • tests/test_vectors.c

Build/run:

cd build
make test
./test_consistency
./test_boundaries
./test_invariants
./test_avalanche
./test_vectors

If 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors