@pytest.mark.parametrize(
"input_data",
[
pytest.param(
H(0) + R(Spec.Gx) + S(Spec.Gx) + X(Spec.Gx) + Y(Spec.Gy),
id="hash_0",
),
pytest.param(
H(Spec.N - 1)
+ R(Spec.Gx)
+ S(Spec.Gx - 1)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="hash_N_minus_1",
),
pytest.param(
H(Spec.N) + R(Spec.Gx) + S(Spec.Gx) + X(Spec.Gx) + Y(Spec.Gy),
id="hash_N",
),
pytest.param(
H(Spec.P - 1)
+ R(Spec.Gx)
+ S(Spec.Gx + Spec.P - 1 - Spec.N)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="hash_P_minus_1",
),
pytest.param(
H(Spec.P)
+ R(Spec.Gx)
+ S(Spec.Gx + Spec.P - Spec.N)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="hash_P",
),
pytest.param(
H(2**256 - 1)
+ R(Spec.Gx)
+ S(Spec.Gx + 2**256 - 1 - Spec.N)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="hash_max",
),
pytest.param(
H(Spec.N + 1 - Spec.Gx)
+ R(Spec.Gx)
+ S(1)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="s_1",
),
pytest.param(
H(Spec.N - 1 - Spec.Gx)
+ R(Spec.Gx)
+ S(Spec.N - 1)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="s_N_minus_1",
),
pytest.param(
H(((2**256 - 1) % Spec.N) - Spec.Gx + Spec.N)
+ R(Spec.Gx)
+ S((2**256 - 1) % Spec.N)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="s_max_mod_N",
),
pytest.param(
H(
0xC3D3BE9EB3577F217AE0AB360529A30B18ADC751AEC886328593D7D6FE042809
)
+ R(
0x3A4E97B44CBF88B90E6205A45BA957E520F63F3C6072B53C244653278A1819D8
)
+ S(
0x6A184AA037688A5EBD25081FD2C0B10BB64FA558B671BD81955CA86E09D9D722
)
+ X(0)
+ Y(
0x66485C780E2F83D72433BD5D84A06BB6541C2AF31DAE871728BF856A174F93F4
),
id="x_0_y_positive",
),
pytest.param(
H(
0xF98A88895CB0866C5BAD58CF03000DDF9D21CB9407892FF54D637E6A046AFBB3
)
+ R(
0x81DC074973D3222F3930981AD98D022517C91063FFB83CFD620E29B86DC30A8F
)
+ S(
0x365E4CD085617A265765062A2D9954ED86309DFA33CF5AE1464FE119419FC34A
)
+ X(0)
+ Y(
0x99B7A386F1D07C29DBCC42A27B5F9449ABE3D50DE25178E8D7407A95E8B06C0B
),
id="x_0_y_negative",
),
pytest.param(
H(
0x5F95DCD6E41662D1E0AEFCCDB7877877C1FD88C9E67FC3CDA0D1D520FA8A3AC2
)
+ R(
0xAF5DFDDB7EDC789D7C9C42A44AFBBF13C8F1D77D576B6EE5F11FEA4F33E2CB39
)
+ S(
0xA28F8C5625AD622950F2FCE9672784B287EF9E032ADE8C23BA218413A1CF6522
)
+ X(5)
+ Y(
0x459243B9AA581806FE913BCE99817ADE11CA503C64D9A3C533415C083248FBCC
),
id="x_5_y_positive",
),
pytest.param(
H(
0x31CE0B00FA8DD61EF28C7DC5F839C78CF70D60E625E0670BF9C9FCE25E89D99F
)
+ R(
0x0FA19CBE154513BA348F2DB951AFB6E135BAC5BD8891282781A032103C3F1289
)
+ S(
0xD9ABF5C4E61098A6E653F265770BDBA36ECC8073CEF99548D89FE2C39A7AFA9B
)
+ X(5)
+ Y(
0xBA6DBC4555A7E7FA016EC431667E8521EE35AFC49B265C3ACCBEA3F7CDB70433
),
id="x_5_y_negative",
),
pytest.param(
H(
0x65B0E03E7A27E6F9F4989C72486FCAF0A3ECF3EF60D14F1C11FB5BF071A8FD1B
)
+ R(
0x0B0CC9E314E4180FE18D205010DD1C4410632D472CC4E7AB56CBC04091ABE006
)
+ S(
0x8D12C4F19AC41D7877705453A247AB96394E7C093F57EC073A9D150CDE6B68C6
)
+ X(
0x09E78D4EF60D05F750F6636209092BC43CBDD6B47E11A9DE20A9FEB2A50BB96C
)
+ Y(1),
id="y_1",
),
pytest.param(
H(
0x744084AD41EE67ED1802A6868ACE7815FD6FC0585A3479FF68E69ADB8DD2B420
)
+ R(
0xB481C7650CBE85BCD15565811966DA2DA4E4E2931F0892D911520B6A06C340D8
)
+ S(
0xE4C2D9FB9A4E3E29B7414F0408B2EBC4421D5BC8ADDCCF864AFF9E7E10DA31BB
)
+ X(
0x09E78D4EF60D05F750F6636209092BC43CBDD6B47E11A9DE20A9FEB2A50BB96C
)
+ Y(Spec.P - 1),
id="y_P_minus_1",
),
# Test case for u1==u2 and Q==G.
# This test case is important because u1*G + u2*Q is point doubling.
pytest.param(
H(
0x7CF27B188D034F7E8A52380304B51AC3C08969E277F21B35A60B48FC47669978
)
+ R(
0x7CF27B188D034F7E8A52380304B51AC3C08969E277F21B35A60B48FC47669978
)
+ S(
0x830D84E672FCB08275ADC7FCFB4AE53BFC5D90CB2F25834F4DAE81C6B4FC8BD9
)
+ X(Spec.Gx)
+ Y(Spec.Gy),
id="u1_eq_u2_and_Q_eq_G",
),
# Test case for u1==u2 and Q!=G.
pytest.param(
H(
0x65FB4407BCB2A33AE2E486366BAA79B3A8A17A83DDE0FED6F09014A8AC6F78A1
)
+ R(
0x65FB4407BCB2A33AE2E486366BAA79B3A8A17A83DDE0FED6F09014A8AC6F78A1
)
+ S(
0x65FB4407BCB2A33AE2E486366BAA79B3A8A17A83DDE0FED6F09014A8AC6F78A1
)
+ Spec.X0
+ Spec.Y0,
id="u1_eq_u2_and_Q_ne_G",
),
],
)
@pytest.mark.parametrize(
"expected_output", [Spec.SUCCESS_RETURN_VALUE], ids=[""]
)
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
def test_valid(
state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transaction
) -> None:
"""Positive tests for the P256VERIFY precompile."""
state_test(env=Environment(), pre=pre, post=post, tx=tx)