I'm working on a smart contract to run a fair lottery game. The winner is chosen by way of random number generation. The current plan is to get the random number from an oracle source. However, this has made me wonder - how does the oracle communicate the number to the blockchain securely?
Because everything in a smart contract is visible (much like anything stored in a HTML file) they cannot hold a private key without it being visible so any public-private key encryption is no longer secure? Therefore how do you know that the externally generated random number has been sent to your smart contract securely and not been intercepted and changed along the way? The scenario that jumps to mind is when the random number is committed to the blockchain but miners could reject it if it didn't result in a win for them (same reason using an external random number generator is recommended). So how does it happen securely?
Any thoughts/explanation/instruction would be great!