Skip to content

[unpinned-masks-shared-constant-blindspot] [LOW] Mask constants have no direct test pin; ctpop/ctpopSlow share M1/M2/M4 #25

Description

@thedavidmeister

Dimension: 6 (hazard surface) · Severity: LOW

src/lib/LibCtPop.sol:6-22 — the nine 256-bit masks are hand-typed hex literals. ctpop (uses M1/M2/M4/H01) and ctpopSlow (uses M1/M2/M4/M8..M128) share M1/M2/M4, so the testCtPopReference cross-check (ctpop == ctpopSlow) alone cannot catch a shared-constant bug — both would be corrupted identically.

Nuance (verified during audit): the n-oracle tests (testCtPopUnshuffled/testCtPopShuffled assert count == n) do functionally enforce the masks — a wrong mask fails count == n — and all nine masks were independently recomputed and are correct today. So this is a convention-vs-enforcement observation, not a live gap: the only enforcement is indirect (via the functional tests), with no explicit constant pin.

Proposed fix (optional, belt-and-suspenders) — add a test that recomputes each mask from its intended repeating pattern and asserts equality, so a mistyped literal fails directly rather than only via a downstream count mismatch.

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions