v2.0.6 - Seeded XXH3
This release adds optional seeded XXH3-64 / XXH3-128 support.
A seed is useful when an app needs reproducible non-cryptographic checksums
across a backend, CLI tooling, and React Native. For example, a backend can
publish both the expected XXH3 digest and the exact u64 seed used to compute
it; the mobile app can then hash the downloaded local file with the same seed
and compare the result.
Seeded XXH3 is also useful for app-owned cache or deduplication namespaces,
such as media-cache-v1 or upload-dedupe-v2, where the same bytes should
produce stable hashes within that namespace.
Seeds are not secrets and do not make XXH3 cryptographic. Use HMAC or keyed
BLAKE3 when authenticity matters.
Added
- Added
hashOptions.seedforXXH3-64andXXH3-128in bothfileHashand
stringHash. hashOptions.seedaccepts:bigint- non-negative safe integer
number - decimal
string 0xhexstring
- Added
xxh3SeedFromLabel(label)for deterministic UTF-8 label ->u64seed
derivation using FNV-1a 64-bit. It returns a canonical0xhex seed that can
be passed directly tohashOptions.seed. - Added seeded XXH3 coverage to the example app, including label, string,
number, and bigint seed inputs. - Added seeded XXH3 validation and vector tests.
Usage
Pass large u64 seeds from a backend as strings so JavaScript does not round
them:
const manifest = {
xxh3Seed: '12345678901234567890',
xxh3: '4b5e0a417dfa7ed2fb965bc17c16bd34',
};
const actual = await fileHash(localFileUri, {
algorithm: 'XXH3-128',
hashOptions: {
seed: manifest.xxh3Seed,
},
});
if (actual !== manifest.xxh3) {
throw new Error('Downloaded file failed checksum verification');
}For app-owned namespaces, derive a stable seed from a readable label:
const seed = xxh3SeedFromLabel('media-cache-v1');
const cacheKey = await fileHash(fileUri, {
algorithm: 'XXH3-128',
hashOptions: { seed },
});Compatibility
hashOptions.seedis optional. Omit it for regular unseeded XXH3.hashOptions.seedis only valid forXXH3-64andXXH3-128; other
algorithms reject it.- Large seeds above
Number.MAX_SAFE_INTEGERshould be passed asbigint,
decimal string, or0xhex string. - With the optional
zigengine, seeded XXH3 currently meansXXH3-64;
XXH3-128remains native-only.