Skip to content

[Enhancement] Implement Jazzer fuzzing and differential checks for ZeroJ cryptographic boundaries #107

Open

Description

@beanbot-gh

Context

The PlonK production-readiness addendum (docs/adr/0022-0023-plonk-production-readiness-addendum.md) already calls for standing coverage-guided fuzzing of untrusted PlonK parsers and differential verification against snarkjs/gnark. Implement that requirement across the risk-critical boundaries; do not treat fuzzing as a substitute for a cryptographic audit.

Targets in priority order

  1. P0 untrusted parser surfaces: SnarkjsPlonkCodec, PtauImporter, PlonKZkeyImporter and applicable BLS variants; malformed headers/lengths/sections, noncanonical field encodings, invalid points, out-of-subgroup points, incomplete setup material, oversized declared sizes.
  2. P0 proof-verification rejection: mutate Groth16/PlonK proof bytes, public inputs, verifying keys, commitments; invalid inputs must reject or throw narrowly documented validation errors, not accidentally verify.
  3. P0 field/curve arithmetic: bounded field elements, inverses, zero/nonzero, point addition/scalar multiplication, identity/infinity rules, encoding round-trips, subgroup membership; compare with independent algebraic models/vectors where practical.
  4. P1 primitives: Pedersen commitment openings (Jubjub and any supported BLS12-381 variant), ElGamal encrypt/decrypt/additive homomorphism, Fiat–Shamir transcript domain separation and deterministic challenge derivation, Bulletproof range-verifier negative cases where implemented.
  5. P1 circuit/prover paths: structured small valid circuits including public/private inputs; witness satisfaction and prover/verifier agreement; differential interoperability with snarkjs/gnark on compatible proof formats/transcripts and supported curves only.

Invariants / security requirements

  • Invalid points/proofs/setups never become accepted; canonical values are enforced where required.
  • Group arithmetic and commitment homomorphism equations hold for valid bounded inputs; deliberately invalid openings fail.
  • Domain-separated transcripts differ across domains; do not interpret probabilistic equality as a deterministic impossibility for arbitrary hash collisions.
  • Bound work and memory for untrusted inputs; cap expensive proving/pairing operations per iteration.
  • Differential tests specify exact parameters, transcript encoding, field, and proof format to avoid false mismatches.

Acceptance criteria

  • At least 3 Jazzer fuzz targets, including parser robustness, proof rejection, and arithmetic/commitment properties.
  • Corpus with valid pinned setup/proof vectors and adversarial mutated samples.
  • Independent reference/differential checks for supported crypto primitives and PlonK where feasible.
  • CI replay and bounded fuzz smoke; scheduled extended fuzzing, documented findings and minimized regression seeds.
  • Document crypto-audit limitations and input rejection policy.

Shared implementation guidance

  • Use Google's Jazzer with JUnit 5 @FuzzTest and the repository's existing Gradle conventions; first audit existing fuzz targets and dependencies instead of duplicating setup.
  • Separate malformed input targets (controlled rejection, never uncontrolled crash/hang) from valid structured input targets (assert semantic properties).
  • Bound input sizes, nesting, operation counts, allocations, and execution time. Do not silently suppress unexpected failures; define allowed rejection exceptions precisely.
  • Maintain small, representative checked-in seed corpora (valid real-world fixtures, canonical boundary values, malformed mutations, regression reproductions); remove sensitive or copyrighted fixtures.
  • PR CI: deterministic replay of the regression corpus plus a small bounded fuzz smoke run; scheduled CI: longer coverage-guided runs with timeouts and saved reproducer artifacts. Avoid flaky PR gates and avoid committing unreviewed large corpora.
  • Document exact local commands and a way to promote each finding into a reproducible JUnit regression. Track target count, corpus size, unique findings, and coverage trends; pin a compatible Jazzer version.
  • Do not treat high coverage or zero crashes as proof of correctness. Test explicit invariants and, where practical, compare to an independent reference.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions