wavefnd / wavefnd/Wave

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
bug good first issue
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

`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:

- [std/string/hash.wave:32](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/string/hash.wave#L32)
- [tests/cases/shared/test81.wave:35](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/tests/cases/shared/test81.wave#L35)

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](https://datatracker.ietf.org/doc/html/rfc9923#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.

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.