Bitcoin Forum
November 05, 2024, 08:09:20 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Python script to generate a private key securely using almost anything  (Read 2957 times)
dunand (OP)
Hero Member
*****
Offline Offline

Activity: 637
Merit: 502



View Profile
February 09, 2014, 11:21:26 PM
Last edit: February 18, 2014, 04:09:05 AM by dunand
 #1

UPDATED : you can now choose the base you want. You are not limited to bingo balls.

This simple utility help you generate a super secure Bitcoin Private key using bingo balls numbered 1 to 64. Before beginning you must discard bingo balls higher than 64. You only keep balls from 1 to 64. Remember to always put back the last picked ball in the hat between each pick. You need to pick 43 balls to generate 256 bits of entropy. The script will output the Private key in the 44 chars base64 format and the 64 chars Hexadecimal format.

https://github.com/dunand/bingowallet

After generating your Private key, you can use bitaddress.org offline to have your public address.

dunand (OP)
Hero Member
*****
Offline Offline

Activity: 637
Merit: 502



View Profile
February 18, 2014, 04:02:58 AM
 #2

I updated the script. You can now generate your Bitcoin private key using anything you have under you hand to generate randomness. You can use a dice (the number of side you want), a coin, a bag of bingo balls. You can choose anything because at the start of the program you choose the Base you want.
For example:
If you use a 6 sided dice, choose 6.
If you use a 12 sided dice, choose 12.
If you want to use a coin, choose 2.
If you want to pick bingo balls in a bag you choose 75...
porqupine
Full Member
***
Offline Offline

Activity: 214
Merit: 101


View Profile
February 19, 2014, 09:36:13 AM
 #3

Why would this be any more secure?
dunand (OP)
Hero Member
*****
Offline Offline

Activity: 637
Merit: 502



View Profile
February 19, 2014, 02:40:06 PM
Last edit: February 19, 2014, 06:08:46 PM by dunand
 #4

Why would this be any more secure?

My script provide a way to generate 256 random bits. If you trust your computer is virus free you can use bitaddress.org or simply use this command:
od -An -N32 -x /dev/random

This is tin foil hat territory

deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1036



View Profile WWW
February 20, 2014, 09:20:20 AM
 #5

I'll give you some Python code critiques first:

-import time is not used
-You have mixed tab and space indents. You should pick one, four spaces is preferred.
-YouHaveCamelCase defs and variables. Both should be lower case.
-Lines too long, 80 is PEP8, 120 is tolerable.
-Inconsistent white space, compare line 45 (OK) to 85 (none)


Then some Pythonic tips:
-Your programmatically seem to be fishing for how many balls/rolls should be entered, the exact number required to exceed N (Secp256k1 max) is:
rolls = int(math.ceil(math.log(N, base)))

-I was going to say to use base64 = 'ABCD...'; list(base64) to make the same list, but it looks like you don't even need to make it a list, a string will do just fine for your existing indexing. It might be easier for you to just use base64 builtin functions though - http://docs.python.org/2/library/base64.html


And hey, I made one too...
**Dice to Bitcoin private key generator**
>How many sides on your dice?:75
Need 42 rolls of 75-sided dice. (261.610385001 bits)

Number of dice rolls so far: 0, need 42 more.
Input some dice rolling results,separated by spaces:)
>g
Generating random *insecure* dice rolls for remainder

dice used:
[7, 36, 73, 35, 68, 45, 1, 32, 72, 61, 71, 38, 14, 63, 7]
[21, 42, 47, 4, 72, 16, 25, 38, 73, 16, 9, 9, 46, 5, 61]
[14, 13, 72, 19, 38, 31, 48, 20, 32, 53]

====== Generated Address Information ============
Bitcoin Address:
  1JumBSm2g8RTJCqB5uRHAJtb4H6EoA4wju
Private Key (Wallet Import Format):
 5HxBYZeFgp2mZZ1UboHqfuz3er9NjvYSpYUm5FEZh9EwJmgtVko
Private Key (Hexadecimal 64 char) :
 11edbc7fd8e518efa64622839ecb167b7d530f9f1fab9e94a2d1c234de8ac842
Public Key (Full 130 character):
 042fd723ba3185607230be41ddcd1c5fbf1dbca2b2fad4edd5e677174c4e7f99135f3b3298ef0c4
45c64091770600adb9b3da2f0d905cb74182e79623a6c2f3dc8
---------
Bitcoin Address (Compressed):
 17Gh5qrLfhhVctNSUJCqhHb5YDZLGLJHC7
Private Key (Wallet Import Format Compressed):
 KwpZYK5RpiaoggH6pbKKpkrni3uxxTKnxqwXXjpsJBNWgxYLwjtE
Public Key (Compressed):
 022fd723ba3185607230be41ddcd1c5fbf1dbca2b2fad4edd5e677174c4e7f9913
===================================================
(Press "Enter" for more dice keys, "C" and "Enter" to close.)
phatsphere
Hero Member
*****
Offline Offline

Activity: 763
Merit: 500


View Profile
February 20, 2014, 10:11:27 AM
 #6

I'll give you some Python code critiques first:
...

well, yes, just start by running autopep8 on it
https://pypi.python.org/pypi/autopep8/
and then fix the naming.
dunand (OP)
Hero Member
*****
Offline Offline

Activity: 637
Merit: 502



View Profile
February 21, 2014, 03:50:49 AM
 #7

Thanks for your comments deepceleron and phatsphere. One goal of this script was to learn python.

  • I formatted the program with autopep8
  • Removed unused import
  • renamed variables to lowercase
  • used rolls = int(math.ceil(math.log(N, base))) to know the number of roll required
  • used a simple string for the list of base64 chars

Your script is a beauty deepceleron. I will read it in details to learn more. https://bitcointalk.org/index.php?topic=297077.msg3661891#msg3661891
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!