## 隨機數生成的方法
* Pseudorandom Number Generator
使用輸入(種子)生成一系列多個隨機數,其所使用的種子需要足夠不可預測。
* 常見方法
1. naive pseudorandom number generation (NPRNG) ):指的是一種基本且簡單的偽隨機數生成方法。「naive」(天真、單純)暗示著這種方法可能不夠安全或隨機,但實際上它是指沒有採用複雜的算法或技術的基本偽隨機數生成。
* 使用區塊鏈上資訊產生隨機數:block hash, the block gas limit and the block timestamp.
* 使用此方式,假定沒人可以控制鏈上相關變數
2. verifiable random function (VRF): 可驗證隨機函數是一種密碼學原語,用於生成一個隨機數並允許第三方驗證該數的有效性,而無需直接公開生成的隨機數。VRF是一種具有驗證性質的隨機數生成算法。
* VRF 結合公私鑰隨機性
* 如果私鑰足夠隨機,生成的隨機數也將是隨機的。
* A VRF takes a public random seed alpha and a secret key SK as input and outputs a hash beta and a proof pi.


3. 協同偽隨機數生成器(Collaborative PRNG)透過結合來自多個參與者的眾多隨機數生成一個隨機數。
* Randao
* The general algorithm of Randao is a commit and reveal scheme divided into three phases as follows
1. The first phase has a fixed, specified duration. During this period participants can issue a transaction with a fixed stake to the Randao contract. They hash a secret s and attach a commitment H(s) to the message.
2. all participants must send the corresponding secret s to the contract again during a limited time. Randao will check whether s is valid. The valid s will be saved as a seed.
3. after collecting all the seeds, the final
random number is calculated using an XOR operation within all the secrets together. The profit which comes from the fee paid by others who use the random number is divided equally and sent to the participants as a bonus.
## 如何比較方法的好壞?
使用六項標準
1. Availability
2. Unpredicability
3. Unbiasability
4. Verifiability
5. Scalability
6. Execution time and cost