Author

Topic: Manually generate keys like paper wallet generators do (Read 1436 times)

legendary
Activity: 3472
Merit: 4794
vanitygen will make an address and private key that is only printed to the console.

I am just a little bit paranoid  Wink Afraid of Backdoors and stuff.

This is why I prefer the original client. Was hoping there is a way to generate temporary (private) keys.

Thanks for all your replies guys!

A private key is just a 256 bit number generated randomly and converted to Wallet Import Format.

Here's a suggestion:

Flip a well balanced coin 256 times.  Write down a 1 every time it lands on heads.  Write down a 0 every time it lands on tails.

When you are done you will have a private key in binary.

Convert from binary (base 2) to hex (base 16).

Follow these instructions here to convert to Wallet Import Format...

https://en.bitcoin.it/wiki/Wallet_import_format

  • Add a 0x80 byte in front of it, this is the extended key
  • Perform SHA-256 hash on the extended key
  • Perform SHA-256 hash on result of SHA-256 hash
  • Take the first 4 bytes of the second SHA-256 hash, this is the checksum
  • Add the 4 checksum bytes from the previous setp at the end of the extended key from the first step
  • Convert the result from a byte string into a base58 string using Base58Check encoding. This is the Wallet Import Format
sr. member
Activity: 255
Merit: 250
vanitygen will make an address and private key that is only printed to the console.

I am just a little bit paranoid  Wink Afraid of Backdoors and stuff.

This is why I prefer the original client. Was hoping there is a way to generate temporary (private) keys.

Thanks for all your replies guys!
member
Activity: 85
Merit: 10
I wrote this to create a deterministic wallet based on any string:

Code:
#!/usr/bin/perl
use strict;
use Digest::SHA qw( sha256 );

my $phrase = $ARGV[0];
my $iter   = $ARGV[1] || 10;

my $hash = '';
foreach ( 1 .. $iter ) {
  $hash = sha256( $hash.$phrase );
  my( $key, $address ) = string2keypair( $hash );
  print "$key\t$address\n";
}

sub string2keypair {
  my $key = chr(0x80).shift;
  my $hash = substr( sha256( sha256( $key ) ), 0, 4 );
  $key = unpack( 'H*', $key.$hash );
  $key = `./base58encode.sh $key`;
  `./keyconv $key` =~ m|Address: (1.*)|;
  my $address = $1;
  return ( $key, $address );
}

__END__
./base58encode.sh:
#!/bin/bash
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z})
bc <<<"ibase=16; n=${1^^}; while(n>0) { n%3A ; n/=3A }" |
tac |
while read n
do echo -n ${base58[n]}
done

It uses "keyconv" from vanitygen.
pc
sr. member
Activity: 253
Merit: 250
I threw together a shell script, based on other posts on this forum, which is what I use. It just uses OpenSSL and some simple shell commands to convert to an address.
hero member
Activity: 737
Merit: 500
Can I use the Bitcoin/Litecoin client to temporarily create a private key that's not put in the wallet.dat? -> because I only need it for my paper wallet.

No, but you can use the bitcoin client on a disconnected machine to generate a new address, dump the private key, and then delete the wallet.dat file when you are done.
legendary
Activity: 1512
Merit: 1036
vanitygen will make an address and private key that is only printed to the console.
legendary
Activity: 1176
Merit: 1260
May Bitcoin be touched by his Noodly Appendage
sr. member
Activity: 255
Merit: 250
Can I use the Bitcoin/Litecoin client to temporarily create a private key that's not put in the wallet.dat? -> because I only need it for my paper wallet.
legendary
Activity: 1176
Merit: 1260
May Bitcoin be touched by his Noodly Appendage
I don't know how Litecoin handles addresses but I think it's the same way, so yeah I think so
sr. member
Activity: 255
Merit: 250
If hexadecimal private key is ok for you: tr -dc a-f0-9 < /dev/urandom | head -c 64
Otherwise: tr -dc a-f0-9 < /dev/urandom | head -c 64 | xargs ./pywallet.py --info --importhex --importprivkey

Thanks!

Is there an equivalent for Litecoin?
legendary
Activity: 1176
Merit: 1260
May Bitcoin be touched by his Noodly Appendage
If hexadecimal private key is ok for you: tr -dc a-f0-9 < /dev/urandom | head -c 64
Otherwise: tr -dc a-f0-9 < /dev/urandom | head -c 64 | xargs ./pywallet.py --info --importhex --importprivkey
sr. member
Activity: 255
Merit: 250
I don't trust (online) paper wallet generators. That's why I like to generate keys only using the command line.

I know how to import a private key (with the "importprivatekey" command).

How do I create a private key?

Can I create a temporary private key, that's not stored in my wallet - but only visible on the command line?
Jump to: