Skip to content

test_invalid()

Documentation for tests/byzantium/eip196_ec_add_mul/test_ecmul.py::test_invalid@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/byzantium/eip196_ec_add_mul/test_ecmul.py::test_invalid --fork Bogota

Test the invalid inputs to the ECMUL precompile.

Source code in tests/byzantium/eip196_ec_add_mul/test_ecmul.py
@pytest.mark.parametrize(
    "input_data",
    [
        pytest.param(
            PointG1(1, 3) + Scalar(0),
            id="not_on_curve_1_3_times_zero",
        ),
        pytest.param(
            PointG1(1, 3),
            id="not_on_curve_1_3_no_scalar",
        ),
        pytest.param(
            bytes(PointG1(1, 3))[:80],
            id="not_on_curve_1_3-length_80",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(0) + b"\0" * 32,
            id="not_on_curve_1_3-32_extra_byte_0x00",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(1),
            id="not_on_curve_1_3_times_one",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(2),
            id="not_on_curve_1_3_times_two",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(9),
            id="not_on_curve_1_3_times_nine",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(2**128),
            id="not_on_curve_1_3_times_2_pow_128",
        ),
        pytest.param(
            bytes(PointG1(1, 3) + Scalar(2**128))[:80],
            id="not_on_curve_1_3_times_2_pow_128-length_80",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(2**256 - 1),
            id="not_on_curve_1_3_times_2_pow_256_minus_1",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(Spec.N - 1),
            id="not_on_curve_1_3_times_group_order_minus_one",
        ),
        pytest.param(
            PointG1(1, 3) + Scalar(Spec.N),
            id="not_on_curve_1_3_times_group_order",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(0),
            id="not_on_curve_0_3_times_zero",
        ),
        pytest.param(
            PointG1(0, 3),
            id="not_on_curve_0_3_no_scalar",
        ),
        pytest.param(
            bytes(PointG1(0, 3))[:80],
            id="not_on_curve_0_3-length_80",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(0) + b"\0" * 32,
            id="not_on_curve_0_3-32_extra_byte_0x00",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(1),
            id="not_on_curve_0_3_times_one",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(2),
            id="not_on_curve_0_3_times_two",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(9),
            id="not_on_curve_0_3_times_nine",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(2**128),
            id="not_on_curve_0_3_times_2_pow_128",
        ),
        pytest.param(
            bytes(PointG1(0, 3) + Scalar(2**128))[:80],
            id="not_on_curve_0_3_times_2_pow_128-length_80",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(2**256 - 1),
            id="not_on_curve_0_3_times_2_pow_256_minus_1",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(Spec.N - 1),
            id="not_on_curve_0_3_times_group_order_minus_one",
        ),
        pytest.param(
            PointG1(0, 3) + Scalar(Spec.N),
            id="not_on_curve_0_3_times_group_order",
        ),
        pytest.param(
            PointG1(7827, 6598) + Scalar(0),
            id="not_on_curve_7827_6598_times_zero",
        ),
        pytest.param(
            PointG1(7827, 6598) + Scalar(1),
            id="not_on_curve_7827_6598_times_one",
        ),
        pytest.param(
            PointG1(Spec.P, 0) + Scalar(1),
            id="x_eq_P",
        ),
        pytest.param(
            PointG1(0, Spec.P) + Scalar(1),
            id="y_eq_P",
        ),
        pytest.param(
            PointG1(Spec.G1.x + Spec.P, Spec.G1.y) + Scalar(1),
            id="x_plus_P",
        ),
        pytest.param(
            PointG1(Spec.G1.x, Spec.G1.y + Spec.P) + Scalar(1),
            id="y_plus_P",
        ),
    ],
)
@pytest.mark.parametrize(
    "expected_output", [pytest.param(b"", id=pytest.HIDDEN_PARAM)]
)
@pytest.mark.ported_from(
    [
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_0_21000_128Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_0_21000_64Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_0_21000_80Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_0_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_1_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_2_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_9_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_340282366920938463463374607431768211456_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_5616_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_5617_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_1-3_9935_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_7827-6598_0_21000_128Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge/ecmul_7827-6598_1_21000_128Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_0_21000_128Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_0_21000_64Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_0_21000_80Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_0_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_1_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_2_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_340282366920938463463374607431768211456_21000_80Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_340282366920938463463374607431768211456_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_5616_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_5617_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_9935_21000_96Filler.json",
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecmul_0-3_9_21000_96Filler.json",
    ],
    pr=["https://github.com/ethereum/execution-specs/pull/2403"],
)
def test_invalid(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """Test the invalid inputs to the ECMUL precompile."""
    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 30 parametrized test cases across 13 forks.