Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion encoding/ghash/ghash_pjw.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func PJW(str []byte) uint32 {
// PJW64 implements the classic PJW hash algorithm for 64 bits.
func PJW64(str []byte) uint64 {
var (
BitsInUnsignedInt uint64 = 32 // 4 * 8
BitsInUnsignedInt uint64 = 64 // 4 * 8

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix changes the hash algorithm's computation, which means PJW64 will now produce a different output for the same input compared to before. The existing unit test in ghash_z_unit_test.go (line 79) still asserts the old expected value of uint64(31150), which was computed using the incorrect 32-bit-wide parameters. The test expected value must be updated to the new correct output produced by the 64-bit algorithm, otherwise the test suite will fail.

Copilot uses AI. Check for mistakes.

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment // 4 * 8 on the BitsInUnsignedInt line is now stale. The value was changed to 64 to correctly represent a 64-bit integer (8 bytes × 8 bits), so the comment should be updated to // 8 * 8 to remain accurate.

Suggested change
BitsInUnsignedInt uint64 = 64 // 4 * 8
BitsInUnsignedInt uint64 = 64 // 8 * 8

Copilot uses AI. Check for mistakes.
ThreeQuarters = (BitsInUnsignedInt * 3) / 4
OneEighth = BitsInUnsignedInt / 8
HighBits uint64 = (0xFFFFFFFFFFFFFFFF) << (BitsInUnsignedInt - OneEighth)
Expand Down
Loading