Title: Simple private key to public key converter Post by: release on January 21, 2021, 07:56:57 AM I am hoping someone can provide mean script preferably python that converts private key in binary and/or hex and converts to public key. Preferably just the X coordinate. Y coordinate is fine also or compressed/uncompressed. Don't need the address generated I can do that myself just wanted a stand alone script. Thanks
Title: Re: Simple private key to public key converter Post by: odolvlobo on January 21, 2021, 08:27:49 AM If you are looking for a challenge, this Javascript code will do it (requires Node.js):
Code: Crypto = require('crypto'); Title: Re: Simple private key to public key converter Post by: release on January 21, 2021, 08:34:27 AM If you are looking for a challenge, this Javascript code will do it (requires Node.js): Code: Crypto = require('crypto'); Lol thank you. Do you know python? Title: Re: Simple private key to public key converter Post by: release on January 21, 2021, 08:35:54 AM Looking for a simple script with like: print(publickey)
Title: Re: Simple private key to public key converter Post by: BlackHatCoiner on January 21, 2021, 10:31:37 AM On secp256k1-py (https://github.com/ludbb/secp256k1-py):
Code: from secp256k1 import PrivateKey I guess that does the job. Title: Re: Simple private key to public key converter Post by: release on January 21, 2021, 12:43:05 PM On secp256k1-py (https://github.com/ludbb/secp256k1-py): Code: from secp256k1 import PrivateKey I guess that does the job. Perfect thank you Title: Re: Simple private key to public key converter Post by: bkelly13 on December 05, 2022, 06:14:58 AM Does anyone know where to find the specific steps to convert from private to public key?
By that I exclude library functions from Java, or Perl or anything where the transformation takes place in a pre-written function that the programmer calls. In other words, maybe something than can be written into C code and make the transformation. I have found code for SHA-256 and RIPEMD-160 and can do those individual steps. But I have not figured out how to put them together to go from private to public then to address. I am not a math major. Title: Re: Simple private key to public key converter Post by: witcher_sense on December 05, 2022, 08:34:02 AM Does anyone know where to find the specific steps to convert from private to public key? It is not that hard: you take a generator point of secp256k1 elliptic curve and multiply it your private key times using specific elliptic curve multiplication. Elliptic curve point multiplication is unlike standard multiplication because it consists of two operations instead of one: point addition and point doubling, which in itself involve calculating modulo inverse using an extended Euclidean algorithm. Essentially, you take a private key (a 256-bit number) and perform point addition each time you see '1', and you perform point doubling each time you see '0'. 256 operations to calculate a point on an elliptic curve that will correspond to your secret number. So, the whole algorithm for calculating a public key from a private one consists of special math functions performing all those calculations.If you are interested, you can check my "poorly written" Python re-implementation of this algorithm: Converting HEX private key to bitcoin address (https://bitcointalk.org/index.php?topic=5413370.msg60929965#msg60929965) Title: Re: Simple private key to public key converter Post by: bkelly13 on December 06, 2022, 02:03:42 AM Seems to me its quite a bit harder than at first appears.
Re: “you take a generator point of secp256k1 elliptic curve…” There is much more to that than immediately meets the eye. I tried reading about elliptic curve and have no idea of how to implement it into code. I looked at your Python and see many steps in there I don’t know how to translate into C code. I don’t know Python. The best I have found so far is here: https://academy.bit2me.com/en/como-se-crea-una-direccion-bitcoin/ (https://academy.bit2me.com/en/como-se-crea-una-direccion-bitcoin/) But when the private key they used is put in an on-line translate page, the numbers do not match the public key of that page. Well, that is to say I have not been able to produce identical results. I have code to do SHA-256 and RIPEMD-160, and wrote some test apps that does those translations, and they get the same values as some on-line tools. But there are intermediate steps that I have not figured out or found. Is there anyone that knows the step-by-step process to translate the private key into the public key? Title: Re: Simple private key to public key converter Post by: Edwardard on December 06, 2022, 02:57:05 AM Is there anyone that knows the step-by-step process to translate the private key into the public key? Check this out: Bitcoin python tutorial for beginners (https://youtu.be/tX-XokHf_nI).PS: It's a long one, but quite informative Title: Re: Simple private key to public key converter Post by: bkelly13 on December 06, 2022, 04:04:25 AM Is there anyone that knows the step-by-step process to translate the private key into the public key? Check this out: Bitcoin python tutorial for beginners (https://youtu.be/tX-XokHf_nI).PS: It's a long one, but quite informative At about 7:50 the narrator states they will call the function and not use the code to implement the function. That does not help me. Thanks for the reply. Title: Re: Simple private key to public key converter Post by: odolvlobo on December 07, 2022, 10:08:51 AM If you want C code, this will give you plenty: https://duckduckgo.com/?q=elliptic+curve+library+C
Keep in mind that most people don't write their own because there are already libraries in most languages that have been tested. Title: Re: Simple private key to public key converter Post by: DannyHamilton on December 09, 2022, 12:04:49 AM Keep in mind that most people don't write their own because there are already libraries in most languages that have been tested. Sure, but I have to say that I found it quite fun to write my own C program that would take a file of private keys and generate the associated public keys and Legacy bitcoin addresses. Title: Re: Simple private key to public key converter Post by: PawGo on December 09, 2022, 05:05:28 PM Keep in mind that most people don't write their own because there are already libraries in most languages that have been tested. Sure, but I have to say that I found it quite fun to write my own C program that would take a file of private keys and generate the associated public keys and Legacy bitcoin addresses. Do you have it available anywhere? Please share it. It would be really interesting to see, as it contains a lot of intermediary steps: point multiplication, hash calculation etc. Title: Re: Simple private key to public key converter Post by: bkelly13 on December 11, 2022, 04:24:09 AM Keep in mind that most people don't write their own because there are already libraries in most languages that have been tested. Sure, but I have to say that I found it quite fun to write my own C program that would take a file of private keys and generate the associated public keys and Legacy bitcoin addresses. I would really like to hear about that and see your code. A large part is the question of what transformations are applied. I cannot find the post from here right now but someone provided this link: https://gobittest.appspot.com/Address (https://gobittest.appspot.com/Address) Its the best I have seen. But in this one, it shows item 0 the private ECDSA Key, then item 1 the Public ECDSA Key. I don't see anything about how to translate from private to public. Title: Re: Simple private key to public key converter Post by: witcher_sense on December 11, 2022, 05:22:38 AM I would really like to hear about that and see your code. I have rewritten my original script to make the conversion process simpler to understand. Specifically, I added comprehensive comments describing each step of calculating bitcoin addresses and private keys in wallet import format (WIF). I also added links where you can find corresponding formulas to calculate public keys from private keys. I think, if you have a basic understanding of some programming language like C/C++, you can read Python code and adapt it if needed.A large part is the question of what transformations are applied. I cannot find the post from here right now but someone provided this link: https://gobittest.appspot.com/Address (https://gobittest.appspot.com/Address) Its the best I have seen. But in this one, it shows item 0 the private ECDSA Key, then item 1 the Public ECDSA Key. I don't see anything about how to translate from private to public. Code: import base58 # pip install base58 Title: Re: Simple private key to public key converter Post by: ramakrishna0905 on December 15, 2022, 01:25:57 PM Hi
Any one have python code for Public key to address converter Public key =Input.txt file Address = output.txt file Input file to output file Title: Re: Simple private key to public key converter Post by: witcher_sense on December 15, 2022, 01:56:37 PM Hi Any one have python code for Public key to address converter Public key =Input.txt file Address = output.txt file Input file to output file I spent ten minutes writing this program, I hope you like it. Ask questions if there is something you don't understand. Please do not use this script for any serious stuff! Pub keys need to be in this format: Code: 02F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9 Code: 1CUNEBjYrCn2y1SdiUMohaKUi4wpP326Lb Code: import base58 Title: Re: Simple private key to public key converter Post by: ramakrishna0905 on December 15, 2022, 02:00:28 PM Thankyou
I will check and get back to you Title: Re: Simple private key to public key converter Post by: ramakrishna0905 on December 16, 2022, 06:37:17 AM Hi Any one have python code for Public key to address converter Public key =Input.txt file Address = output.txt file Input file to output file I spent ten minutes writing this program, I hope you like it. Ask questions if there is something you don't understand. Please do not use this script for any serious stuff! Pub keys need to be in this format: Code: 02F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9 Code: 1CUNEBjYrCn2y1SdiUMohaKUi4wpP326Lb Code: import base58 Thankyou very much It's working perfectly ... Title: Re: Simple private key to public key converter Post by: witcher_sense on December 16, 2022, 07:39:11 AM Thankyou very much I am glad to hear that, here is optimized version of the script, it should run a little bit faster: https://github.com/witcher-sense/learning_python/blob/main/public_to_address.pyIt's working perfectly ... Title: Re: Simple private key to public key converter Post by: n0nce on December 17, 2022, 12:22:08 AM Hi I'm just commenting to say that I find such questions kind of disrespectful. You're just asking people to write code for you for free; you didn't put in any effort trying to do it yourself.Any one have python code for Public key to address converter Public key =Input.txt file Address = output.txt file Input file to output file I can say this confidently, because even an inexperienced programmer can figure out how to read and write to files in Python within 10 minutes, try it out, then take some more minutes to incorporate it into one of the scripts that people have already written in this thread for free. Also @release: after getting provided a script doing exactly what you wanted, you still weren't happy or thankful for it and asked to get it in a different programming language. I recommend to follow the How to ask a good question (https://stackoverflow.com/help/how-to-ask) standards from StackOverflow. You're honestly lucky that people have written so much code with comments and everything else in this thread, after you guys literally showed 0 effort yourself, attempting to build whatever you need (or even just parts of it!). Title: Re: Simple private key to public key converter Post by: bkelly13 on December 21, 2022, 02:49:52 AM Keep in mind that most people don't write their own because there are already libraries in most languages that have been tested. Sure, but I have to say that I found it quite fun to write my own C program that would take a file of private keys and generate the associated public keys and Legacy bitcoin addresses. I would really like to see that. If too much to post here I will PM an email address. BTW: As I was going through this thread a few minutes ago there was a post where someone provided a list of about eight links to various descriptions of the process of private to public key. I have some hand tremors and while looking through the list I clicked something and went to a totally different page. Now when I scroll through the posts of this thread I cannot find that post again. Is there something I might have done that will hide a post? Something that will unhide the post? |