Git Product home page Git Product logo

lava's Introduction

Lava

Decentralized Random Number Generation

Technical Summary

  1. Some players, randers, submit random numbers, one at a time (plus a fixed deposit and gas costs for each submitted random number). Every submitted random number is pushed to a (cyclical) fixed-sized array. The rander whose random number gets booted off of this array upon a random number submission gets their deposit returned. Other players, preders, submit a prediction window (an array of predictions) along with 1 wager per unit length in the array (1 deposit per prediction). Finally, there are customers, who pay the smart contract a fixed amount C to automatically have a random number sent to their address or some location of their choosing.
  2. Randers and preders can submit random numbers and predictions, respectively, at any time, but each may only be entitled to disbursed when a customer places an order. Cases:
    1. The last submitted random number DOES NOT match a prediction. Thus, the most recent randers are entitled to 1/(1+i) of C, where i ranges from 1, 2, ..., N for some fixed integer N. Excess customer payment not disbursed to randers (namely the amount N - โˆ‘^N_i N/(1+i)) contributes to a pot of ether. For example, the rander who submitted a random number and deposit most recently (closest to when a customer paid for a random number) receives 1/2 of C. The rander who submitted the previous random number is entitled to 1/3 of C even if their random number has not been sent to a customer. Preders don't lose anything; Preders are returned their wager (less gas).
    2. The last submitted random number DOES match a prediction. Thus, all preders who submitted a prediction that matches the random number sent to the customer split C and receive their wager back in full. Furthermore, the first preder to submit the correct guess gets the ether pot. Note that there is nothing preventing any preder from "investing" in a particular value for a random number multiple times over using different public addresses.
    3. In both cases, the customer receives the last submitted random number.

Why It Works

Randers are incentivized to constantly submit random numbers of maximal entropy to maximize their chance of not matching a predictor while maximizing their chance to earn income from C. Preders are incentivized to correctly guess the next random number that will be utilized.

If volume is low, or too many people freely take the random numbers submitted by the randers (by accessing the smart contract's logs), then preders are incentivized to act as customers and pay for random numbers themselves. But this opens an opportunity for randers to profit - all they need to do is submit a truly random number to optimize their chances of beating the opportunistic preder to profit.

Read these to understand why a rander, under pressure from preders, is incentivized to submit samples from the uniform distribution:

Contributors

Kenny Peluso

License

MIT

lava's People

Contributors

nickemmons avatar kpeluso avatar ianlapham avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.