Skip to content

Commit 45ba0a8

Browse files
authored
feat(tests): add test cases for P256 input s special values (#2215)
Add test cases for the `p256verify` precompile with `s` edge values: `1`, `N-1` and `(2**256-1)%N`. For the last value also include an invalid signature because not covered by other test cases.
1 parent 28e339e commit 45ba0a8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/osaka/eip7951_p256verify_precompiles/test_p256verify.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ def test_wycheproof_extra(state_test: StateTestFiller, pre: Alloc, post: dict, t
124124
+ Y(Spec.Gy),
125125
id="hash_max",
126126
),
127+
pytest.param(
128+
H(Spec.N + 1 - Spec.Gx) + R(Spec.Gx) + S(1) + X(Spec.Gx) + Y(Spec.Gy),
129+
id="s_1",
130+
),
131+
pytest.param(
132+
H(Spec.N - 1 - Spec.Gx) + R(Spec.Gx) + S(Spec.N - 1) + X(Spec.Gx) + Y(Spec.Gy),
133+
id="s_N_minus_1",
134+
),
135+
pytest.param(
136+
H(((2**256 - 1) % Spec.N) - Spec.Gx + Spec.N)
137+
+ R(Spec.Gx)
138+
+ S((2**256 - 1) % Spec.N)
139+
+ X(Spec.Gx)
140+
+ Y(Spec.Gy),
141+
id="s_max_mod_N",
142+
),
127143
pytest.param(
128144
H(0xC3D3BE9EB3577F217AE0AB360529A30B18ADC751AEC886328593D7D6FE042809)
129145
+ R(0x3A4E97B44CBF88B90E6205A45BA957E520F63F3C6072B53C244653278A1819D8)
@@ -205,6 +221,10 @@ def test_valid(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transact
205221
Spec.H0 + Spec.R0 + S(Spec.N) + Spec.X0 + Spec.Y0,
206222
id="s_eq_to_n",
207223
),
224+
pytest.param(
225+
Spec.H0 + R(Spec.Gx) + S((2**256 - 1) % Spec.N) + X(Spec.Gx) + Y(Spec.Gy),
226+
id="s_max_mod_N",
227+
),
208228
pytest.param(
209229
Spec.H0 + Spec.R0 + Spec.S0 + X(Spec.P) + Spec.Y0,
210230
id="x_eq_to_p",

0 commit comments

Comments
 (0)