I know that the "how to generate random number" in solidity is a very common question. However, after reading the great majority of answers I did not find one to fit my case.
A short description of what I want to do is: I have a list of objects that each have a unique id, a number. I need to produce a list that contains 25% of those objects, randomly selected each time the function is called. The person calling the function cannot be depended on to provide input that will somehow influence predictably the resulting list.
The only answer I found that gives a secure random number was Here. However, it depends on input coming from the participants and it is meant to address a gambling scenario. I cannot use it in my implementation.
All other cases mention that the number generated is going to be predictable, and even some of those depend on a singular input to produce a single random number. Once again, does not help me.
Summarising, I need a function that will give me multiple, non-predictable, random numbers.
Thanks for any help.
nowandmsg.senderwould both be available to any malicious contract intending to abuse the contract above. – AnAllergyToAnalogy Oct 03 '19 at 06:40msg.sender would both be available to any malicious contract(from your first comment). Not in the actual statement, but in the implications of that statement. It is true that any malicious contract would know about it, but in order to call that function and get it to generate the exact same numbers, that contract would need the private key of thatmsg.sender... (continue) – goodvibration Oct 03 '19 at 07:05viewfunction. But imagine that in the actual system, we would take these numbers and register them on thismsg.sender(i.e., save them in a mapping in the contract's storage). Then, at a given time (say, after many users have made their gamble), the owner of the system executes the gambling-draw and grants a prize to the winner. An attack of the type that you've described is not feasible in this case. – goodvibration Oct 03 '19 at 07:05