There is no Math.random() on a blockchain

5 days ago 5



When a developer wants a random number, they simply type in the command “Math.random()”, and a random number will be generated. Though helpful for developers to come up with a random number, on the blockchain, it doesn’t work. Instead of numbers being completely random, computers in the network need to arrive at the same number, not together, but independently. The reason is that using Math.random() would result in many different computers coming up with many different numbers. This would produce different results for each computer and break blockchain agreement. Because of this, blockchain protocols don’t just randomly generate numbers. They manufacture numbers that behave unpredictably. Sealed Envelopes, and Who Opens Last Ethereum runs a commit-reveal scheme. Simply, everyone submits a sealed answer first and opens it later, so nobody can change theirs after seeing anyone else’s. Validators, which are operators who confirm the transactions, each pick a secret number and then publish it scrambled. The scrambling runs one way only, so the sealed version gives nothing away. They then reveal the number in a set order, and each is mixed into a running total. Every validator sees the ...

Read Entire Article