Skip to content

test: add regression test for F-01 field canonicity check#258

Open
aryaethn wants to merge 1 commit into
leanEthereum:mainfrom
aryaethn:test/regression-test-f01-canonicity
Open

test: add regression test for F-01 field canonicity check#258
aryaethn wants to merge 1 commit into
leanEthereum:mainfrom
aryaethn:test/regression-test-f01-canonicity

Conversation

@aryaethn

@aryaethn aryaethn commented Jul 5, 2026

Copy link
Copy Markdown

What

The MontyField31 Deserialize impl rejects non-canonical serialized values (val >= p) — the fix for audit finding F-01 (non-canonical field deserialization, rated Critical). But that check has no regression test: a future refactor could silently drop or weaken it and reintroduce the bug while CI stays green.

This adds a unit test asserting that deserializing a value >= p (the modulus, p + 1, u32::MAX) is rejected, while canonical values in [0, p) are accepted. The quintic extension and packed types deserialize each of their coefficients through this same checked base-field path.

Tests only — no production code changes.

Tested

$ cargo +nightly test -p koala-bear canonicity_tests                                # 1 passed; 0 failed
$ cargo +nightly clippy -p koala-bear --all-targets --all-features -- -D warnings   # clean

The MontyField31 Deserialize impl rejects non-canonical values (>= p), the fix
for audit finding F-01, but had no test -- a refactor could silently drop the
check and reintroduce the critical bug. Add a unit test asserting values >= p
are rejected and canonical values in [0, p) are accepted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant