đĩī¸VRF
True randomness for KLY
Briefly
A verifiable random function (VRF) is a cryptographic primitive that uses a pair of keys and, based on some input data, can generate pseudo-random values ââwhile also creating proof that it was calculated correctly.
This "testable randomness" can be extremely important for special use cases within services or workflows.
Only the owner of the private key can calculate the hash and proof, but anyone with the public key can verify the hash is correct and the proof is valid.
Some code
You can see a small example right in the core repository. And although VRF is not yet included in our developments, it is nevertheless available for use and application in your developments.
You can see this example here
Let's clarify it with code example
Let's see what's going on here
Initially you generate a key pair
VRF can be built on any curves, but it uses secp256k1 curve and ECDSA to generate key pairs. In general, we took the same keys that we use to generate key pairs for ring signatures (that is, there will again be ETH compatibility).
Step 2 - Computation
Next comes the hash calculation and proof. Here the data is represented as bytes. The hash becomes public and is used as the very "random value", and the proof - as proof of the reliability of the calculation.
Step 3 - Verification
Anyone with the public key, the original input, and the proof can verify the validity of the computation by taking the hash and comparing it to the original.
So what's the catch here?
For those who have not yet understood, the point here is that even the owner of the private key cannot specifically choose the right hash value. No one can manipulate or deliberately select a random value. It is also of interest that before the publication of the hash and proof, no one could guess this random value that was generated by some address.
Usecase
Let's imagine that a group of people (2 people) are playing a game in which everyone receives the input string THIS IS A GAME and generates 32 byte hashes using VRF. This continues 3 times and each time the input will be the hash obtained in the previous step. After that, they sum up the hash values. Whoever has the most amount wins. Each of them has a pair of keys and each knows the public key of the other. You can visualize it like this
At the same time, both Alice and Bob will be sure of the impossibility of obtaining other data and the fairness of this game.
Where can it be useful and where is it applied?
Here we explained the VRF mechanism in a simplified way, but Algorand consensus works similarly.
We assume the use of VRF in smart contracts and services on KLYNTAR. Also, it's a great method for MEV-resistance or other stuff in workflows which require randomness.
Links
Last updated