Enhancing Randomness with VRF in Kleros' Juror Selection

Kleros is as a pioneering platform for decentralized dispute resolution. Jurors are randomly selected to rule an arbitration, with the chances of being chosen proportional to the amount of tokens staked. At the core of Kleros' juror selection is randomness -- this is to keep the selection process fair and transparent.

At present, the selection of jurors relies on random numbers derived from the blockhashes of Ethereum blocks. Although it's impossible to foresee these values, miners have the option to withhold a block if the resulting random numbers are not to their advantage, at the cost of losing a block reward. To create random numbers that are impervious to manipulation by large miners, the Verifiable Random Function (VRF) service provided by Chainlink can be a solution.

VRF is a cryptographic function that generates pseudorandom numbers based on data input and provides a proof, which anyone can verify. Here's a simple explanation of how Chainlink's VRF contracts work and integrate with Kleros:

  1. Chainlink's Coordinator contract generates a preSeed using a fixed algorithm based on the parameters of Kleros' random number request. It also records the blockNumber of the current transaction and then sends the preSeed as the content of an event log to Ethereum.

  2. After ChainLink Oracle detects the event log, it retrieves the preSeed from the log. It can also obtain the blockHash of the block containing the previous step's transaction (It's important to note that blockHash can only be obtained after the block is mined. In the contract, it's not possible to get the current block's blockHash, only blockNumber. This is why the Coordinator contract in the previous step can only record blockNumber, not blockHash).

  3. After a specified number of block confirmations, ChainLink Oracle uses its private key to generate a proof with parameters including the preSeed and blockHash, and then submits this proof back to the Coordinator contract.

  4. The Coordinator contract verifies the proof. Since blockNumber was recorded in the first step, the contract can now use the function blockHash(blockNumber) to get the historical block's blockHash. The blockHash, along with the preSeed generated by itself, is used to verify the proof submitted by ChainLink Oracle.

  5. If the verification is successful, a tamper-proof parameter from the proof (proof.gamma) is used as the seed for random number generation. The VRF contract will then serve the random number to Kleros contract in a fallback function.

The reason that VRF can generate unpredictable random number primarily lies in the use of two factors:

  • blockHash, which is unknown before a block is confirmed by miners and becomes determinable only after it has been packed.

  • The proof submitted by ChainLink Oracle, whose corresponding private key is unknown.

If the generation of random numbers relies solely on blockHash as the seed source, miners could potentially manipulate it; similarly, if it relies only on the proof from ChainLink Oracle, the oracle nodes might act maliciously. Therefore, ChainLink VRF ingeniously combines these two sources, ensuring the unpredictability of the random number seed.

For Kleros, looking to optimize its random number generation in juror selection, VRF presents a viable solution.