Skip to content

feat(bls-12-381): add test vectors for BLS-12-381#224

Open
tob-scott-a wants to merge 5 commits intoC2SP:mainfrom
tob-scott-a:bls-12-381-tests
Open

feat(bls-12-381): add test vectors for BLS-12-381#224
tob-scott-a wants to merge 5 commits intoC2SP:mainfrom
tob-scott-a:bls-12-381-tests

Conversation

@tob-scott-a
Copy link
Contributor

The methodology for generating this test vectors is as follows:

  1. Source several high-quality implementations.
  2. Run mutation testing on each of them.
  3. Have Claude write additional test inputs intended to trigger more behaviors in internal functions not currently exercised by the incumbent test suites.
  4. Re-run the mutation testing framework with the new Wycheproof harness and new JSON files.
  5. Compare before/after.

The end result are a set of static tests that ensure implementations do not have subtle mistakes that the barebones known answer tests do not detect.

Here's an example of the delta in mutation testing coverage provided by the JSON files generated in this PR, against https://github.com/zkcrypto/bls12_381:

File Before Missed After Missed Delta Key Kills
scalar.rs 35 10 -25 ct_eq (&^), arithmetic (square, neg, from_bytes)
fp.rs 46 31 -15 Roundtrip caught field arithmetic corruption
fp2.rs 12 12 0 No change (pow_vartime_extended, sqrt not in deser path)
g1.rs 42 → 59* 54 -5 All from_compressed_unchecked flag mutations killed
g2.rs 29 → 54* 54 0 All from_compressed_unchecked flag mutations killed

*Full file now tested (more mutants in scope).

tob-scott-a and others added 4 commits March 12, 2026 08:20
The methodology for generating this test vectors is as follows:

1. Source several high-quality implementations.
2. Run mutation testing on each of them.
3. Have Claude write additional test inputs intended to trigger more
   behaviors in internal functions not currently exercised by the
   incumbent test suites.
4. Re-run the mutation testing framework with the new Wycheproof harness
   and new JSON files.
5. Compare before/after.

The end result are a set of static tests that ensure implementations do not
have subtle mistakes that the barebones known answer tests do not detect.
Go's json.Marshal HTML-escapes > as \u003e; reformat_json.py expects
literal >= characters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Thanks! I think this mutation based approach for generating vectors is really cool 🚀

I propose we consider the feedback I left, give it a bit to see if anyone else has input, and then merge. Sound good?

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.

2 participants