Skip to content

test: add VerifyProofsTest fixture and basic test vectors to sanity check proof verification#786

Open
unnawut wants to merge 4 commits into
leanEthereum:mainfrom
unnawut:verify-proofs-vectors
Open

test: add VerifyProofsTest fixture and basic test vectors to sanity check proof verification#786
unnawut wants to merge 4 commits into
leanEthereum:mainfrom
unnawut:verify-proofs-vectors

Conversation

@unnawut
Copy link
Copy Markdown
Collaborator

@unnawut unnawut commented May 28, 2026

🗒️ Description

Add a new VerifyProofsTest fixture for verifying type-1 proofs along with some basic, consensus-related tests to begin with. Will follow with more complex ones in separate PRs

3 positive tests: single, 4-validator all participating, 4-validator some participating, and 3 rejection tests: wrong message, wrong slot and wrong public keys.

These vectors target devnet-5 since devnet-5 PR already landed in leanSpec.

@unnawut unnawut added this to the pq-devnet-5 milestone May 28, 2026
@unnawut unnawut requested a review from tcoratger May 28, 2026 09:31
unnawut added 4 commits May 28, 2026 16:49
Introduces a new consensus fixture format that emits self-contained
multi-signature verification vectors so cross-client implementations
can run their own Type-1 verifier and compare outcomes.

Three positive vectors land alongside the fixture: a single-validator
baseline, a four-validator all-participating case, and a
four-validator non-contiguous bitfield case ([1, 0, 1, 1]).

The fixture also surfaces the spec-layer binding between attestation
data and proof: clients recompute hash_tree_root(attestation_data)
and must match the emitted message field before running the verifier.
Adds four negative vectors exercising spec-layer bindings between
inputs and the multi-signature proof. Each vector uses a tamper
operation on the fixture to produce a structurally valid bundle that
must be rejected by a conformant verifier:

- wrong_message: proof bound to an alternate head root inside the
  attestation data
- wrong_slot: emitted slot field shifted while the proof binding
  stays on the original slot
- wrong_public_keys: one emitted pubkey replaced with another
  validator's
- aggregation_bits_length_mismatch: emitted bits truncated while
  the pubkey count stays unchanged

Vectors covering malformed or truncated proof bytes are intentionally
out of scope: leanSpec consumes the multi-signature primitive as a
black box and primitive integrity belongs to its own conformance
suite. Pubkey ordering is also not a binding to test: the aggregator
sorts participants internally, so the verifier is order-insensitive.
Brings the new fixture in line with the patterns the other consensus
test fixtures follow:

- Drop ``from __future__ import annotations`` (PR leanEthereum#759 removed it from
  Pydantic-defining files); quote the one self-reference instead.
- Replace the bespoke ``expect_valid: bool`` field with the inherited
  ``expect_exception`` field already used by SSZTest, NetworkingCodec,
  and VerifySignaturesTest. Rejection vectors now pin
  ``AggregationError`` and the framework serializes the class name to
  JSON.
- Switch the tamper dispatch in ``_apply_tamper`` from ``if/elif`` to
  ``match/case`` to follow the pattern in slot_clock and
  networking_codec.
- Expand the module-level docstring from one line to a short
  paragraph describing what the fixture covers.
- Normalize the ``public_keys`` default from ``[]`` to ``| None =
  None`` to match every other output field on the model.
The check that fires here is the early-reject in the spec wrapper's
verify method (len(public_keys) != participants.count(True)), not a
consensus-critical binding. In real consensus the inconsistency cannot
arise because clients resolve public keys from the bitfield plus the
validator registry as one operation. A client that did pass a wrong
pubkey count would also be rejected by the underlying recursive
verifier on its internal pubkey-set commitment, so the wrapper check
is at best an early exit with a nicer error message.

The remaining three rejection vectors still exercise the meaningful
spec-layer bindings: message hash, slot, and pubkey set.
@unnawut unnawut force-pushed the verify-proofs-vectors branch from 4291677 to f61c0ed Compare May 28, 2026 09:50
@unnawut unnawut requested a review from anshalshukla May 28, 2026 10:16
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.

1 participant