Post
Topic
Board Development & Technical Discussion
Merits 15 from 6 users
Re: Fail at coding my own Secp256k1 function (Pyhon)
by
j2002ba2
on 11/08/2022, 17:18:23 UTC
⭐ Merited by o_e_l_e_o (4) ,SamYezi (3) ,ETFbitcoin (3) ,Welsh (2) ,NotATether (2) ,DdmrDdmr (1)
...
I got it, and  your suggestions are useful. I changed the code here and on Github. However It still doesn't work for small numbers (See the test case 1)
https://github.com/MaltoonYezi/Python-DSA/blob/main/Cryptography/SECP256k1Procedural.py
Sorry, for a delayed response

You got mistaken somewhere (or, as usual, in many places).

Test case 1 asks us to multiply (47,71) by 8 modulo 223 (with a=0, b=7). However with this prime the curve has structure 42x6, it is noncyclic.  Point (47,71) is from the group of (7,166); while (49,71) is from the group of (8,127). So, you could never reach either point from the other one.

You might want to change the test. If you insist on modulo 223, then b=5 is a good choice. Otherwise (b=7) use modulo 67 or 79, they are a bit like p and n in secp256k1, modulo one of them the group size is the other.