I am developing a decentralized algorithm which is able to do a deterministic calculation based on input data and a given random seed.
But how to achieve a provably fair and cryptographically secure pseudorandom number generator (CSPRNG) on hyperledger ?
My first assumption was to get a random number from the consensus algorithm but a validator could manipulate the current block to his advantage if he sends the transaction only with his manipulated block.
Later I developed this algorithm which should work but is hard to implement:
for every block:
every validator:
1. generates new temporary privkey and pubkey
2. makes a raw transaction to the next validators pubkey
3. transfers his privkey to the blockchain after a block was broadcasted
4. verifies every privkey which belongs to a pubkey on the blockchain
5. calculates H(blockhash | privkey1 | privkey2 | ... | privkeyn) as new random number
I think this is really interesting for gambling applications, too.
So what is the easiest way for my problem? Should I realize the algorithm shown above?