How do we decide who wins?
The winner is decided using three key elements:
1. A server secret of which the hash is revealed beforehand. We have 24 hours upon the termination of a round to reveal the server secret; otherwise everyone gets their money back.
2. A client secret which is updated each time a transaction is sent within a round. Once the round ends, this is set in stone.
3. The blockhash of the block following the round. This is also set in stone upon the end of a round.
We can't cheat you because we can't easily modify (2 and 3). You can't cheat us because you don't know (1). It's to our advantage to pay you to keep the contract running.
//Update client seed
clientSeed = sha3(clientSeed, msg.sender, msg.value);
庄家只要参与最后一笔投注,就可以指定client secret,所以上面说的2很难修改不成立
//Fetch the non-server sources of entropy
bytes32 serverClientHash = sha3(curSecret, lastClientSeed);
//Calculate winner and pay out
uint winnerIdx = lastProcessed + uint(serverClientHash ^ lastBlockHash) % TICKETSPERROUND;
所以庄家可以提前知道serverClientHash。
庄家如果和矿池合作,就可以大幅提高胜率!
randao就快好了, be patient :D