Pages:
Author

Topic: How to create an N bit ECDSA compatible private key from dice rolls in python - page 2. (Read 2281 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
There is a roughly 1 in 2^128 chance (not worth worrying about) of a random 256 bit key not falling in this range.
What would happen to a wallet program if this happened?
The wallet should be checking that the keys generated are in that range. If it is not, then a new key should be generated and the first one discarded.
full member
Activity: 224
Merit: 117
▲ Portable backup power source for mining.
An ECDSA private key is simply a 256 bit integer between 0x1 and 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140.
There is a roughly 1 in 2^128 chance (not worth worrying about) of a random 256 bit key not falling in this range.
What would happen to a wallet program if this happened?
staff
Activity: 3458
Merit: 6793
Just writing some code
An ECDSA private key is simply a 256 bit integer between 0x1 and 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140. So all you need to do is combine those random numbers so that the result is in that range. The result is your private keys. I'm pretty sure that however you combine those numbers will still be safe, so how you want to do it is up to you.
jr. member
Activity: 32
Merit: 1
How can you create an N bit uniformly random ECDSA private key from indepentend dice rolls, that to be inputed in phython console.

Let me explain. I would like to create a private key just from combining dice rolls, with 6 sided dice.

You can create a random private key already in python with:

Code:
import ecdsa

privkey = ecdsa.util.randrange(pow(2, n))

Where the n is the number of bits, so if n=160, that would be a classic 160 bit private key, which would be as strong as an unspent bitcoin address (no need to utilize the full 256 bits).



Of course this relies on the RNG of the computer, which can be weak. So I want to do it manually with dices.

A perfect 6 sided dice, has an entropy of 2.5849625007, so I need to roll 62 times a dice, or less times multiple dices.

Rolling 62 times gives us an entropy of 160.2676750447, which wouldbe equivalent to what the code above would give us, except that this one is manual.



Alright, so we have 62 random numbers ranging from (1-6), the question is, how to combine these 62 random numbers into an ECDSA compatible integer like the one generated above with that script?

I need a python code for that, thank you.

Pages:
Jump to: