π§΅ Let's dive into the technical details of RandoMina: a protocol for provable random number generation on Mina Protocol blockchain blockchain written in 01JS! π’π
π‘ Powering zkLocus
π GitHub: https://github.com/iluxonchik/randomina/
1οΈβ£ RandoMina uses Zero-Knowledge proofs to ensure random numbers are provable, fresh, and trustless. It combines:
- Network State π
- Sender-Specific Nonce π
- Local Seed/Nonce π±
2οΈβ£ To ensure freshness, RandoMina leverages $Mina's VRF (Verifiable Random Function) values, specifically `stakingEpochData.seed.value`. π
This value is updated with each new staking epoch, providing a unique seed for each epoch. π
3οΈβ£ Using `stakingEpochData.seed.value` as part of the PRNG seed ensures that random numbers are tied to the current epoch, preventing manipulation and guaranteeing freshness. πΏ
4οΈβ£ The Sender-Specific Nonce is derived from the sender's public key, ensuring unique (pseudo)random numbers across the network. π
It's computed by Poseidon-hashing the public key, adding a global uniqueness component. π
5οΈβ£ The Local Seed/Nonce allows generating multiple random numbers per epoch for each sender. π²
By varying this private nonce, an infinite number of pseudo-random numbers can be generated within a single epoch. βΎοΈ
6οΈβ£ RandoMina's smart contract, `RandoMinaContract`, verifies the computation and ensures the claimed network state matches the current epoch. β
It's designed to be used or integrated by other contracts needing secure randomness. π§©
7οΈβ£ Here's how RandoMina ensures unique random numbers! π΅οΈ
- Two identities (public keys) will always generate different random numbers π
- Same identity with different local seeds produces unique numbers π±
- Same identity across different epochs generates distinct numbers π
8οΈβ£ When two identities generate random numbers using RandoMina:
β
Sender-Specific Nonce is unique due to different public keys
β
Combining unique Sender-Specific Nonce with Network State and Local Seed/Nonce
β‘οΈ Always results in different random numbers for each identity! π
9οΈβ£ For the same identity, using different Local Seed/Nonce values:
π Varying the Local Seed/Nonce
π While keeping the Sender-Specific Nonce and Network State constant
β‘οΈ Produces unique random numbers for the same identity within an epoch! πͺ
π Across different epochs, the same identity generates distinct random numbers:
π Network State changes with each new epoch
π Updated Network State is combined with Sender-Specific Nonce and Local Seed/Nonce
β‘οΈ Guarantees diff numbers for the same identity across epochs! β°
1οΈβ£1οΈβ£ Generating a random number involves:
1. Preparing public (Network State, Sender) and private (Nonce) inputs
2. Generating a proof using `RandomNumberObservationCircuit`
3. Verifying the proof and network state with `RandoMinaContract`
Code & Tests: https://github.com/iluxonchik/randomina
1οΈβ£2οΈβ£ In summary, RandoMina leverages ZK proofs, $Mina's VRF `stakingEpochData.seed.value`, and a combination of network state, sender info, and local nonces to provide secure, verifiable, and infinite randomness for dAppss π
That's it for technical deep dive into RandoMina and its 01JS implementation on Mina Protocol blockchain ! π€Ώ
For more details, check out the source code and tests on GitHub. βοΈ
Feel free to ask any questions or share your thoughts! π¬
π https://github.com/iluxonchik/randomina