albertobsd / ecctools

Small collection of tools written in C for ECC and bitcoin
MIT License
59 stars 38 forks source link

/ 2 #20

Closed kpot87 closed 2 years ago

kpot87 commented 2 years ago

hi @albertobsd ! Can you help me and explain one thing: example privkey 0x30a6e39807c92c3533dac2acd41452 pubkey of this privkey 02B5F5D0BF884267CC5B3D6BF5B185AD6CC8BF63704D2BD0951A41B2A1744EB39C you see that this privkey is odd and it can be divide by 2 equals pubkey also can divide by 2 but when we 0x30a6e39807c92c3533dac2acd41452 / 2 = 0x185371cc03e4960000000000000000 == pubkey = 038C3D7D46F82B9287014A8E248A390760CB58E64DA570F2B6A67720FE41971A8C and 02B5F5D0BF884267CC5B3D6BF5B185AD6CC8BF63704D2BD0951A41B2A1744EB39C / 2 = 02186bd8fc6ef3103226bc23637c6d13a75a4779ff041f771c71ea386b43d6b4d4

AS you see the pubkeys are differents? why? can you explain if you know. Thank you

kpot87 commented 2 years ago
./keymath 02B5F5D0BF884267CC5B3D6BF5B185AD6CC8BF63704D2BD0951A41B2A1744EB39C / 2
Result : 02186bd8fc6ef3103226bc23637c6d13a75a4779ff041f771c71ea386b43d6b4d4 == 0x185371cc03e4961a99ed61566a0a29

0x185371cc03e496000000000000000 : How did you come to that conclusion?

or i missed something but in my python

from fractions import Fraction Fraction(0x30a6e39807c92c3533dac2acd41452/2) Fraction(126307580523951311183010847145328640, 1) hex(126307580523951311183010847145328640) '0x185371cc03e4960000000000000000'

Hurd8x commented 2 years ago
./keymath 02B5F5D0BF884267CC5B3D6BF5B185AD6CC8BF63704D2BD0951A41B2A1744EB39C / 2
Result : 02186bd8fc6ef3103226bc23637c6d13a75a4779ff041f771c71ea386b43d6b4d4 == 0x185371cc03e4961a99ed61566a0a29

0x185371cc03e496000000000000000 : How did you come to that conclusion?

or i missed something but in my python

from fractions import Fraction Fraction(0x30a6e39807c92c3533dac2acd41452/2) Fraction(126307580523951311183010847145328640, 1) hex(126307580523951311183010847145328640) '0x185371cc03e4960000000000000000'

this is because of ROUNDING !

albertobsd commented 2 years ago

if you have doubts use modmath

./modmath 0x30a6e39807c92c3533dac2acd41452 / 2
Result: 185371cc03e4961a99ed61566a0a29

btw i expected more from pyton

Hurd8x commented 2 years ago

if you have doubts use modmath

./modmath 0x30a6e39807c92c3533dac2acd41452 / 2
Result: 185371cc03e4961a99ed61566a0a29

btw i expected more from pyton

yes, bro, python not fine variant SAGE more more good for this calcs

br

kpot87 commented 2 years ago

thank every one