albertobsd / keysubtracter

Bitcoin and Altcoins Publickey subtracter
BSD 2-Clause "Simplified" License
41 stars 34 forks source link

Why subractor making from pubkeys wth prefix 02, prefix 03 ? #11

Closed Manosuper closed 3 years ago

Manosuper commented 3 years ago

Luis, good day.

Why subractor making from pubkeys wth prefix 02, prefix 03 ?

./keysubtracter -p 02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630 -n 10 -r 0:32

023e40191ed19ba1c82d3948ffad7d11efc7352e8a071b09750fc0a62cba295f15 # - 10 02ad82cfd538d8f9a98ea7d2393a958962d3dd783456284353084ad74e459ca98c # + 10 029649575661e11d5c7c277d008c7a6d6a56c14824e31673a5a49809f94777858e # - 20 02a1c7e1fffa740388689234491047208e0f7c23a9bee61b61ef035a6d016a709c # + 20 02a3c299147e9cb77fc03b13712700361b6175e3fa3521a297854c73f680f8b389 # - 30 028a6ee5e557bf738107e02cf5533dd40d6390f4a4a1539092774246c1352583b8 # + 30 03911f949fe7d1c81152974161306cda43c810ec50839cee0ff1fd047b25eb95bf # - 40 0311d6b86415d2122e4103d63906cfda90f9f6359f2b90887839b25a2fe7e6de6b # + 40 02c234090ac778e0e311d4306a9ba41e042900f44f7166e3a17786e4376bfdfabf # - 50 039f147c6939d4d3b66eb7ae37f67652d1b4e28794a55ca39e22db6eb2c8949505 # + 50 02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630 # target

I think then subtract 02 pubkeys, all subtracted pubkeys must be 02 too. And no need use a prefix in calculation - so need use pubkey without 02,03, then subtract ?????

Luis, help please with this, I do not know code work fine or this is mistaken with "02 03".

Regard !

albertobsd commented 3 years ago

Well if you want to full understand it, you need to read about how publickeys are maked the next link have all the background that do you need to know:

https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch04.html

TL:TD

A publickey is value (X,Y), uncompress publickeys keys are prefixed with 04<X value 32 bytes hexadecimal><Y value 32 bytes hexadecimal> A publickey compress only need to know the parity of the Y value: if Y value is even: 02<X value 32 bytes hexadecimal> if Y value is odd 03<X value 32 bytes hexadecimal>

They Y value can be easyly calculted with the X value, but there is 2 results, you need to check which one do you need in base of the prefix 02 o 03.

So there is no mistake about 02 or 03 values those values can vary a lot in base of the Y parity

Manosuper commented 3 years ago

Thank you Luis !!!

Regard.