Author Topic: How random is random  (Read 2295 times)

0 Members and 1 Guest are viewing this topic.

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
Yeah, I think that my results show that the random seed is pretty random.  To get back to the original question, as far as I have been able to figure out the RNG in play is created by hashing the previous random seed against the secret held by the delegate.

I do have some questions about the process if anyone in the know could answer them.

What value from the previous block is hashed?  Is it the random_seed?  ID?  entire block?

How is the random seed derived?  As far as I can tell from my limited ability to read the source code, it seems as if SHA256 is used, but the random seed is too short to be the hexdigest of a SHA256 hash.  What format is it? 

And probably most importantly does the client check that the delegate is not cheating?  Does it verify that the exposed secret hashes to the previously exposed hash?  Does it check that the random seed is the hash of this exposed secret, and whatever other value it should be?
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline cylonmaker2053

  • Hero Member
  • *****
  • Posts: 1004
  • Saving the world one block at a time
    • View Profile
  • BitShares: cylonmaker2053
I have been using the random seed to generate roulette spins on a project I have been playing with.  In my most recent iteration I am simply taking the random seed from a block, converting it into an integer with base 16, and then dividing that integer by 38, and using the remainder to pick a number between 0 and 37.  In my most recent test, out of a total of 805 spins the results have been.

0   17      19   23      odd    = 406
1   24      20   17      even  = 399
2   20      21   16      
3   18      22   22      
4   19      23   18      
5   26      24   23      
6   26      25   21      
7   23      26   27      
8   21      27   15      
9   24      28   15      
10   24      29   17      
11   17      30   19      
12   24      31   26      
13   27      32   17      
14   24      33   26      
15   26      34   26      
16   18      35   13      
17   23      36   21      
18   19      37   23      

After only 805 results the lowest result is 35 with only 13 spins, and the highest would be 13 and 26 tied at 27.  I am not sure what the expected deviation would be in a truly random process after 805 results.  The odd and the even at 406 and 399 lead me to believe that the results are pretty random. 

If anyone has the maths to evaluate these numbers further that would be interesting.

it depends on the probability distribution your random number generator is drawing from. i'm guessing you're using some sort of uniform distribution draw across some integer range? that even/odd spread doesn't seem too worrisome to me. run it for a million draws and see what happens...i bet it'll be just fine.

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
I have been using the random seed to generate roulette spins on a project I have been playing with.  In my most recent iteration I am simply taking the random seed from a block, converting it into an integer with base 16, and then dividing that integer by 38, and using the remainder to pick a number between 0 and 37.  In my most recent test, out of a total of 805 spins the results have been.

0   17      19   23      odd    = 406
1   24      20   17      even  = 399
2   20      21   16      
3   18      22   22      
4   19      23   18      
5   26      24   23      
6   26      25   21      
7   23      26   27      
8   21      27   15      
9   24      28   15      
10   24      29   17      
11   17      30   19      
12   24      31   26      
13   27      32   17      
14   24      33   26      
15   26      34   26      
16   18      35   13      
17   23      36   21      
18   19      37   23      

After only 805 results the lowest result is 35 with only 13 spins, and the highest would be 13 and 26 tied at 27.  I am not sure what the expected deviation would be in a truly random process after 805 results.  The odd and the even at 406 and 399 lead me to believe that the results are pretty random. 

If anyone has the maths to evaluate these numbers further that would be interesting.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline pgbit

  • Sr. Member
  • ****
  • Posts: 241
    • View Profile
At the core of many systems is a trusted random number generator, but it seems that some software libraries that perform this function are not completely random - for various reasons. It might seem reasonable to mix RND methods. How does the Play random number generator work and how has it been validated to prove randomness?