Correct the FNV-1a 64-bit offset basis and assert known hash outputs

Open Beginner friendly
#547 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Read std/string/hash.wave at the cited initialization and tests/cases/shared/test81.wave at the existing hash check. Run the relevant shared test, then add exact checks for the empty string, a single ASCII byte, and a longer string, verifying the 64-bit bit patterns and intentional modulo-2^64 behavior. Done means the known FNV-1a outputs pass without adding dependencies.

Written by the indexing model from the issue text.

Description

bug good first issue

fnv1a_64 initializes its hash with 1469598103934665603, which differs from the FNV-1a 64-bit offset basis 14695981039346656037 (0xCBF29CE484222325). The empty string already exposes the difference: the loop is skipped, so the function returns the incorrect seed. Nonempty hashes consequently do not interoperate with FNV-1a implementations.

The existing shared/test81 check only requires a nonzero result, which cannot catch a wrong algorithm constant. The correct bit pattern exceeds positive i64, so a fix must also handle unsigned arithmetic/result representation deliberately.

Code evidence:

Acceptance:

  • Use the correct 64-bit offset basis and intentional modulo-2^64 multiplication, preserving the existing public result type unless a separately reviewed API change is needed.
  • Add exact known-output checks for the empty string, a single ASCII byte, and a longer string; compare the 64-bit bit pattern rather than assuming a positive signed result.
  • Keep the implementation dependency-free and note that correcting this bug changes previously computed hashes.

Reference: FNV offset basis values, RFC 9923 section 5. This is a small constant/arithmetic and regression-test contribution.

Audit status: static source inspection against canonical master ea74c2dafc31da876e5561f2d176ba719f5a0458 on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.

Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 6m
Merged PRs (30d)
44

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wavefnd/Wave

All issues in wavefnd/Wave

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.