Title: simple script to generate address from private key Post by: JeromeS on May 29, 2012, 07:23:42 PM OK, so I wanted to have a small script that I can use to generate new (offline) bitcoin addresses and be sure that the information was not stored anywhere or sent to anyone, but I couldn't find anything that does that that's also simple enough that I can read the source code and verify it myself.
anyway I ended up writing this python 2.5 script (and then decided to upload it here, in case it's useful to anyone else) Code: import ecdsa Code: print addy(0x18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725) The code uses the ecdsa library which can be found here (https://github.com/warner/python-ecdsa). The address function takes a private key and returns the corresponding bitcoin address. The last two lines have some practical uses of the address function. Since the sha256 hash function returns a 256 bit long value, it can be used to generate a private key. This is useful if you want to have a bitcoin address and private key that you can remember without having to write it down anywhere, or if you want to use a file that you have on your computer as the key. When you want to spend the coins that you have in that address, all you have to do is use the same function to generate the private key and address. WARNING #1: using a file that you have on your computer or a short sentence to generate a private key / address pair makes it a lot easier for an attacker to guess your private key. Instead of having to try 2^256 possibilities, they only have to try the files on your computer one by one, or your favorite book/game/your birthday... WARNING #2: I just made this script today and I'm fairly new to bitcoin. Use at your own risk ! woooo five posts i'm outta here Title: Re: simple script to generate address from private key Post by: Panama Jack on May 30, 2012, 12:42:40 AM Cool idea. :)
Title: Re: simple script to generate address from private key Post by: Stephen Gornick on May 30, 2012, 12:47:46 AM WARNING #2: I just made this script today and I'm fairly new to bitcoin. Use at your own risk ! Just wanted to make sure that part stands out..., since money is involved. Title: Re: simple script to generate address from private key Post by: crazy_rabbit on September 07, 2012, 02:25:46 PM Did anyone confirm whether or not this works? It's a very nice idea.
Is there a code-wiki for bitcoin where people can paste their code snippets? -crazy_rabbit Title: Re: simple script to generate address from private key Post by: JeromeS on September 18, 2012, 07:24:05 AM np :)
Code: import hashlib, binascii I used this (https://en.bitcoin.it/wiki/Wallet_import_format) as a reference for the algorithms. This code is also in Python 2.5. Again, you're welcome to use this code anyway you want, but use at your own risk ! Title: Re: simple script to generate address from private key Post by: flatfly on September 19, 2012, 10:04:44 PM np :) Code: import hashlib, binascii I used this (https://en.bitcoin.it/wiki/Wallet_import_format) as a reference for the algorithms. This code is also in Python 2.5. Again, you're welcome to use this code anyway you want, but use at your own risk ! Very nice, again! Title: Re: simple script to generate address from private key Post by: laSeek on September 20, 2012, 07:34:45 AM Paste it up as a public gist on github & share the link - it should then be visible to devs generally looking via google/github & via the forum.
Nice work! Title: Re: simple script to generate address from private key Post by: moneygames on November 22, 2013, 12:42:09 AM This is very helpful, thanks! I am in the process of using this to recover some coins.
Title: Re: simple script to generate address from private key Post by: JompinDox on December 08, 2013, 03:01:09 PM Although this is an old thread, I felt it was appropriate to give a warning about the above script, as it has a bug that produces wrong results for some keys.
I will post more details and a fix when I have some free time. Meanwhile, you guys can try to find it as an exercise... Some technical knowledge of bitcoin is required. Title: Re: simple script to generate address from private key Post by: RedGolpe on March 06, 2014, 09:50:26 PM Extremely helpful.
To follow JompinDox's suggestion, just add Code: m=0 before Code: address='' Title: Re: simple script to generate address from private key Post by: Stemby on June 27, 2014, 04:35:29 PM It seems to be a little bit out of date, because it uses an old version of python-ecdsa (before secp521r1 implementation). I will try to get an updated and simplified version.
Thank you! Title: Re: simple script to generate address from private key Post by: tpksarathy on July 07, 2015, 08:28:14 AM How to run this script in python?? is there any need of additional script ?? HELP me...
|