Why Cadence Only provide UnsafeRandom function instead of using random number generated by threshold signature?

Flow utilize threshold signature to generate random number used to pick random committee, why not expose this randomness to smart contract? Is there any considerations?

We recently discussed this on forum[0] and on office hours. Basically they are few issues as far as I can see.

  • Try & Abort ( basically interact with the contract in a brute force way till you get the result you want, panic if you don’t like the result)
  • Your transaction is executed on multiple execution nodes and result is compared (if you had different random on those nodes, they would disagree) So I think syncing the random for transaction would be a bit problematic

I think second issue can be solved, also there are some ideas for the first one.

Sooner or later I believe we will have random on chain.

[0] https://forum.onflow.org/t/randomness-for-nft-packs-on-flow/1830/5

Yes, that is something we are looking into, but it’s complicated.

For now we have added a basic implementation so that developers can also already start developing their applications that require random numbers.

@tarak.by probably has more information