I've been looking for a decentralized algorithm that would allow a large number of interconnected computers in a P2P network (over 10,000) to collectively agree on a random number.In this scenario each peer might be connected to, say, 20 others with a "small world" network topology - where most (but not all) of a peer's connections are to nearby peers.I know it can be done on a small scale if every peer selects a random number, and then broadcasts a cryptographic hash of that number to all other peers - thus "committing" to it. The peers would then broadcast their actual random numbers which can be verified against the hashes and then combined using xor to get the global random number.With this algorithm no subset of peers could manipulate the result because even just one honest peer will randomize the global value, due to the xor step.Unfortunately this won't work in my scenario because it won't scale beyond a relatively small network.A possible solution I've considered is more easily explained if we first simplify the problem to the peer network collectively choosing a single random bit.Each peer chooses their own random value, 0 or 1, and broadcasts it to its neighbors.  Each peer then looks at whether the majority of neighbors have selected 1 or 0 and changes their bit to that value.The process is then repeated iteratively until the entire network converges to 1 or 0, my hope is that this would occur in time proportional to log(n) where n is the network size - due to the network's small world topology.This algorithm can then be extended to larger numbers involving multiple bits.While a substantial subset of peers could influence the final result (making it less secure than the small-scale algorithm), my hope is that it would require considerable resources to do this, making it impractical.I'm interested in whether anyone can recommend a better approach.