INK Protocol
Search…
Randomization
A quick explanation of our randomization mechanism.

Overview

To randomize winners for each round, INK Protocol uses a secret word selected from the previous round and a number on-chain entropy source that we cannot control to generate a random number. The summation of generated random numbers and prize indexes is hashed to get a unique random number for every prize.
Note: We're implementing a VRF (Verifiable Random Function) randomizer through an oracle for the next phases!

Secret and secret_hash

After contract creation and at the end of every round, the protocol generates a secret (256 bits number from off-chain) for the next round and submits a secret_hash (a hash of that secret) to store in the INK core contract. The hash function is keccak256. At the end of the round, when the prize drawer submits the transaction to draw winners, it sends the secret along with draw_winner message. If the hash of input secret and secret_hash are not the same, the transaction will revert. This process is to make sure that the protocol does not know the result of the random. The protocol sets the secret long before drawing time so the protocol cannot change the secret to force the result)

Entropy

Entropy is an on-chain number that the protocol cannot control. the entropy is used with the secret to generate a random number by XOR operation. Right now, the entropy is equal to the result of swapping $LUNA to $UST with env.block.height + env.block.time amount.

Random number

The random number is generated from the secret and the entropy. The secret number (256 bits) will be converted to first half (128 bits) and second half (128 bits). The random number will be the result of the first half exclusive or with the entropy and exclusive or with the second half.
Copy link
Outline
Overview
Secret and secret_hash
Entropy
Random number