Bitcoin Forum
May 08, 2024, 05:39:53 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Python Request : Add, Subtract, Divide and Multiply Public Keys  (Read 257 times)
CoinMagus (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
December 21, 2021, 08:54:23 AM
 #1

I want to do this with Python, if you have any, can you share? --> https://github.com/albertobsd/keysubtracter

Thanks.
1715146793
Hero Member
*
Offline Offline

Posts: 1715146793

View Profile Personal Message (Offline)

Ignore
1715146793
Reply with quote  #2

1715146793
Report to moderator
The network tries to produce one block per 10 minutes. It does this by automatically adjusting how difficult it is to produce blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715146793
Hero Member
*
Offline Offline

Posts: 1715146793

View Profile Personal Message (Offline)

Ignore
1715146793
Reply with quote  #2

1715146793
Report to moderator
1715146793
Hero Member
*
Offline Offline

Posts: 1715146793

View Profile Personal Message (Offline)

Ignore
1715146793
Reply with quote  #2

1715146793
Report to moderator
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7486


Crypto Swap Exchange


View Profile
December 21, 2021, 09:55:32 AM
Merited by PrimeNumber7 (1)
 #2

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).

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
December 21, 2021, 10:06:22 AM
 #3

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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
NeuroticFish
Legendary
*
Offline Offline

Activity: 3668
Merit: 6381


Looking for campaign manager? Contact icopress!


View Profile
December 21, 2021, 10:07:09 AM
 #4

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).

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
December 21, 2021, 10:11:11 AM
 #5

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...

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
NeuroticFish
Legendary
*
Offline Offline

Activity: 3668
Merit: 6381


Looking for campaign manager? Contact icopress!


View Profile
December 21, 2021, 10:17:15 AM
 #6

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.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
December 21, 2021, 10:32:04 AM
Merited by NeuroticFish (2), ABCbits (1)
 #7

--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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
bigvito19
Full Member
***
Offline Offline

Activity: 706
Merit: 111


View Profile
December 21, 2021, 10:35:24 AM
 #8

I want to do this with Python, if you have any, can you share? --> https://github.com/albertobsd/keysubtracter

Thanks.

Python 3 Version

https://github.com/WanderingPhilosopher/Windows-KeySubtractor/releases/tag/v1.0
CoinMagus (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 1


View Profile
December 21, 2021, 10:47:41 AM
 #9

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?
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6730


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 21, 2021, 02:08:22 PM
Merited by ABCbits (1)
 #10

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).

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
December 22, 2021, 10:09:35 AM
 #11


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
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6730


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 22, 2021, 11:10:59 AM
 #12


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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
December 22, 2021, 02:02:09 PM
Merited by NotATether (2)
 #13


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)
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6730


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 24, 2021, 07:40:34 AM
Merited by mocacinno (5), ABCbits (3)
 #14

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 <secp256k1>)
X: 0x6ccae81fef496780cab0b333a2712e867bda428f09fb4374628a16b164d48cf2
Y: 0x32141673b26e4302a3d33c9148d16c0445ae4e84c577352a47dceebb0a6cf0e6
(On curve <secp256k1>)
X: 0xea31f5d48f0c43969b607d592636e2443539e7a86ef1350dba0d9040a98fc378
Y: 0x9e324a7345f1b9c1ee964b82fe43492b8f0bc5186713d81f45d7488139e4b7c
(On curve <secp256k1>)
X: 0x97539272d59d6e75488df9a5628e7b0efc03b4fec79de246ac116ae40c05225a
Y: 0xc809e0056436079a426d5084fef7b806015f4138e1c544857a2a2bb1a7f80c2e
(On curve <secp256k1>)

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).

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!