# The population securely generates random numbers
The population has a protocol that allows them to generate a random numbers each period in a way that cannot be manipulated by foreign actors. It relies on a form of majority vote, but, no one can control what they vote for. They can only control that their vote is random, and know that the vote of every other person is random. This is possible by using a commit-reveal scheme, where votes are committed before the votes in the previous period have been revealed. The random number generated by majority vote each period, is used to mutate the votes in the next period. Votes contribute randomness to generators. There are as many generators as there are people, and the probability that some generator gets k hits is e^-1/k!. The generator that gets the most hits , i.e., a majority vote, wins.
The random number generator is a bit similar to proof-of-work. The population "mines" a random number, by submitting random nonces. These nonces contribute entropy to a randomly selected generator. The generator that gets the most hits , wins. The nonces are truly random, because they are mutated after they have been committed, using the random number generated in the previous cycle. It is impossible to predict what nonce will hit a winning generator.
mapping (address => bytes32) commit; // The pre-committed nonce
mapping (address => bool) reveal; // Has the person cast their number?
mapping (address => bytes32) mutation;
mapping (uint => uint) points; // Keeps tracks of score
mapping (uint => bytes32) generator; // XOR of all entropy that hit generator
uint leader; // What generator has the highest score?
It uses a game to sample who gets to submit random numbers. This game is simply, that everyone reveals their random numbers. Each random number hits another person, giving them one point. The person with the highest score, and who got the reached that score first, is selected, and the random numbers that hit them are used. The game is initialized with the random number generated in the previous game. This value is known first after people commit their encrypted random numbers. The probability that a candidate gets k points is 1/k! (multiplied by 1/e). The second highest score, will have k times more candidates than the highest score, and the probability that honest players can generate that score without the colluders is > 1 if percentageHonest>k.
# Randomization
The random number generation in Online Pseudonym Parties relies on that every person submits random entropy, and that every person votes (in a way they cannot predict or control) for the entropy submitted by a random person. This is made possible by that the list of registered people one month (who have pre-committed their entropy, but not yet revealed it) is randomized using the random number generated by the registered people the previous month.
The probability that a candidate gets k points is 1/k! (multiplied by 1/e) i.e., the probability of 2 points is /=2 less than 1 point. The probability of 3 points is /=3 less than 2 points. The probability of 4 points is /=4 less than 3 points. The highest score should on average be the value of k where k!*e is closest to population.
If it is a draw, the person who had the most points first is selected. If the person who won did not reveal a number, they are skipped and the person next in line for the win is selected.
For example, the average highest score with 8*10^9 people, will be 12.7 points (x!*e = 8*10^9, solve for x). This is not possible to get, since points are integers, so, it will be 12 points, with the occasional 13 point score. It can be calculated that on average 6 people will get 12 points, (1/(12!*e))*(8*10^9) = 6. If the colluders control either of the accounts that hold the "winning votes", they will at best be able to cast their vote as fast as they can (to be the first to get to 12 points), but, without knowing if that value is better than any of the others that will be revealed.
An example of how secure the randomization mechanism is: what if the colluding party waits until last to reveal? Then they'd get a lot of numbers to choose from? Well, the probability of a score k being reached decreases as 1/k!. With 8 billion people, 12.7 points is the norm. To reach 12 points, the average population size required is just 12!*e = 1.3 billion people. So as long as 1.3/8 = 16% honestly reveal their numbers, the colluders will at best have on average a single 13 vote to either cast, or not cast. So, they end up choosing just between two randomly selected numbers. And, this assumes a huge colluding party of upwards 50%, who'd have 50% chance of holding the "13" vote.
But what if colluders cast very early votes? Total 12 point votes in a population of 8 billion is on average 8 billion/12!*e = 8 billion/1.3 = 6.15 candidates. The colluders will at best be able to hand pick from a few random number candidates if they submit first at the winning score.
The random number generation in Online Pseudonym Parties relies on that every person submits random entropy, and that every person votes (in a way they cannot predict or control) for the entropy submitted by a random person. This is made possible by that the list of registered people one month (who have pre-committed their entropy, but not yet revealed it) is randomised using the random number generated by the registered people the previous month.
The probability that a candidate gets k points is 1/k! (multiplied by 1/e) i.e., the probability of 2 points is /=2 less than 1 point. The probability of 3 points is /=3 less than 2 points. The probability of 4 points is /=4 less than 3 points. The highest score should on average be the value of k where k!*e is closest to population.
If it is a draw, the person who had the most points first is selected. If the person who won did not reveal a number, it goes to the person with the second highest score.
For example, the highest score with 8*10^9 people, will be 12.7 points. This is not possible to get, so, it will be 12 points, with the occasional 13 point score. It can be calculated that on average 6 people will get 12 points, (1/(12!*e))*(8*10^9) = 6. If the colluders control either of the accounts that hold the "winning votes", they will at best be able to throw their vote as fast as they can (to be the first to get to 12 points), but, without knowing if that value is better than any of the others that will be revealed.