Mates Raffle
They really do. Per wikipedia, the first lottery/raffle system we have record of in human history are some keno slips from the Chinese Han dynasty between 205 and 187 BC. Humans love a punt, and they seemingly always have.
The thing about lotteries, raffles and gambling that gets us going is the 'Well, what if I did win?' cost analysis type thinking that comes with them, something that is only fair to think when a raffle with valuable prizes is conducted fairly - fairly meaning that no cheating is possible to pick winners in advance.
matesraffle.com aims to provide a good looking web app that allows for creation and management of raffle systems that source their randomness from public computers, that anyone can verify. matesraffle.com does this by utilising Verifiably Random numbers from Chainlink and Pyth Network, 2 separate oracle providers.
An oracle in computing refers to accessing non-computer generated information. Computers are excellent at either doing nothings (0s) or doing somethings (1s), so, how can they generate random things?
The short answer is, they kind of can't, so consulting an external source of randomness is often useful to guarantee randomness. For example, Cloudflare does this by using 100 Lava Lamps, then reading the randomness that comes off such a set up and using that for their random input values.
By getting 2 separate oracle providers we get 2 completely random sources of information, this would mean that in order for someone to cheat this system, they would need to have control of all 2 oracle providers. This is tricky, but not impossible, I think we can add more fairness guarantees.
Hash Functions
A hash function or a trap-door function is something that sends information one way, with no way to return to the previous place it was.
input
hash(input)
output
A good hash function is collision resistant, meaning that for a unique given input (i), you should always get a unique given output (o).
i0
hash(i0)
o0
i1
hash(i1)
o1
...
iN
hash(iN)
oN
Because of these properties, when given the output of a hash function, it can be used as a commitment to a given input, without yet revealing anything about the input itself.
matesraffle.com utilises these properties to by committing to a locally generated value when a raffle is created. We call this our 'Raffle Secret', and we call the hashed output of our Raffle Secret our 'Raffle ID', and we can share this with anyone.
Achieving Verifiable Randomness
You might of already seen this coming, but, we achieve randomness by creating a value by hashing:
- All VRF values from our oracle providers
- Our Raffle ID (which is public)
- Our Raffle Secret (which we reveal at the time of drawing)
This holds as trustless and fair, as:
- If the Oracle Providers plan to collude, they do not know our Raffle Secret that will be hashed with their dishonest inputs.
- If the raffle organiser wants to cheat, they have to find a hash collision of 4 separate input fields, as they are still bound by hash function properties.
Both of these statements should hold true with the hash function being used, mainly because of the discrete log hard property of our hash function.
Once we have our random output, based on the amount of tickets, prizes and rules of the raffle (can someone win more than once, etc), we can output a list of winning tickets for the world to see.