4

If I understand it correctly, I could generate a valid Bitcoin address (key pair) following this algorithm.

With an address generated in such a way I would be able to receive Bitcoin without ever having to install a Bitcoin client. Is this correct?

How could I follow this algorithm with common (command-line) tools, i.e. those typically available on (even older) GNU/Linux systems? (they don’t have to be installed by default, but they should be part of the distributor’s package archive)

Would there be any risks/problems using such a key instead of one generated by a Bitcoin client?

2
  • You should keep in mind that computers are not very good in creating randomness. Many applications that require a lot of randomness, get it from user input. Just make sure your private key is random enough :) You could use Vanitygen to create keypairs. Commented May 12, 2013 at 14:39
  • Users be aware that typically you want a wallet program to manage your addresses and make sure you're monitoring the blockchain for any funds sent to your address. Generating them as described in the current answers means that no wallet software is monitoring your address to alert you when you receive your coins.
    – morsecoder
    Commented Dec 14, 2015 at 12:53

3 Answers 3

2

I recommend simply using vanitygen like this:

vanitygen -1 1

This will generate a small number of addresses that you can use, as well as their private keys.

vanitygen is trivial to install on any POSIX system and is proven to work.

Alternatively, you can try bitcoin-bash-tools. Source that from your .bashrc or simply run it, then you can create a new keypair with newBitcoinKey.

3
  • Thanks for this suggestion, the tool sounds good. However, it doesn’t seem to be included in (older) package archives of distributions (yet) (probably because it especially for Bitcoin, so still somewhat new), e.g. it’s not in Debian/Ubuntu/Arch/…. So I’m still looking for a way with tools included in package archives, e.g. from Debian.
    – unor
    Commented May 12, 2013 at 18:51
  • Unfortunately, I don't think you're likely to be able to do it with tools included in the archives. You can generate a secp256k1 key and do the hashing, but the base58 step requires code. See also this. vanitygen only requires pcre and openssl, both of which are likely already to be installed on any system. You'd just need to install build-essential to get the rest of the compiling environment ready.
    – Colin Dean
    Commented May 12, 2013 at 20:03
  • 1
    I looked around for a bit on the Bitcointalk forums a thread in which people are discussing command line generation.
    – Colin Dean
    Commented May 12, 2013 at 20:11
3

Check out this shell script, which generate a public/private bitcoin address pair.

3

The following code snippets are taken from the blog post: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html

It is a great read and you should take a look at it.

import random, keyUtils
#FOR DEMO ONLY.USE A CRYPTOGRAPHICALLY SECURE RANDOM  GENERATOR IN PRODUCTION
private_key = ''.join(['%x' % random.randrange(16) for x in range(0, 64)])
print private_key
print keyUtils.privateKeyToWif(private_key)
print keyUtils.keyToAddr(private_key)

The source code for keyUtils is on the followign github: https://github.com/shirriff/bitcoin-code

That is the example code from the blog post I shared above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.