Skip to content

test_valid()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py::test_valid@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py::test_valid --fork Amsterdam

Test the BLS12_MAP_FP2_TO_G2 precompile.

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@pytest.mark.parametrize(
    "input_data,expected_output,vector_gas_value",
    # Test vectors from the reference spec (from the cryptography team)
    vectors_from_file("map_fp2_to_G2_bls.json")
    + [
        pytest.param(
            FP2((0, 0)),
            G2_POINT_ZERO_FP,
            None,
            id="fp_0",
        ),
        pytest.param(
            FP2((Spec.P - 1, Spec.P - 1)),
            PointG2(
                (
                    0x9BF1B857D8C15F317F649ACCFA7023EF21CFC03059936B83B487DB476FF9D2FE64C6147140A5F0A436B875F51FFDF07,
                    0xBB10E09BDF236CB2951BD7BCC044E1B9A6BB5FD4B2019DCC20FFDE851D52D4F0D1A32382AF9D7DA2C5BA27E0F1C69E6,
                ),
                (
                    0xDD416A927AB1C15490AB753C973FD377387B12EFCBE6BED2BF768B9DC95A0CA04D1A8F0F30DBC078A2350A1F823CFD3,
                    0x171565CE4FCD047B35EA6BCEE4EF6FDBFEC8CC73B7ACDB3A1EC97A776E13ACDFEFFC21ED6648E3F0EEC53DDB6C20FB61,
                ),
            ),
            None,
            id="fp_p_minus_1",
        ),
        pytest.param(
            FP2(
                (
                    3510328712861478240121438855244276237335901234329585006107499559909114695366216070652508985150831181717984778988906,
                    2924545590598115509050131525615277284817672420174395176262156166974132393611647670391999011900253695923948997972401,
                )
            ),
            Spec.INF_G2,
            None,
            id="fp_map_to_inf",
        ),
    ],
)
@pytest.mark.eels_base_coverage
def test_valid(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """Test the BLS12_MAP_FP2_TO_G2 precompile."""
    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 3 forks.