I have the following idea of implementing a lottery game:
- we have all the numbers from 1 to 40
- we generate a permutation of those numbers which will be the lottery solution
- participants need to guess that permutation to win the pot.
The implementation will be in a smart contract.
The game will have a timer, let's say a couple of minutes. If the pot is not won during that timespan, that game ends, to prevent brute-force attacks; afterwards, we can reload the game with a new permutation, but this is not relevant at the moment.
Now, my question is the following: how can we make sure that a valid permutation was generated at the beginning of the game? Any participant should be able to verify that a lucky permutation exists. I was thinking of storing the permutation as a hash and then compare the participant's hash with our hash, but it does not assure that we didn't hash garbage. Furthermore, besides hashing, my ideas point to some public key cryptography algorithms, but I can't figure out how to demonstrate that the encrypted message was obtained from a plaintext that has a certain pattern.
Therefore, I ask you, my fellow crypto-enthusiasts, is there any secure possibility to achieve this?
Thanks in advance.