Skip to content

jamylak/xxhash3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

xxHash3 Len=8 Visualizer

AI Generated Visualizer finetuned for intuition not code quality

xxhash3.mov

Small standalone C/raylib program that visualizes the exact XXH3_64bits path used for one specific case:

  • input text: "xxhash3!"
  • input length: 8
  • seed: 0
  • secret source: the built-in XXH3 default secret

This repository is not an xxhash3 library and it does not implement the full family of XXH3 code paths. The app is an interactive teaching/inspection tool for the len=8 64-bit path only.

What The Program Shows

The program walks through the concrete values and bit-level transformations for:

  1. Packing the 8-byte input into the input64 value used by the len=8 entry path.
  2. Building the bitflip value from readLE64(secret + 8), readLE64(secret + 16), and seed'.
  3. Computing keyed = input64 XOR bitflip.
  4. Running the first XXH3_rrmxmx XOR/rotate stage.
  5. Multiplying by PRIME_MX2.
  6. Applying h ^= (h >> 35) + len.
  7. Multiplying by PRIME_MX2 again.
  8. Applying the final h ^= h >> 28.
  9. Emitting the final 64-bit hash.
  10. Showing a 64x64 avalanche grid for single-bit flips of the input64 value.

Most pages animate the operation step-by-step and let you hover bits or bytes to inspect how values move through the transform.

Pages

The UI has ten pages, selected with the top bar or number keys:

  • 0: overview of the exact path and current concrete values
  • 1: input packing and first keyed XOR (input64 XOR bitflip)
  • 2: bitflip expansion from the default secret windows and seed adjustment
  • 3: first rrmxmx XOR/rotate step
  • 4: first multiply by PRIME_MX2
  • 5: h ^= (h >> 35) + len
  • 6: second multiply by PRIME_MX2
  • 7: final h ^= h >> 28
  • 8: returned 64-bit hash bytes and final value
  • 9: avalanche grid for one-bit input flips

Requirements

  • cc or another C compiler
  • raylib
  • optionally pkg-config

The Makefile first tries pkg-config --cflags raylib and pkg-config --libs raylib. If that fails, it falls back to:

-lraylib -lm -lpthread -ldl

That fallback is aimed at common Unix-like setups, but raylib still needs to be installed and linkable on your machine.

Build

make

This produces the executable:

./xxhash3_viz

Run

make run

Clean

make clean

Controls

  • 0 through 9: switch pages
  • click page buttons in the top bar: switch pages
  • space: pause or resume the page animation
  • r: reset the current page animation
  • q: quit
  • move the mouse over bits, bytes, secret windows, or avalanche cells: inspect mappings and intermediate values

Notes And Limitations

  • The window starts at 1200x700, is resizable, and requests MSAA_4X.
  • The window title is xxHash3 Visual - First Operation.
  • The input text is currently hard-coded in src/main.c as "xxhash3!".
  • The app is specific to the XXH3_64bits len=8 path. Other input lengths use different formulas and are not visualized here.
  • The avalanche page flips bits in the derived input64 value for this path, not arbitrary-length byte strings.

About

xxHash Visualiser

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors