Skip to content

Add property-based tests, test the common.ak helpers, retire raw.ak - #21

Merged
SamDelaney merged 5 commits into
mainfrom
sam/property-tests
Nov 11, 2026
Merged

SamDelaney merged 5 commits into
mainfrom
sam/property-tests

Conversation

@SamDelaney

@SamDelaney SamDelaney commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Catalyst completion roadmap tasks 1.2 and 1.3: property-based tests for all three verifiers and the affine point compression, unit tests for the common.ak helpers the verifiers use, and the removal of raw.ak. Uses aiken-lang/fuzz v2.2.0 (v3.0.0 needs stdlib v4 and Aiken 1.1.24, so it can't be used here yet). Includes #22, which was stacked on this branch.

Property tests

Four modules in zkp/lib/tests/, with 14 property tests at 100 runs each plus 2 unit tests:

Module Properties
groth_props changing any public input in [0, r) is rejected; replacing a, b or c with another valid point is rejected; too few inputs fails
plonk_props changing any public input is rejected; tampering any of the six evaluation scalars is rejected
point_props g1_affine_compress gives byte-for-byte the builtin's encoding for random points (and the other square root encodes differently)
bullet_props every value in [0, 2^8) verifies with any blinding and seed; a commitment to another value is rejected; tampering tau_x, mu, l_vec or r_vec is rejected

Known-issue tests

known_issue_* tests pin #11, #12, #14, #15 and #16. They pass because the bug exists, which keeps CI green until the fix lands. Each fix then turns its test red, and the test should be replaced by the property named in its comment (the same call must fail). For #14, the test drops only the surplus generator's inverse (#19), the one inverse an honest proof can lose and still verify.

common.ak helpers and raw.ak (from #22)

raw.ak had no callers and its projective fixtures weren't used by any test, so both are removed. The verifiers use five definitions from common.ak (the two BLS12-381 constants, concat_and_keccak_256, scalar_sum, g1_sum); tests/common_tests.ak covers them with 8 unit and 3 property tests.

Documentation

The README, zkp/README.md, specification.md and the three implementation reports describe the new test files and the known-issue convention, give the current test count, and no longer mention raw.ak. Each report's limitations section lists the open issues for its module (#11 to #19); the Groth16 report had called the extra-input truncation safe, which #11 shows it isn't.

Checks

  • aiken check -D: 64 tests, all pass
  • aiken fmt --check and aiken build pass; plutus.json is unchanged
  • Mutation check: breaking the library on purpose was caught, by swapping the G1 sort bit (point_props), dropping the second Bulletproofs check (bullet_props), or reversing the join order in concat_and_keccak_256 (common_tests)

Not covered: G2 compression (it needs an Fp2 square root), #13 (it needs a modified prover), and #17 to #20, which aren't property-shaped.

🤖 Generated with Claude Code

Adds aiken-lang/fuzz v2.2.0 (v3 needs stdlib v4) and four test modules:

- groth_props, plonk_props: changed public inputs, replaced or tampered
  proof elements are rejected.
- point_props: g1_affine_compress matches blst's encoding for random
  points.
- bullet_props: valid range proofs verify for any in-range value,
  blinding and seed; other values and tampered proofs are rejected.

known_issue_* tests pin #11, #12, #14, #15 and #16: they pass because
the bug exists, so each fix turns one red and it should then be
replaced by the property named in its comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the added verifier and compression regression coverage.

No open issues 🎉

What changed in this PR

Adds property-based regression coverage for the Groth16, PLONK, and Bulletproofs verifiers and G1 affine compression, without changing production verifier code.

Changes:

  • Adds 14 property tests and two unit tests covering valid proofs, input and proof tampering, and compression consistency.
  • Captures current behavior for known issues #11, #12, #14, #15, and #16, with instructions for updating the tests when fixes land.
  • Pins aiken-lang/fuzz to v2.2.0 for compatibility with the current toolchain.
File Description
zkp/​lib/​tests/​point_props.ak Checks G1 affine compression against builtins and captures unchecked-y behavior.
zkp/​lib/​tests/​plonk_props.ak Tests input and evaluation tampering, input range handling, and inverse-list truncation.
zkp/​lib/​tests/​groth_props.ak Adds shared fuzzing helpers and tests proof tampering and public-input handling.
zkp/​lib/​tests/​bullet_props.ak Tests generated range proofs, commitment mismatches, proof tampering, and modular value aliases.
zkp/​aiken.toml Declares the fuzz dependency.
zkp/​aiken.lock Locks the fuzz dependency to v2.2.0.

Review effort: Balanced

raw.ak had no callers, and its projective fixtures in plonk_tests were
not used by any test, so both are removed. The PLONK implementation
report recommended revalidating or retiring it; it now has a dated note.

The verifiers use five definitions from common.ak: the two BLS12-381
constants, concat_and_keccak_256, scalar_sum and g1_sum. The new
tests/common_tests.ak covers them with 8 unit and 3 property tests:
p against the spec value, (p - 1) / 2, p = 3 mod 4, the G1 generator on
the curve, Keccak (not SHA3) of the empty input, join order, split
invariance, and both sums against integer arithmetic.

64 tests pass with aiken check -D; fmt and build are clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SamDelaney and others added 3 commits November 11, 2026 12:03
The PLONK implementation report now describes the module as it is:
raw_affine.ak is the one point-type front door, and the raw.ak passages
and limitation are gone. The README and the three implementation
reports give the current test counts (64 across the package, including
the property-test files); the Bulletproofs report said 13 where the
module has 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Retire raw.ak and test the common.ak helpers the verifiers use
The README, zkp/README, specification and the three implementation
reports now describe the property-based test files and the
known_issue_* convention, and give the current layout of tests/.

Each report's limitations section now lists the open issues that
affect its module (#11 to #19). The Groth16 report described extra
public inputs being truncated as safe, which #11 shows it isn't. The
README links #20 for the unused part of common.ak.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SamDelaney SamDelaney changed the title Add property-based tests with aiken-lang/fuzz Add property-based tests, test the common.ak helpers, retire raw.ak Nov 11, 2026
@SamDelaney
SamDelaney merged commit 90b3652 into main Nov 11, 2026
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