miércoles, 29 de agosto de 2012

Secure random number

Some theory

Well, the next step is to verify the keys of the One-Time-Pad randomly generated by Python's random method

There are many types of methods for checking if the numbers are random.


  1. Uniformly distributed
  2. No numbers repeated on a specified length
  3. Numbers must be independent of each other
  4. The series should be reproducible
  5. The numbers must be generated quickly

Part of the previous program had to generate the random numbers

In this code I generate random numbers between 0 and 1 to create different keys, now is necesary to verify that this numbers are really random

Test used "Run Test"

In this Test is verified if the hypothesis of a number is really random between two elements, in this case 0 and 1.


amount of the first element in this case "0"
amount of the second element in this case "1"
amount of elements
amount of blocks

Regarding the blocks, a block is when the same element is repeated until meet the other element and it starts over with a new block:

For example:
In this case, we have 5 Blocks

Having this elements clearly defined, we can begin seeing how the test works

First, we get the arithmetic mean:

After we got the arithmetic mean, the variance:

Finally we got the probability of Z

Screen Printing

In this case is randomly, but in mayor of the case arenot randomly
Is randomly = 20%
Not randomly = 80 %
Test was performed 10 times

Sorry, here is more information, the value 1.96 is found in the critical value, it depends of the level of reliability, in this case 95 percent.

Graphics and table:

Here is the table:
1 - a a/2 Za/2
0.90 0.05 1.645
0.95 0.025 1.96
0.99 0.005 2.575

Thanks, have a nice day :D

1 comentario: