Skip to content
Franta883Public

About

A high-security cryptographic framework in Rust...

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

84 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ith_hash

Current version: v4.5.0

A single-crate, dependency-free hashing toolkit for Windows consoles (it also builds on Linux and macOS). The toolkit ships one front-end binary, ith_hash, whose default engine is a Keccak-f[1600] sponge XOF, plus four additional engines that are reachable through flags on the same binary or as their own executables: a parallel Merkle-tree root engine, a spectral-entropy lattice fingerprint, a CTPS fuzzy-signature tool, and a PE/ELF structural report.

Scope note: only the default engine is a general-purpose cryptographic hash. /spectral and /fuzzy are similarity fingerprints and are intentionally not collision resistant. See Security notes.

What's new

  • One entry point, five engines. ith_hash now dispatches /tree, /spectral, /fuzzy, and /metadata to the same code paths as the standalone executables. Exactly one engine flag may be supplied, and /ui takes precedence.
  • Retired profile binaries. The separate ith_paranoid and ith_standard executables are gone. Choose a profile on ith_hash with /paranoid (default) or /standard.
  • Full-screen /ui. The current console can host a file/folder/Merkle form with profile, output length, a 16-colour or custom accent picker, and a filesystem browser. Redirected consoles get the equivalent line menu.
  • Harder diffusion checks. Exhaustive single-bit sweeps now cover all 1600 state bits of the sponge and tree permutations and all 1024 state bits of the spectral permutation, with additional hash-level avalanche checks for both profiles. The spectral NTT uses the primitive 64th root of unity, 2^39.
  • Removed the DOSKEY installer. DOSKEY_installer.ps1 no longer ships; set up any command aliases directly if you still want them.
  • Documentation rebuilt. This README now matches the code: the default engine is documented as a genuine Keccak-f[1600] sponge with the real rate/capacity values, and the spectral, fuzzy, and tree designs are described for what they are.

Engines

Engine Flag / standalone binary Output Purpose
Sponge XOF (default) (none) / ith_hash 64..1,048,576 hex chars (default 128 = 512 bits) file hashing, directory manifests, Merkle roots, /check
Merkle tree /tree / ith_tree 64 hex chars (256-bit root) Merkle root over 1 MiB leaves, built in parallel
Spectral lattice /spectral / ith_spectral 128 hex chars + 256 hex chars similarity fingerprint (rigid root + fuzzy mask)
CTPS fuzzy /fuzzy / ith_fuzzy up to 64-char signature segments similarity signature and /compare
Metadata /metadata / ith_metadata text report + structural SHA-256 PE/ELF structure summary

Requirements

  • Rust 1.85 or newer (edition 2024) and Cargo.
  • No third-party crates. [dependencies] is empty.
  • A real console with VT support is only needed for the full-screen /ui; everywhere else the tool is a normal command-line program.

Build

cargo build --release

Five binaries are produced in target\release\:

ith_hash.exe       main entry point (default sponge engine + merged engines)
ith_tree.exe       standalone Merkle tree engine
ith_spectral.exe   standalone spectral-entropy engine
ith_metadata.exe   standalone PE/ELF report
ith_fuzzy.exe      standalone CTPS fuzzy hash / compare

Run the main binary through Cargo with cargo run --release -- <args>.

Quick start

# default 128-hex (512-bit) digest of a file
ith_hash.exe "C:\path\to\file.bin"

# 500-hex XOF output
ith_hash.exe "C:\path\to\file.bin" 500

# standard profile (faster, smaller capacity)
ith_hash.exe /standard "C:\path\to\file.bin"

# directory content hash and Merkle root
ith_hash.exe /folder "C:\path\to\dir"
ith_hash.exe /folder /usemerkletree "C:\path\to\dir"

# merged engines
ith_hash.exe /tree "C:\path\to\file.bin"
ith_hash.exe /spectral "C:\path\to\file.bin"
ith_hash.exe /fuzzy "C:\path\to\file.bin"
ith_hash.exe /metadata "C:\path\to\app.exe"

# interactive form
ith_hash.exe /ui "C:\path\to\dir"

Command-line reference (default engine)

ith_hash [flags] [--] <file_path> [output_length]
ith_hash [flags] /folder [/usemerkletree] [--] <dir_path> [output_length]
ith_hash [flags] /check [--] <path> <expected_hash>
Flag Meaning
/paranoid Profile with 1536-bit capacity, 64-bit rate (default).
/standard Profile with 1024-bit capacity, 576-bit rate.
/folder Hash the contents of a directory instead of a single file.
/usemerkletree With /folder, compute a Merkle root instead of a flat manifest digest.
/check Compare a computed digest against an expected hex string.
/len:<N> Explicit digest length in hex characters, 64..=1048576, even only.
/maxdepth:<N> Directory traversal depth limit (default 64).
-- End of flags; the remaining arguments are positional.

Flags are matched case-insensitively and also accept --flag and -flag spellings. Providing an output length both positionally and through /len: is an error.

  • Without an output length the digest is 128 hex characters (512 bits).
  • /folder prints a statistics line (Files, Folders, Symlinks, Special, Total size) before the digest.
  • /usemerkletree requires /folder.
  • Exit status is 0 on success, 1 on usage/IO/verification failure, and 2 when more than one engine flag is supplied.

Profiles

Profile Rate Capacity Block Domain byte Notes
/paranoid (default) 64 bits (8 B) 1536 bits 8 B 0x06 Maximum capacity, slowest absorption.
/standard 576 bits (72 B) 1024 bits 72 B 0x0A Faster, capacity still above the 1024-bit floor.

Both profiles run the same 24-round Keccak-f[1600] permutation; they differ in rate and domain tag. Digests are project-defined sponge outputs and are not SHA-3 digests.

Verification (/check)

ith_hash.exe /check "C:\path\to\file.bin" <128-hex-digest>
ith_hash.exe /check /len:64 "C:\path\to\file.bin" <64-hex-digest>
  • /check defaults strictly to the canonical 128-hex (512-bit) length. To verify any other length, pass the same /len:<N> that produced it.
  • The expected string must be ASCII hexadecimal and exactly the requested length.
  • The comparison is constant-time. On success it prints [OK] Hash matches!; on failure it prints [FAIL] with both digests and exits 1.
  • /check recomputes the default engine output only. It cannot verify /tree, /spectral, /fuzzy, or /metadata output.

Merged engines

The engine flags may appear anywhere on the command line and are matched case-insensitively. They hand the rest of the arguments to the corresponding engine, exactly like the standalone binary of the same code. Supply exactly one engine flag; supplying two is an error (exit 2). /ui takes precedence over every engine flag.

/tree - parallel Merkle root

ith_hash /tree [/boostc] <file_path>
  • Returns a 64-hex (256-bit) Merkle root over 1 MiB leaves. Leaves are hashed in parallel with up to 32 workers.
  • The tree is built pairwise; an unpaired node is hashed with a dedicated odd-node domain. The final root binds the total input size and chunk count.
  • Default sponge parameters: 1024-bit capacity, 576-bit rate. /boostc raises the capacity to 1536 bits and lowers the rate to 64 bits.
  • The permutation is a project-defined 24-round 1600-bit ARX construction. It is Keccak-shaped but not Keccak-f: its chi layer is a flat 25-cycle and its iota layer XORs a per-lane constant into every lane. See Security notes.

/spectral - spectral-entropy lattice fingerprint

ith_hash /spectral <file_path>

Output:

=== Binary State Analysis: <path> ===
Rigid Root (64B) : <128 hex chars>
Fuzzy Mask (128B): <256 hex chars>
  • 1024-bit state (16 x u64), 12 rounds of a custom ARX permutation.
  • Entropy-driven chunking between 64 and 2048 bytes; each chunk is projected through an NTT over the Goldilocks field Q = 2^64 - 2^32 + 1 = 0xFFFF_FFFF_0000_0001, with N = 64 and the primitive 64th root of unity omega = 2^39.
  • Sponge framing: 512-bit rate, 512-bit capacity.
  • The rigid root is order-sensitive. The fuzzy mask is a thermometer-coded entropy vector intended for near-duplicate correlation. This engine is a similarity fingerprint, not a collision-resistant hash; see Security notes.

/fuzzy - CTPS similarity signature

ith_hash /fuzzy <file_path>
ith_hash /fuzzy /compare <hash_1> <hash_2>
  • A signature is five colon-separated fields: b:sig_b:sig_2b:entropy_b:entropy_2b, for example 4:uSo3:K:2240:5. Each signature segment is capped at 64 characters.
  • Chunk boundaries come from a gear-hash rolling window; each chunk contributes an FNV-folded base64 character and a 4-bit entropy nibble.
  • /compare normalizes a capped Levenshtein distance over the signatures and, when the two chunk scales match (or are exactly a factor of two apart), blends 80% signature similarity with 20% entropy similarity. It prints a percentage and [MATCH] above 50%, [MISMATCH] otherwise.
  • Similarity only; this is not a content hash.

/metadata - PE/ELF structural report

ith_hash /metadata <binary_path>
  • Parses PE or ELF and prints format, architecture, heuristic language marker, section/import/export counts, up to 8 compiler comments, up to 5 .rdata strings, the first 30 imports and exports, and a === Structural SHA-256 === value.
  • The SHA-256 is computed over the parsed structural fields (format, architecture, section table, imports, exports, and related metadata), not over the raw file bytes. Two files that differ only in data outside those fields can share it. Use the default engine for file integrity.

Interactive UI

ith_hash /ui [optional-path]

/ui turns the current console into a selectable form: mode (file, folder, folder Merkle), profile, output length (blank = automatic 128 hex), and accent colour. Nothing is launched in a second window and no child process is spawned; the previous prompt state is restored on exit.

  • Browse files walks the drives, the home directory, and the current directory; . toggles hidden entries, / filters the list, g goes to a typed path, Backspace goes up, and s selects the current folder.
  • Ctrl+V pastes into path fields.
  • Accent colours: the 16 classic console colour names, #RRGGBB / RRGGBB, or rgb(r,g,b) / r,g,b. Very dark choices are lightened for readability.
  • Keys: Up/Down move, Left/Right change a value, Enter opens/activates, Tab/Shift+Tab cycle fields, Esc goes back or cancels, q quits. Mouse clicks and scrolling work too.
  • On the result screen: c copies, r runs again, Esc returns to the form, q quits.

The full-screen form needs a real console on both stdin and stdout. With redirected streams or no VT support, the same settings are offered as a plain line menu instead:

mode <file|folder|merkle>   profile <paranoid|standard>
path <target>               len <n|auto>
color <name|#rrggbb|rgb(r,g,b)>
ls [folder]   run   help   quit

Security notes

  • Default engine. A genuine Keccak-f[1600] sponge: 24 rounds of standard theta/rho/pi/chi/iota, 1600-bit state, pad10*1 framing, and domain-separated object types (file data, directory root, and Merkle node variants). The permutation and sponge are checked against an independent reference implementation. The XOF is a prefix stream: squeezing more output never changes an earlier prefix. The construction is not NIST SHA-3 compatible: rates, domains, and padding parameters differ.
  • Tree engine. Uses its own 24-round permutation, which deviates from Keccak-f in the chi and iota layers. It is bijective and reaches full avalanche (covered by the test suite), but it is a project-defined primitive rather than a standard one. Treat tree roots as project-specific values.
  • Spectral and fuzzy engines. Both are intentionally lossy similarity fingerprints. The spectral engine is explicitly not collision resistant. Neither is suitable for integrity protection, signatures, commitments, password storage, or key derivation.
  • Metadata engine. The structural SHA-256 covers parsed fields, not raw bytes; it is a clustering aid, not a file-integrity check.
  • Input handling. Files are read in bounded streaming buffers; symlinks and Windows reparse points are refused rather than followed; the PE/ELF parsers are bounds-checked and are not allowed to panic on malformed prefixes. Control and bidirectional-override characters in paths and extracted strings are escaped before being printed.
  • Do not use spectral or fuzzy values as keys, MACs, or secret comparisons.

Tests

cargo test --release
cargo clippy --release

The suite contains 116 tests. Highlights:

  • Keccak-f permutation and padded-stream known-answer tests against independent Python reference implementations, including cross-profile and cross-domain separation.
  • Streaming absorption equals one-shot hashing; XOF squeezing is a true prefix stream; absorbing after squeezing is rejected.
  • Avalanche checks: every single-bit input flip reaches the 650..=950 band of the 1600-bit state after 24 rounds, and single-bit message flips change about half of the output bits for both profiles.
  • Differential/avalanche guards for the tree and spectral permutations.
  • NTT field-arithmetic identities, direct-DFT equivalence, linearity, and bijectivity on the Goldilocks field.
  • PE/ELF parser round-trips and hostile-prefix handling, CTPS signature invariants, thermometer-level mask validation, path sanitization, and CLI length validation.

Repository layout

Cargo.toml
src/ith_ui.rs            full-screen console form (compiled into ith_hash only)
src/Bin/ith_hash.rs      default engine + merged-engine dispatch
src/Bin/ith_tree.rs      Merkle tree engine
src/Bin/ith_spectral.rs  spectral-entropy lattice engine
src/Bin/ith_fuzzy.rs     CTPS fuzzy hashing engine
src/Bin/ith_metadata.rs  PE/ELF structural report
AUDIT_REPORT.md          security/performance audit notes

License

MIT License.

About

A high-security cryptographic framework in Rust...

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages