2

I want to understand on-chain and off-chain operations in the context of randomness. Kindly provide me an example so that its clear to me.

I got one post here:

What are offchain and onchain Transactions?

but they did not discuss off-chain and on-chain in the context of randomness.

One example of off-chain is:

We saw some of the pitfalls of bad randomness on Ethereum, but what can one do to produce truly random numbers? A standard recommendation is to go off-chain and employ external sources. These are typically either an outside “oracle” service (e.g., Oraclize), or hashed inputs by multiple users with competitive interests.

What is meant by the outside "oracle" service (e.g Oraclize)? What is a hashed input (is it a random id?) ? If you could tell me about an inside oracle that would be useful too.

For on-chain, I got the following:

To summarize, our recommendation for on-chain random number generation is to follow a pattern such as: • Accept a bet, with payment, register the block number of the bet transaction. • The bettor has to not only place the bet but also invoke the contract in a future transaction (within the next 256 blocks). The contract will compute the blockhash of the earlier-registered block number, and use it to determine the success of the bet.

What I understand is that for on-chain we have to use some sort of blockchain variable. Am I right?

Zulfi.

0

What is meant by the outside "oracle" service (e.g Oraclize)? What is a hashed input (is it a random id?) ? If you tell me about an inside oracle that would be useful too.

An oracle is by definition always outside, so it's somewhat redundant to call it 'outside oracle'. It takes information from the outside world and makes it available inside the blockchain. Oraclize (now Provable) is generating a random number using a Nano Ledger. A 'hashed input' probably refers to the commitment scheme where users generate local random numbers and in step 1 send the hash of those numbers (commitment) and in step 2 send the actual random numbers (reveal).

What I understand is that for on-chain we have to use some sort of blockchain variable. Am I right?

Yes on-chain would refer to the randomness actually coming from on-chain data. The difference to off-chain is exactly the random number generation source. With a commitment scheme you have users computing random numbers off-chain and with Oraclize you have a random number being generated on a hardware device. For on-chain you would have to use block variables from a future block, see also your other question Blockhash: Register the block number. This can be influenced by miners to some degree, so it's only good enough if the stakes are low.

| improve this answer | |
0

in a nutshell; having a random number generator is a very important component for many algorithms. Most random number generators (RNG) are "pseudo" random number generators, meaning; the result is produced by a complete deterministic and repeatable process. Having a source of randomness with enough entropy to seed a PRNG algorithm is the most important component of the algorithm. Usually PRNG entropy seed is sourced from physical events like CPU noise level or virtual events driven by physical events mouse movement combined with other variables of the compute system - check https://en.wikipedia.org/wiki/dev/random.

As you can observe a true source of randomness is mostly bound to unpredictable physical events. Now imagine trying to achieve that in a platform that is deterministic and sandboxed from any proactive interaction with the external world. Most Blockchain solutions do not have parameters in their trust boundary that can offer enough entropy to simulate this unpredictable physical events and most of the parameters (block high, timestamp, ...etc) do not provide enough entropy to be considered secure, hence on chain randomness is hard.

Now you would think how about i just gather the randomness outside and feed it to the blockchain layer (E.g using a smart contract), the challenge here now is the distributed nature of the blockchain which makes trusting the correctness, finality of this value itself is not an easy task, and this is why distributed oracles services exist.

https://www.random.org/randomness/ https://en.wikipedia.org/wiki/Randomness https://blog.chain.link/verifiable-random-functions-vrf-random-number-generation-rng-feature/ https://fravoll.github.io/solidity-patterns/randomness.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.