This module is in Beta, use at your own risk
This specification describes the usage and scope of random numbers on IRISHub. This feature is currently in beta and please assess the risk yourself before using.
Applicable to the application layer to obtain random numbers generated based on blockchain, such as gaming, games, etc.
Not Applicable to private keys, blockchain consensus algorithms, etc.
A pseudorandom number generator (PRNG), also known as a deterministic random bit generator (DRBG), is an algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers. -- Wikipedia
IRISHub uses this algorithm to generate random numbers during the Beta phase.
On the one hand, we use the multiple indicators generated by the blockchain as "factors" to calculate the random number, making this random number transparent and convenient for verification;
The random number "factor" specifically includes the following indicators:
- Last Block Hash: The generation of Block Hash depends on various factors of the block, such as block height, number of transactions, timestamp, etc., so the block Hash itself has certain unpredictability.
- Current Block Timestamp: The block timestamp uses the BFT time, that is, the weighted calculated distributed timestamp (millisecond level), based on the validator's weight, using the time of each Precommit in the previous block, also certain unpredictability [BFT Time]
- Consumer Address: mainly to achieve different random numbers for different people at the same block height
Since the calculation of block Hash and BFT time is based on the information of the previous block, in order to avoid pre-calculating the result before requesting the random number, on the other hand, we strengthen the unpredictability of the random number through the "future block".
However, unpredictable does not mean that it is unmanipulable. For example, a new block proposer can selectively package transactions and accept Precommits to affect block Hash and BFT time
seed = sha256(timestamp + int(sha256(blockhash)) / timestamp + int(sha256(consumer)) / timestamp) rand = seed mod 10^20 / 10^20
A hardware random number generator (HRNG) or true random number generator (TRNG) is a device that generates random numbers from a physical process, rather than by means of an algorithm. -- Wikipedia
In view of the security risks of PRNG, we plan to introduce TRNG through the oracle in the next version to improve the security of random numbers.