RANDAO – A decentralized random number generator protocol

Random number generator (RNG) is crucial in computer science and software development, as it underpins various applications like emulators and games.

Problem of Pseudo RNG Algorithms

Most programming languages provide libraries for RNGs, but the algorithms they use are mostly pseudo-random and deterministic. This means they rely on an initial value, known as a random seed, to generate subsequent values. If someone knows the seed, they can easily compute exact all the following values.

Problem of the lottery winners

People don’t trust lottery companies. It is suspected that the winners are not actually lucky enough to buy the winning numbers but are actually deliberately chosen by intervening in the random process, for example by attaching magnets inside those resulting balls or change the size or weight of them. In fact, this also happens very often in the online entertainment business. Players do not trust the publisher, there are always some people who think that the reward results are changed in favor of the publisher. Meanwhile, the publisher also suspects that the jackpot winners are most likely cheaters.

💥Is there a way to generate a random but always verifiable result?

Problem of playing Paper-Rock-Scissors via chatting

It’s easy to see that it’s almost impossible for two people chatting online to play a game of rock, paper, scissors because the guy behind always chooses to counter the guy in front. To solve this problem, there are 2 options:

     

      • Ask a third person to be the referee, then both players send their results to the referee instead of sending them directly to each other. However, relying on a third person to act as a refree will lack fairness because sometimes there is collusion between the referee and a certain party.

      • Each person generates a result and its corresponding hash value, then shares the hash with the other person. These hash values serve as proof of the results’ integrity. Once both parties have received the other’s hash, they exchange the original results. By comparing the received results with the previously exchanged hashes, they can determine the winner or loser. This eliminates the need for a third party, ensuring the randomness and fairness of the results.

    The commit-reveal scheme

    The second solution above, is an example of the commit-reveal scheme. The commit-reveal scheme is a cryptographic protocol designed to ensure fairness and prevent cheating in situations where participants need to submit secret values without revealing them prematurely.

       

        1. Commit Phase:

             

              • Participants generate their secret values (e.g., bids, votes, or random numbers).

              • They create cryptographic commitments of these values, typically using hash functions. These commitments hide the actual values but bind the participants to their choices.

              • The commitments are then submitted and recorded on a trusted platform.

          1. Reveal Phase:

               

                • After a predetermined time or condition, participants reveal their original secret values.

                • These revealed values are compared against the previously submitted commitments.

                • If the revealed values match the commitments, they are considered valid. If not, the participant is disqualified or penalized.

          RANDAO

          The RANDAO process is a decentralized random number generation (RNG) protocol that leverages blockchain technology to produce verifiable and unpredictable random numbers. Here’s a breakdown of the RANDAO process:

          Participation and Seed Submission – Commit Phase:

             

              • Participants who wish to contribute to the random number generation process submit a secret random value, known as a “seed.”

              • These seeds are typically hashed using a cryptographic function (like SHA-256) before being submitted to the system.

              • The hashed seeds are then recorded on the blockchain, ensuring transparency and preventing tampering.

              • Participants may required to commit a certain amount of cryptocurrency as a stake. This stake serves as an incentive for honest participation and disincentivizes malicious behavior.

            Reveal Phase:

               

                • After a predetermined time or block height, participants reveal their original unhashed seeds.

                • The system verifies that the revealed seeds match the previously submitted hashed seeds.

                • Participants who fail to reveal their seeds or submit incorrect values may be penalized (e.g., by losing their stake).

              Aggregation and Calculation:

                 

                  • The revealed seeds from all participants are combined using a predefined aggregation function (e.g., XOR, hashing, or averaging).

                  • The resulting value is considered the final random number.

                  • This aggregation process ensures that the final random number is influenced by the contributions of multiple participants, making it difficult to predict or manipulate.

                Example:

                   

                    • Three users A, B, C join a RANDAO process

                    • User A generates seed value 4, calculates the according hash SHA256(4) =4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a, and commits to the blockchain

                    • User B generates seed value 19, and calculate the according hash SHA256(19) =9400f1b21cb527d7fa3d3eabba93557a18ebe7a2ca4e471cfe5e4c5b4ca7f767, and commits to the blockchain

                    • User C generates seed value 5, and calculate the according hash SHA256(5) =ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39d, and commits to the blockchain

                    • Then, they reveal their according original values: 4, 19, 5.

                    • The random seed can be created by sum all of the original values => seed = 4+19+5 = 28.

                  💡 You can play with Hash Function here https://skyglab.tech/hash

                  Subscribe to SkyGLab

                  Scroll to Top