Bitcoin Forum
July 16, 2018, 10:24:46 PM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Manually generate keys like paper wallet generators do  (Read 1374 times)
Radacoin
Sr. Member
****
Offline Offline

Activity: 255
Merit: 250


View Profile
April 09, 2013, 07:31:01 AM
 #1

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?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1531779886
Hero Member
*
Offline Offline

Posts: 1531779886

View Profile Personal Message (Offline)

Ignore
1531779886
Reply with quote  #2

1531779886
Report to moderator
1531779886
Hero Member
*
Offline Offline

Posts: 1531779886

View Profile Personal Message (Offline)

Ignore
1531779886
Reply with quote  #2

1531779886
Report to moderator
jackjack
Legendary
*
Offline Offline

Activity: 1134
Merit: 1012


May Bitcoin be touched by his Noodly Appendage


View Profile
April 09, 2013, 07:34:48 AM
 #2

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

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
Radacoin
Sr. Member
****
Offline Offline

Activity: 255
Merit: 250


View Profile
April 09, 2013, 07:39:30 AM
 #3

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?
jackjack
Legendary
*
Offline Offline

Activity: 1134
Merit: 1012


May Bitcoin be touched by his Noodly Appendage


View Profile
April 09, 2013, 07:42:23 AM
 #4

I don't know how Litecoin handles addresses but I think it's the same way, so yeah I think so

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
Radacoin
Sr. Member
****
Offline Offline

Activity: 255
Merit: 250


View Profile
April 09, 2013, 10:32:42 AM
 #5

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.
jackjack
Legendary
*
Offline Offline

Activity: 1134
Merit: 1012


May Bitcoin be touched by his Noodly Appendage


View Profile
April 09, 2013, 11:20:44 AM
 #6

No

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1000



View Profile WWW
April 09, 2013, 11:25:02 AM
 #7

vanitygen will make an address and private key that is only printed to the console.
twmz
Hero Member
*****
Offline Offline

Activity: 737
Merit: 500



View Profile
April 09, 2013, 04:11:09 PM
 #8

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.

Was I helpful?  1TwmzX1wBxNF2qtAJRhdKmi2WyLZ5VHRs
WoT, GPG

Bitrated user: ewal.
pc
Sr. Member
****
Offline Offline

Activity: 253
Merit: 250


View Profile
April 09, 2013, 05:12:33 PM
 #9

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.
HighInBC
Member
**
Offline Offline

Activity: 85
Merit: 10


View Profile
April 09, 2013, 05:18:49 PM
 #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.
Radacoin
Sr. Member
****
Offline Offline

Activity: 255
Merit: 250


View Profile
April 10, 2013, 07:25:34 AM
 #11

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!
DannyHamilton
Legendary
*
Offline Offline

Activity: 2198
Merit: 1370



View Profile
April 10, 2013, 01:52:19 PM
 #12

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

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!