Skip to content

test_invalid_inputs()

Documentation for tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_invalid_inputs@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_invalid_inputs --fork Amsterdam

Test invalid precompile calls; verification expected to fail.

Source code in tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
@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,
    )

Parametrized Test Cases

This test generates 14 parametrized test cases across 4 forks.