Provably Fair

Game of Hope is provably fair

Random Number Generation

The random number generation that determines whether or not a user wins is provably fair. We've integrated with Supra's dVRF, which provides Blockchain-based verifiable random functions (VRFs) that enable the generation of numbers that are as good as random (pseudorandom) and can be (publicly) verified on-chain.

After each bet, you will see a transaction appear below the dice panel, this is the random number generation callback which contains the signature, which can be verified to match the outcome.

Bet Verification

For the verify button, it makes a call to a separate verify contract that we've written. You can find it at address 0xD24858aC5b1f865614bC0105F95909aC7A0910D1. It makes a call to the verify function which looks like this:

    function verifyBet(
        uint256[2] calldata _signature,
        uint8 _rngCount
    ) public pure returns (uint256[] memory) {
        // Generate random number
        uint256[] memory rngList = new uint256[](_rngCount);
        for (uint256 loop = 0; loop < _rngCount; ++loop) {
            rngList[loop] = uint256(
                keccak256(abi.encodePacked(_signature, loop + 1))
            );
        }
        return rngList;
    }

This function, called verifyBet, is used to verify that the random numbers generated for a bet are indeed correct and valid, as provided by Supra's decentralized Verifiable Random Function (dVRF). It does this by using a cryptographic signature provided by Supra and running a hash function on it to generate random numbers.

Here’s how it works step by step:

  1. Takes a Signature: The function accepts a cryptographic signature from Supra’s dVRF along with the number of random numbers needed.

  2. Runs a Hash Function: It uses the signature as input to a hash function, along with a counter, to generate each random number. Hash functions are like a digital fingerprint, which ensures that each output is unique and consistent.

  3. Verifies Supra’s Output: By hashing the signature provided by Supra, it ensures that the random numbers generated are exactly what Supra’s dVRF intended to generate. This signature originates directly from Supra’s contract, not from ours, ensuring that the process is secure and unbiased.

In simple terms, this function double-checks that the random numbers came directly from Supra's system and haven’t been tampered with, maintaining fairness and trust in the game.

Last updated