Skip to content

test(match): rsum collision fixture rejects via strong-checksum gate - #3640

Merged
oferchen merged 1 commit into
masterfrom
test/zsync-rsum-collision-fixture-2078
May 5, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/zsync-rsum-collision-fixture-2078

Conversation

@oferchen

@oferchen oferchen commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

Construct adversarial 700-byte block pairs that share an identical rolling Adler digest but have different content. Verify the strong-checksum gate in `DeltaSignatureIndex::find_match_bytes` rejects the colliding window.

Why

This is the safety property that probabilistic prefilters depend on: even if a prefilter (the current `tag_table`, or a future bithash) admits the rolling key, the strong-checksum stage must catch the mismatch. Pinning this down as a regression test is a prerequisite for the upcoming bithash work (#2061).

Construction

For a block of length `n >= 4`, swapping the last four bytes `[a, b, c, d]` -> `[d, c, b, a]` preserves both `s1` and `s2` iff `3 * (a - d) == c - b` (in plain integer arithmetic, since the values fit comfortably within the s2 weight range). Two concrete pairs:

  • low-byte: `[0x01, 0x00, 0x03, 0x00]` / `[0x00, 0x03, 0x00, 0x01]`
  • high-byte: `[0x80, 0x86, 0x80, 0x82]` / `[0x82, 0x80, 0x86, 0x80]`

The high-byte case exercises the signed-`schar` path from upstream `checksum.c:285` and adds redundant coverage for the sign-extension fix in PR #3560.

Tests

Six tests in `crates/match/tests/rsum_collision_fixture.rs`:

  • `low_byte_collision_pair_shares_rolling_digest` - construction sanity
  • `high_byte_collision_pair_shares_rolling_digest` - signed-byte sanity
  • `collision_pair_strong_checksums_differ` - MD4 distinguishes
  • `find_match_rejects_low_byte_collision_window` - strong-checksum gate works
  • `find_match_rejects_high_byte_collision_window` - same, signed-byte path
  • `find_match_accepts_self_window` - negative control

Closes

#2078

@github-actions github-actions Bot added the test label May 5, 2026
Construct adversarial pairs of 700-byte blocks that share an identical
rolling Adler digest (signed-byte interpretation) but have different
content. Verify that DeltaSignatureIndex::find_match_bytes rejects the
colliding window via the strong-checksum gate.

This is the safety property that future probabilistic prefilters
(e.g. a bithash) will depend on: even if the prefilter admits the
rolling key, the strong-checksum stage must catch the mismatch.

Includes a high-byte (>= 0x80) variant that exercises the signed-schar
path from upstream checksum.c:285, providing additional regression
coverage for the sign-extension fix in PR #3560.

Construction: swap last 4 bytes [a, b, c, d] -> [d, c, b, a] when
3*(a-d) == c-b. Two solutions used: low-byte [0x01, 0x00, 0x03, 0x00]
and high-byte [0x80, 0x86, 0x80, 0x82].
@oferchen
oferchen force-pushed the test/zsync-rsum-collision-fixture-2078 branch from dfb37be to d10efc7 Compare May 5, 2026 07:29
@oferchen
oferchen merged commit 43fd514 into master May 5, 2026
11 checks passed
@oferchen
oferchen deleted the test/zsync-rsum-collision-fixture-2078 branch May 5, 2026 09:41
oferchen added a commit that referenced this pull request May 18, 2026
…3640)

Construct adversarial pairs of 700-byte blocks that share an identical
rolling Adler digest (signed-byte interpretation) but have different
content. Verify that DeltaSignatureIndex::find_match_bytes rejects the
colliding window via the strong-checksum gate.

This is the safety property that future probabilistic prefilters
(e.g. a bithash) will depend on: even if the prefilter admits the
rolling key, the strong-checksum stage must catch the mismatch.

Includes a high-byte (>= 0x80) variant that exercises the signed-schar
path from upstream checksum.c:285, providing additional regression
coverage for the sign-extension fix in PR #3560.

Construction: swap last 4 bytes [a, b, c, d] -> [d, c, b, a] when
3*(a-d) == c-b. Two solutions used: low-byte [0x01, 0x00, 0x03, 0x00]
and high-byte [0x80, 0x86, 0x80, 0x82].
oferchen added a commit that referenced this pull request Aug 24, 2026
…3640)

Construct adversarial pairs of 700-byte blocks that share an identical
rolling Adler digest (signed-byte interpretation) but have different
content. Verify that DeltaSignatureIndex::find_match_bytes rejects the
colliding window via the strong-checksum gate.

This is the safety property that future probabilistic prefilters
(e.g. a bithash) will depend on: even if the prefilter admits the
rolling key, the strong-checksum stage must catch the mismatch.

Includes a high-byte (>= 0x80) variant that exercises the signed-schar
path from upstream checksum.c:285, providing additional regression
coverage for the sign-extension fix in PR #3560.

Construction: swap last 4 bytes [a, b, c, d] -> [d, c, b, a] when
3*(a-d) == c-b. Two solutions used: low-byte [0x01, 0x00, 0x03, 0x00]
and high-byte [0x80, 0x86, 0x80, 0x82].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant