Inspiration
It would be great to be able to generate random numbers directly on an L1
What it does
It is a SmartPy implementation of the 4-digit 64 bit Threefry algorithm described in http://www.thesalmons.org/john/random123/releases/1.11.2pre/docs/
These pRNGs are suitable for blockchain usage as they are stateless, you pass in a key (or seed) and counter (state) and it gives back a random set of numbers in a deterministic fashion.
If you want a stream of randoms you just increment the counter and call rand again. It has the property that any call to rand with the same key and counter will yield the same random number (deterministic), however if you call it with slightly different key or counter it will give significantly different answers and as such it is suitable for blockchain usage.
How we built it
In SmartPy and compiled to Michelson
Challenges we ran into
I wanted to wrap the whole thing up in a sapling contract with the idea that one could seed it with a mutez value via a shielded transaction and thus keep the seed hidden but I ran out of time.
Accomplishments that we're proud of
It seems to give the same results as the reference implementation
What we learned
Sapling stuff is hard
What's next for pRNG
Do the sapling idea
Contact me
telegram
Built With
- smartpy
Log in or sign up for Devpost to join the conversation.