Skip to content

Wnaf Unit Testing#1879

Open
42Pupusas wants to merge 9 commits into
RustCrypto:masterfrom
42Pupusas:wnaf/wnaf-form-tests
Open

Wnaf Unit Testing#1879
42Pupusas wants to merge 9 commits into
RustCrypto:masterfrom
42Pupusas:wnaf/wnaf-form-tests

Conversation

@42Pupusas

Copy link
Copy Markdown
Contributor

Adds unit tests for wnaf_form in the wnaf crate, covering known textbook vectors (zero scalar, single bits, borrow chains, alternating patterns) and adversarial edge cases (cross-byte carry, u64 limb boundaries, all-bits-set values up to 72 bits, maximum borrow depth per window size).

These tests exercise wnaf_form at the byte level independently of any group or field implementation, which is a natural isolation boundary identified in the discussion around a broader testing strategy for the crate discussed on #1839

Checks the four defining w-NAF properties (exactness, odd non-zero
digits, magnitude bound, non-adjacency) over every byte 0..=255 and
every window size 2..=8.
Replace Vec<Digit> in run() with a fixed-size stack buffer (Digits
wrapper struct) and rewrite the non-adjacency check in
exhaustive_wnaf_invariants as a single-pass scan instead of collecting
into a Vec<usize>.

The test module is now gated only on #[cfg(test)] and runs in full
no_alloc environments (--no-default-features).
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