Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: samadamsbeer on April 23, 2013, 04:25:11 PM



Title: Generating key pairs in Linux from a passphrase?
Post by: samadamsbeer on April 23, 2013, 04:25:11 PM
In Linux I know "echo -n passphrase | sha256sum" will give me a string which then you convert to base58 to get a private key, and then you need to do something to that to get the corresponding public key.

What are the Linux commands to do this beyond the first one "echo -n passphrase | sha256sum" to get the private/public key pairs? Or how would I do that? I am trying to verify pairs given to me by bitaddress.org or brainwallet.org...


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: jackjack on April 23, 2013, 04:48:38 PM
Pretty much anything that transforms your passphrase into 256 bits
sha256, first half of sha512, last half of sha512, sha1+sha1, ridemd256, etc


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: samadamsbeer on April 23, 2013, 05:13:14 PM
Pretty much anything that transforms your passphrase into 256 bits
sha256, first half of sha512, last half of sha512, sha1+sha1, ridemd256, etc

Thanks - but can you tell me what the actual commands/steps would be though for Linux to get from seed passphrase to the private/public key?

Sorry I almost posted this to newbie section but thought the folks here would know how to answer.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: Zeilap on April 23, 2013, 06:02:01 PM
Step 1: delete your bash history
Step 2: don't try to roll your own security tools


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: proff on April 23, 2013, 06:18:23 PM
Thanks - but can you tell me what the actual commands/steps would be though for Linux to get from seed passphrase to the private/public key?

Sorry I almost posted this to newbie section but thought the folks here would know how to answer.
NB Zeilap's comment. That said, look at https://bitcointalk.org/index.php?topic=133220.0 to see how to string the commands together.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: jackjack on April 23, 2013, 07:32:59 PM
The wiki explains everything
Also, writing a space before your command doesn't keep it in bash history


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: dserrano5 on April 23, 2013, 08:43:51 PM
Also, writing a space before your command doesn't keep it in bash history

You can't rely on yourself to remember that. It's better to use 'unset HISTFILE'. And close the terminal after finishing so its memory (particularly the scrollback buffer) is released to the OS.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: Shevek on April 23, 2013, 11:03:31 PM

Thanks - but can you tell me what the actual commands/steps would be though for Linux to get from seed passphrase to the private/public key?


You can also download the html/js code from https://www.bitaddress.org/ Open your local instance with your browser; go to the tab "Brain wallet" and put there your password. If paranoid, unplug the net cord before proceeding.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: samadamsbeer on April 24, 2013, 12:39:06 AM
Proff, at the link you mentioned installing Armory would seem to do the trick? But what command do I use?

Quote
echo -n C4BBCB1FBEC99D65BF59D85C8CB62EE2DB963F0FE106F483D9AFA73BD4E39A8A | python ArmoryQt.py -genPublicKey
did not seem to work.

Would like to use something other than bitaddress or brainwallet.org since I am looking to verify the output from those in the first place. Does not have to be command line based but I was looking for something command line because I was looking to do this on a bootable Puppy Linux machine.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: DannyHamilton on April 24, 2013, 02:27:47 AM
I'm not aware of any utilities currently available that will allow you to present a private key and receive a public key in response.

There appear to be libraries for javascript, PHP, and Python to assist with the calculation of the public key.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: jackjack on April 24, 2013, 05:37:39 AM
I'm not aware of any utilities currently available that will allow you to present a private key and receive a public key in response..
Pywallet


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: DannyHamilton on April 24, 2013, 11:17:56 AM
I'm not aware of any utilities currently available that will allow you to present a private key and receive a public key in response..
Pywallet

I didn't see anything in the usage about that.  What are the command line parameters for that behavior?


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: jackjack on April 24, 2013, 11:29:07 AM
pywallet.py -info -importprivkey PRIVKEY ('-importhex' if privkey is hexadecimal)


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: DannyHamilton on April 24, 2013, 11:35:39 AM
pywallet.py -info -importprivkey PRIVKEY ('-importhex' if privkey is hexadecimal)

Ah, I had assumed that importprivkey would attempt to import the private key into a wallet.  I hadn't realized that it would write the public key to STDOUT.  Interesting behavior.  Can I get it to write the Bitcoin Address to STDOUT instead of the public key?


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: jackjack on April 24, 2013, 11:47:37 AM
Yeah that's pretty misleading but I made these changes when I first started to modify pywallet, that was not intended to become a real, public fork
I think it's mentionned in the readme though

When you do this you get: address, privkey, hexadecimal privkey, hash160 and pubkey


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: DannyHamilton on April 24, 2013, 12:02:18 PM
Yeah that's pretty misleading but I made these changes when I first started to modify pywallet, that was not intended to become a real, public fork
I think it's mentionned in the readme though

When you do this you get: address, privkey, hexadecimal privkey, hash160 and pubkey

Great! Thanks.  I've been looking for something like that.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: samadamsbeer on April 25, 2013, 02:07:48 AM
Hmm, tried to install in Ubtuntu. Got:

Quote
~$ aptitude install build-essential python-dev python-twisted python-bsddb3
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

Dumb question, but do I need to be root to install? Just use sudo before "aptitude"? Always makes me nervous to install this stuff when I am not sure what Im doing.


Title: Re: Generating key pairs in Linux from a passphrase?
Post by: jackjack on April 25, 2013, 05:40:10 AM
Yes you always need to be root to install something with aptitude
Yes, just sudo and it's OK
Note that installing with sudo won't make python and other things you install have root rights