Generating user Random Number

Hi there, I have two questions regarding Pyth Entropy

  1. I read the Entropy docs to generate a random number. I don’t quite get what’s the difference between generating a random number doing something like “web3.utils.randomHex(32)” or “crypto.randomBytes(32)” and doing the whole entropy protocol process. If I want to create a dApp and I use the first option instead of the Entropy RNG protocol what difference does it make? The number will be completely random in both cases.

  2. The coin flip example in the pyth data github repo (https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol) says:

users of this protocol can stall the protocol by choosing not to reveal their generated random number.
    // Developers using Pyth Entropy should ensure that users are always incentivized (or at least, not disincentivized)
    // to finish both stages of the protocol.

Does that example protect from it? And if so, how does it protect from it?

Hi there, thank you for the questions on Pyth Entropy.

To answer your questions:

  1. You can generate the random number any way you want, so that other method should work just fine.

  2. It does protect against it. The “protection” is just to make sure that if the user doesn’t submit the reveal transaction, nothing bad happens to the protocol. E.g., you wouldn’t want to charge the user some money in the reveal step of the protocol.

1 Like