Skip to content

Commit 180e610

Browse files
authored
enhance(test-tests): add ecrecover test cases (#1857)
Add valid ecrecover test inputs which invoke point doubling in the multi-scalar multiplication based on the Shamir trick. Ported from evmone unit tests: ipsilon/evmone#1391.
1 parent 55d6595 commit 180e610

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

tests/frontier/precompiles/test_ecrecover.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,120 @@
228228
),
229229
id="13u1_eq_u2_R_eq_13G",
230230
),
231+
# R == 2G, low s
232+
pytest.param(
233+
bytes.fromhex(
234+
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
235+
),
236+
bytes.fromhex(
237+
"000000000000000000000000000000000000000000000000000000000000001c"
238+
),
239+
bytes.fromhex(
240+
"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"
241+
),
242+
bytes.fromhex(
243+
"000000000000000000000000000000000000000000000000000000000000000b"
244+
),
245+
bytes.fromhex(
246+
"000000000000000000000000a77cc0129dba3df2c0e27f2bfe79a18b498f8934"
247+
),
248+
id="R_eq_2G_low_s",
249+
),
250+
# R == 2G, high s
251+
pytest.param(
252+
bytes.fromhex(
253+
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
254+
),
255+
bytes.fromhex(
256+
"000000000000000000000000000000000000000000000000000000000000001c"
257+
),
258+
bytes.fromhex(
259+
"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"
260+
),
261+
bytes.fromhex(
262+
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413b"
263+
),
264+
bytes.fromhex(
265+
"000000000000000000000000bbb10a3b5835400b63ca00372c16db781220fb0b"
266+
),
267+
id="R_eq_2G_high_s",
268+
),
269+
# R == 3G, low s
270+
pytest.param(
271+
bytes.fromhex(
272+
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
273+
),
274+
bytes.fromhex(
275+
"000000000000000000000000000000000000000000000000000000000000001c"
276+
),
277+
bytes.fromhex(
278+
"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"
279+
),
280+
bytes.fromhex(
281+
"0000000000000000000000000000000000000000000000000000000000000010"
282+
),
283+
bytes.fromhex(
284+
"000000000000000000000000620833dce54ca9329f13a22c3831b102f15df27c"
285+
),
286+
id="R_eq_3G_low_s",
287+
),
288+
# R == 3G, high s
289+
pytest.param(
290+
bytes.fromhex(
291+
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
292+
),
293+
bytes.fromhex(
294+
"000000000000000000000000000000000000000000000000000000000000001c"
295+
),
296+
bytes.fromhex(
297+
"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"
298+
),
299+
bytes.fromhex(
300+
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036412a"
301+
),
302+
bytes.fromhex(
303+
"000000000000000000000000b0e0b5974d71cd6d9142451cc94291dec4191b8b"
304+
),
305+
id="R_eq_3G_high_s",
306+
),
307+
# R == 4G, low s
308+
pytest.param(
309+
bytes.fromhex(
310+
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
311+
),
312+
bytes.fromhex(
313+
"000000000000000000000000000000000000000000000000000000000000001c"
314+
),
315+
bytes.fromhex(
316+
"e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13"
317+
),
318+
bytes.fromhex(
319+
"0000000000000000000000000000000000000000000000000000000000000020"
320+
),
321+
bytes.fromhex(
322+
"0000000000000000000000009d39e4bd10915d73b7d6ba205c1aefd814710aaa"
323+
),
324+
id="R_eq_4G_low_s",
325+
),
326+
# R == 4G, high s
327+
pytest.param(
328+
bytes.fromhex(
329+
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
330+
),
331+
bytes.fromhex(
332+
"000000000000000000000000000000000000000000000000000000000000001c"
333+
),
334+
bytes.fromhex(
335+
"e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13"
336+
),
337+
bytes.fromhex(
338+
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364112"
339+
),
340+
bytes.fromhex(
341+
"0000000000000000000000000a6fe081a013109d981bad2c5143d7a1fd3bfef7"
342+
),
343+
id="R_eq_4G_high_s",
344+
),
231345
],
232346
)
233347
def test_precompiles(

0 commit comments

Comments
 (0)