Skip to content

Add property-based tests for the IVC pure helpers #3469

Description

@jpraynaud

Why

proptest is established in halo2_snark (eligibility, clerk, message encoding) but absent from halo2_ivc_snark, despite several pure helpers with clear invariants.

What

Add proptest suites in the fast tier for the pure helpers and codecs. Case counts start at 100 for the byte-level and classification properties and stay low where a case decodes a verifying key; each target is measured as it lands, so the counts come from data rather than convention. Where a generated domain reaches an important case only by chance — an epoch pair that happens to be adjacent, a repeated name — that case is constructed rather than sampled. Per-helper scope and rationale are in the comment below.

How

Paths are relative to mithril-stm/src/.

  • Accumulator and MSM byte codec (circuits/halo2_ivc/io.rs): round-trips preserve every component over arbitrary counts, fixed-base maps and key strings, and consume the whole encoding
  • Preimage accessor range isolation (circuits/halo2_ivc/types.rs): each accessor decodes its own range, and is unchanged when every byte outside that range is altered
  • Rigid preimage assembly (circuits/halo2_ivc/protocol_message.rs, circuits/halo2_ivc/types.rs): a preimage built from arbitrary inputs decodes back to them, and its whole 190-byte layout matches expectations computed from those inputs rather than from the helpers under test
  • build_next_state (proof_system/halo2_ivc_snark/prover_input_helpers.rs): all seven next-state fields taken from their declared source, for both transition types on the same generated inputs, with step counters spanning the 32-bit boundary
  • Epoch transition classification (proof_system/halo2_ivc_snark/rolling_state.rs): same-epoch, next-epoch and both gap directions constructed for each generated epoch, with the typed error payloads, plus deterministic (MAX - 1, MAX) and (MAX, MAX) cases for the overflow precedence
  • Protocol parameter promotion guard (proof_system/halo2_ivc_snark/rolling_state.rs): a truth table over step counter, transition type, and whether the two parameter fields hold equal field values
  • Aggregate verification key codec (proof_system/halo2_snark/aggregate_key.rs): legacy to CBOR preservation, a forced CBOR-version-byte root, and one property pairing the rigid slot layout with rejection of any decoded root that is not 32 bytes
  • Input message matching (proof_system/halo2_ivc_snark/proof.rs): raw, lowercase, uppercase and mixed hex encodings of the same message are accepted, a message reducing to a different field element is rejected in every one of those forms, and malformed encodings are covered by a small example table
  • State::as_public_input (circuits/halo2_ivc/state.rs): every field value at its row over full-width integers, with the four {0, MAX} boundary pairs
  • trivial_accumulator (circuits/halo2_ivc/accumulator.rs): each distinct name once with a zero scalar, duplicates collapsed, empty left side, over a name pool small enough that duplicates actually occur
  • Fixed-base availability guards (circuits/halo2_ivc/accumulator.rs): a name missing from either accumulator side is reported, and a correct label mapped to a different point is rejected
  • IvcRollingState serde round-trip (proof_system/halo2_ivc_snark/rolling_state.rs, through AncillaryProverData): state values, proof bytes, accumulator components and signature compared field by field over non-genesis values
  • IvcVerifierData (proof_system/halo2_ivc_snark/verifier_setup.rs): reject input without the CBOR version prefix, and preserve a nonzero genesis message
  • MessageHash::try_from(&ProtocolMessagePreimage) (circuits/halo2_ivc/types.rs): the result is the field reduction of SHA-256 over all 190 input bytes, pinned by independently computed vectors
  • Assess the gain and report it in the issue, with the measured per-case cost and the chosen case counts

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions