@pytest.mark.parametrize(
"z,y,kzg_commitment,kzg_proof,versioned_hash",
[
# Out of bounds z and y.
pytest.param(
Spec.BLS_MODULUS,
0,
INF_POINT,
INF_POINT,
None,
id="out_of_bounds_z",
),
pytest.param(
0,
Spec.BLS_MODULUS,
INF_POINT,
INF_POINT,
None,
id="out_of_bounds_y",
),
# Correct proof and commitment but incorrect input lengths.
pytest.param(
Z,
0,
INF_POINT,
INF_POINT[:-1],
None,
id="correct_proof_1_input_too_short",
),
pytest.param(
Z,
0,
INF_POINT,
INF_POINT[0:1],
None,
id="correct_proof_1_input_too_short_2",
),
pytest.param(
Z,
0,
INF_POINT,
INF_POINT + b"\x00",
None,
id="correct_proof_1_input_too_long",
),
pytest.param(
Z,
0,
INF_POINT,
INF_POINT + b"\x00" * 1023,
None,
id="correct_proof_1_input_extra_long",
),
# Empty calldata.
pytest.param(
b"",
b"",
b"",
b"",
b"",
id="null_inputs",
),
# Zero commitment is not a valid compressed BLS12-381 point;
# the two cases differ only in whether the versioned hash matches
# the one derived from the zero commitment.
pytest.param(
0,
0,
0,
0,
0,
id="zeros_inputs",
),
pytest.param(
0,
0,
0,
0,
None,
id="zeros_inputs_correct_versioned_hash",
),
# Correct proof and commitment but incorrect versioned-hash version.
pytest.param(
Z,
0,
INF_POINT,
INF_POINT,
Spec.kzg_to_versioned_hash(INF_POINT, 0x00),
id="correct_proof_1_incorrect_versioned_hash_version_0x00",
),
pytest.param(
Z,
0,
INF_POINT,
INF_POINT,
Spec.kzg_to_versioned_hash(INF_POINT, 0x02),
id="correct_proof_1_incorrect_versioned_hash_version_0x02",
),
pytest.param(
Z,
0,
INF_POINT,
INF_POINT,
Spec.kzg_to_versioned_hash(INF_POINT, 0xFF),
id="correct_proof_1_incorrect_versioned_hash_version_0xff",
),
# Proof is the negation of G1_generator.
pytest.param(
0,
0,
G1_GENERATOR,
NEG_G1_GENERATOR,
None,
id="proof_neg_g1_generator",
),
# P+P doubling in the final G1 add: verifier computes
# `C - [y]_1 = [-1]_1 + [-1]_1`, forcing the doubling path.
pytest.param(
0,
1,
NEG_G1_GENERATOR,
INF_POINT,
None,
id="g1_doubling_in_final_add",
),
],
)
@pytest.mark.parametrize("result", [Result.FAILURE])
@pytest.mark.valid_from("Cancun")
@pytest.mark.eels_base_coverage
def test_invalid_inputs(
state_test: StateTestFiller,
pre: Alloc,
tx: Transaction,
post: Dict,
) -> None:
"""Test invalid precompile calls; verification expected to fail."""
state_test(
env=Environment(),
pre=pre,
post=post,
tx=tx,
)