If you want to have a secure bitcoin wallet you should have a good private key. Private keys are used to move bitcoins in the bitcoin network. If you lose your private key, you can no longer move your bitcoins on the bitcoin block chain. Essentially a bitcoin wallet is a set of keys: the private key, public key and bitcoin address.
We will use quantum random number generator (QRNG) to participate in secure key generation. A list of quantum random number generators can be found here. A quantum number generator could be a device you own, or be a server in a remote location. Using a server in a remote location poses a few risks that I need not mention, so use at your own risk. To counter this, we use multiple servers and some other techniques. In this toy project we want to have good random number generators for the generation of private keys. A list of random number generators we use in this project:
- ANU Quantum Random Numbers Server, Australia. (quantum random number generator)
- Fourmilab Hot Birds Random Number Server, Switzerland (decay random number generator)
- Random.org Random Number Server, Ireland (atmospheric noise random number generator)
- Traditional Pseudo-random Number Generator (your machine)
In addition to using several random number sources, we hash the resulting random numbers to generate a unique digest. Even if all three sources would not be random due to failure of https, there still is the PRNG included which is used. The program will output a private key, based on a combination of quantum random numbers, atmospheric random numbers, decay random numbers and traditional random numbers along with public key and bitcoin address. The source of the script is, use on your own risk:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# BSD license
from pybitcointools import *
import urllib
from random import *
class Random:
def PRNG(self):
# pseudo random number generator
data = ""
for i in range(0,512):
data = data + "%06x" % randint(0,0xFFFFFF)
return data
def ARNG(self):
# atmospheric random number generator
response = urllib.urlopen('https://www.random.org/integers/?num=1024&min=1&max=16&col=1&base=16&format=plain&rnd=new')
data = response.read()
data = data.replace("\n","")
return data
def TRNG(self):
# quick way to grab hexadecimal random numbers from HotBits
response = urllib.urlopen('https://www.fourmilab.ch/cgi-bin/Hotbits?nbytes=1024&fmt=hex&npass=1&lpass=8&pwtype=3')
data = response.read()
data = data[data.index("
")+len(" ")+1:]
data = data[:data.index("")]
return data
def QRNG(self):
# quantum random number generator.
response = urllib.urlopen('https://qrng.anu.edu.au/RawHex.php')
data = response.read()
data = data[data.index("
")+len("
|
")+1:]
| ")]
data = data[:data.index("
return data
q = Random()
password = sha256(sha256(q.QRNG()+q.QRNG()) + q.ARNG() + q.QRNG() + q.PRNG())
print password
priv = sha256(password)
pub = privtopub(priv)
address = pubtoaddr(pub)
print("-----------------------------")
print("Address : " + address)
print("Private key: " + priv)
print("Public key: " + pub )
print("-----------------------------")
|
Run with (Python 2.7):
1
|
python program.py
|
This will output your a private key based on a combination of quantum, atmospheric and pseudo number generators. You can use the function as you please, in any order or combination. The public key and address will also be given by the program. If you use a desktop wallet, you can import the private key into that wallet. Keep a copy of your private key at all times (memorize it or write it down).