Author

Topic: Python Request : Add, Subtract, Divide and Multiply Public Keys (Read 257 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange

I just tested the script using Python 3.9 (with most recent version of fastecdsa and bit) and i experience same problem. Additionally, on line 45 you forget to add equal symbol.
 

ok, I will try upgrade by python to 3.9 and test again my WSL python is 3.8

What? I said i experience same problem, which means i also got same error message.

Can you help to explain each value on shiftdown function for non-programmer understand?

I'm not experienced with cryptography, so i barely can explain it. You could try ask @NotATether or wait someone else giving you an explanation.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
The issue was because the public keys were not being converted to secp256k1 points in the example. It should work now and print this:

Code:
$ python script.py
X: 0xf0c386f6714fe5940ec7e622d8ba2e5204c58cd71a9c73ca95fb0e4ec0e76d72
Y: 0x56cc1950b7e993f76df9848ad106789f49d1bee3f68d346e03024cd31b3ffcb8
(On curve )
X: 0x6ccae81fef496780cab0b333a2712e867bda428f09fb4374628a16b164d48cf2
Y: 0x32141673b26e4302a3d33c9148d16c0445ae4e84c577352a47dceebb0a6cf0e6
(On curve )
X: 0xea31f5d48f0c43969b607d592636e2443539e7a86ef1350dba0d9040a98fc378
Y: 0x9e324a7345f1b9c1ee964b82fe43492b8f0bc5186713d81f45d7488139e4b7c
(On curve )
X: 0x97539272d59d6e75488df9a5628e7b0efc03b4fec79de246ac116ae40c05225a
Y: 0xc809e0056436079a426d5084fef7b806015f4138e1c544857a2a2bb1a7f80c2e
(On curve )

What is k value?

k is equal to 1/i (one divided by 'i'). Because division is not directly possible on the curve, I raise the divisor to the (N-2)th power. Because when you do that and then take modulo N, that is equal to taking the (-1)th power.

[if I were to take the (N-1)th power instead, that would be like taking the 0th power which results in the number 1, because taking the Nth power gives us the 1st power which is the same number as input - the exact same result because the group is cyclic - repeats itself over and over again.]

'i' stands for the remainder of the public key division you want to get. @WanderingPhilosipher explained it in the Kangaroo thread somewhere, but basically, if you divide by 32, there are exactly 32 unique answers for the division by adding the public key to [0, 1, 2, .... 31] before dividing, so the 'i' selects which answer you need out of those 32 (it can be any number not just 32, it's just an example. It can even be an odd number as long as it's bigger than 0).
member
Activity: 406
Merit: 45

I just tested the script using Python 3.9 (with most recent version of fastecdsa and bit) and i experience same problem. Additionally, on line 45 you forget to add equal symbol.
 

ok, I will try upgrade by python to 3.9 and test again my WSL python is 3.8

Can you help to explain each value on shiftdown function for non-programmer understand?

pubkey in hex convert to pubkey point x and y is Q (Q.x,Q.y)
G is Gx,Gy of curve right
P is value after subtract value
What is k value?
i is how may time to dividing

I am hobby code not professional coder, try to understand (may be slowly understand)
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org

No need to do that.... as I already solved this problem several months ago.

See https://gist.github.com/ZenulAbidin/286a652b160086b3b0f184a886ba68ca (shiftup is multiply, and shiftdown is divide).

this scripts last version update run with some error
TypeError: unsupported operand type(s) for -: 'str' and 'Point' and  pk2 missing =

last version on my WSL ubuntu run fine

That's strange... because the last update yesterday was only to add the division and multiplication funcs that were lying around elsewhere. I don't believe I altered any other code.
member
Activity: 406
Merit: 45

No need to do that.... as I already solved this problem several months ago.

See https://gist.github.com/ZenulAbidin/286a652b160086b3b0f184a886ba68ca (shiftup is multiply, and shiftdown is divide).

this scripts last version update run with some error
TypeError: unsupported operand type(s) for -: 'str' and 'Point' and  pk2 missing =

last version on my WSL ubuntu run fine

how every will be great if can have some version for python on windows 10 use ecdsa or other
because fastecdsa it is can use only on Linux (can't install on windows), for run scripts with fastecdsa for me use no problem I use WSL
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
I doubt people is willing to do your request for free. I would recommend you to check Services board to see any developer who're experienced with both C and Python. But why don't you just use the tool as it is? You just need to compile it (if you're linux user) or use compiled windows version (https://github.com/WanderingPhilosopher/Windows-KeySubtractor/releases/tag/v1.0).

No need to do that.... as I already solved this problem several months ago.

See https://gist.github.com/ZenulAbidin/286a652b160086b3b0f184a886ba68ca (shiftup is multiply, and shiftdown is divide).
newbie
Activity: 16
Merit: 1
I doubt people is willing to do your request for free. I would recommend you to check Services board to see any developer who're experienced with both C and Python. But why don't you just use the tool as it is? You just need to compile it (if you're linux user) or use compiled windows version (https://github.com/WanderingPhilosopher/Windows-KeySubtractor/releases/tag/v1.0).


I already use this tool in WSL... I don't feel any trust issues. Since I don't know the C language, I can't change it according to my own opinion. I know a little Python language and if there is a Python version of it, I would like to realize a few of my ideas on it.


You can not be serious?
legendary
Activity: 3388
Merit: 4919
https://merel.mobi => buy facemasks with BTC/LTC
--snip--

In the solution you propose, I guess that he will have to get the output and parse it. Clearly possible and clearly inelegant too Wink
On the other hand, in case he wants to do this (run a command line, get the output) for a website, I don't know whether that's possible at all (but I may be completely wrong too).

Of course, what I wrote was an idea OP can take into account or completely ignore. No biggie.

Just for the sake of clarity and completeness, i'd like to say that it's defenatly inelegant, but i do system calls from python scripts all the time and python is perfectly capable of handling these situations... In my line of work, i usually get closed source binaries from vendors... If i want to write wrapper scripts, the only thing i can do is use system calls to these closed source binaries and parse the output... Offcourse, if the vendor upgrades his binary, or if you get unforseen output, you'll need to maintain the wrapper script aswell.

As for using the output for a website: it shouldn't matter if he's using a native python library or a system call. The end result is exactly the same.
legendary
Activity: 3668
Merit: 6382
Looking for campaign manager? Contact icopress!
It may be much less painful for some (Linux?) C developer to convert that keysubtracter into a library and OP use/call that library from Python (if OP can do such calls).


Worst case scenario OP can always do a system call directly from his script... Not the most elegant sollution, but depending on his usecase, it might work just aswell? I mean, it's not like it's a brute force tool or something (and even if it was, it would probably be a better idear to use a native c tool instead of a python tool), so a simple system call will probably do the trick just as good as a real python library...

In the solution you propose, I guess that he will have to get the output and parse it. Clearly possible and clearly inelegant too Wink
On the other hand, in case he wants to do this (run a command line, get the output) for a website, I don't know whether that's possible at all (but I may be completely wrong too).

Of course, what I wrote was an idea OP can take into account or completely ignore. No biggie.
legendary
Activity: 3388
Merit: 4919
https://merel.mobi => buy facemasks with BTC/LTC
It may be much less painful for some (Linux?) C developer to convert that keysubtracter into a library and OP use/call that library from Python (if OP can do such calls).


Worst case scenario OP can always do a system call directly from his script... Not the most elegant sollution, but depending on his usecase, it might work just aswell? I mean, it's not like it's a brute force tool or something (and even if it was, it would probably be a better idear to use a native c tool instead of a python tool), so a simple system call will probably do the trick just as good as a real python library...
legendary
Activity: 3668
Merit: 6382
Looking for campaign manager? Contact icopress!
It may be much less painful for some (Linux?) C developer to convert that keysubtracter into a library and OP use/call that library from Python (if OP can do such calls).
legendary
Activity: 3388
Merit: 4919
https://merel.mobi => buy facemasks with BTC/LTC
Like ETFbitcoin said, why don't you use the tool itself instead?

Compiling it is really, really, really easy... Here's the binary i compiled (took me 2 minutes to do): https://mocacinno.com/hotlinkimages/keysubtracter
Is it safe? I really don't know... I have not read the sourcecode, nor would i run a binary compiled by somebody else i didn't fully trust... So yeah, if i was in your position, i'd read the sourcecode and compile the binary myself instead of using one that was compiled by somebody else, but at least now you have a choice...

BTW: since i did not read the soucecode, i'll remove the binary later today... If you need it, download it, if not leave it be... It won't be on my server for more than a couple of hours.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
I doubt people is willing to do your request for free. I would recommend you to check Services board to see any developer who're experienced with both C and Python. But why don't you just use the tool as it is? You just need to compile it (if you're linux user) or use compiled windows version (https://github.com/WanderingPhilosopher/Windows-KeySubtractor/releases/tag/v1.0).
newbie
Activity: 16
Merit: 1
I want to do this with Python, if you have any, can you share? --> https://github.com/albertobsd/keysubtracter

Thanks.
Jump to: