Skip to main content

Module hash

Module hash 

Source
Expand description

Karp-Rabin rolling hash (Karp & Rabin 1987; Section 2.1.3).

Polynomial fingerprints over the Mersenne prime 2^61-1. Full 61-bit fingerprints are used for collision-free seed comparison; fp_to_index maps them into the bounded hash table via F mod q.

Structs§

RollingHash
Rolling hash for O(1) incremental fingerprint updates.

Functions§

crc64_xz
Compute CRC-64/XZ of data; returns 8 bytes big-endian.
fingerprint
Compute the Karp-Rabin fingerprint of data[offset..offset+p] (Eq. 1, Section 2.1.3).
fp_to_index
Map a full fingerprint to a hash table index (F mod q, Section 2.1.3).
is_prime
Deterministic Miller-Rabin primality test.
mod_mersenne
Reduce a u128 value modulo the Mersenne prime 2^61-1.
next_prime
Smallest prime >= n.
precompute_bp
Precompute HASH_BASE^{p-1} mod HASH_MOD.