#416 Improvement: propertybased tests for circuits fuzz witnesses aga… - #495
Open
Kappa16 wants to merge 1 commit into
Conversation
…sses against constraints FIXED
|
@Kappa16 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CLOSE #416
What does this PR do?
Adds property-based fuzzing tests for all Noir circuits to catch constraint gaps that fixed example tests miss. Introduces a Node.js fuzzing harness (
circuits/scripts/fuzz_circuits.js) that generates randomized valid/invalid witnesses — computes real Poseidon2 commitments, signs with secp256k1 ECDSA, and runsnargo executeto assert pass/fail outcomes across 8 credential circuits. Adds 86 new Noir-native boundary tests (126 total, up from 40) covering threshold off-by-one, date boundaries, tampered commitments, salt mismatches, and commitment collision resistance. Integrates bothnargo testand the fuzz harness into CI as a newcircuit-fuzzjob.Closes #
Type of change
Merge requirements
cargo test(contracts),pnpm tsc --noEmit(frontend),pnpm build(frontend), circuit tests — all greenfixtures/<type>/artifacts updatedNEXT_PUBLIC_prefix on server-only env varsprehash:falsepreserved on any issuer signing path touched✅ Merge requirements
Notes for reviewers
Two-layer testing strategy:
Noir-native tests (in each circuit's
main.nr) — 86 new#[test]/#[test(should_fail)]cases that exercise constraint logic directly without the expensive ECDSA overhead. These run fast vianargo testand cover boundary conditions systematically: threshold exact, ±1, zero, max, date epoch, large values, commitment collision resistance, salt binding.External fuzzing harness (
circuits/scripts/fuzz_circuits.js, 1,267 lines) — generates random witnesses usingcrypto.randomBytes, computes Poseidon2 commitments locally (same round constants asmerkle_tree.js), signs with the demo issuer key viasign.js, writesProver.toml, and runsnargo executeend-to-end. Covers pass space (valid commitment + signature + satisfied constraint) and fail space (tampered commitment, wrong salt, threshold violations). Backs up and restoresProver.tomlfiles so the fuzz run never corrupts committed fixtures.Key design decisions:
nargo executeon thecommitcircuit — this reuses the Poseidon2 implementation already inmerkle_tree.jsand avoids a round-trip to the Noir compiler per test case.--iterations Nflag controls random test count (default 20); CI runs with--iterations 10to stay within time budget.--circuit NAMEflag targets a single circuit for local debugging.set_membershipcircuit has a pre-existing test failure (test_merkle_path_produces_correct_root) onmain— confirmed viagit stash+nargo teston clean branch. Not introduced by this PR.Circuits covered by fuzz harness: age_proof, income_proof, funds_proof, accreditation_proof, kyc_proof, jurisdiction_proof, range_proof, employment_proof.
Circuits covered by Noir boundary tests: all of the above + commit, commit3, aggregate_proof (11 total, 126 tests passing).