4

I know that it's not possible to have a completely 'safe' random generator on block chain.

But still wondering how safe it would be if I use a combination of methods like now() and transaction_size() to generate a random number generator. How easy would it be compromised, would it be easy to manipulate the number?

5

You should never use now() to seed the random number generator because the blockchain generates a block every 0.5 second which means an attacker can write a smart contract to predict the result of a future block.

  • I was thinking it was millisecond so it would be quite unpredictable. However just checked the API reference and it was "second". So this wouldn't work. Thank you very much! By the way, is there a way to get the number of trasactions in the current block? If so, would this be a good resource for random number generation? – daniaoren Sep 14 '18 at 9:37
0

There is an official answer to this question :) https://developers.eos.io/eosio-cpp/docs/random-number-generation

  • 1
    Thank you very much, I've checked this doc before. This method is the most fair and secure one, however it is a bit unrealistic when you want to use it in games. It's just pretty hard to ask users to come back and 'reveal' their securets. – daniaoren Sep 11 '18 at 10:40
  • You dont need their secrets. All you need is a source of randomness. Dont you? – Vasiliy Bondarenko Sep 12 '18 at 13:30

protected by TeeAttack42 Nov 27 '18 at 9:57

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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