There are quite a few bitcoin gambling sites, starting with Satoshi Dice, that use this method. The hashcode of any specific future block is definitely random. There is definitely no way for a hacker to control it, and everyone can agree on what the hashcode is after the block is confirmed.
However, on reflection, I think it would be simpler to use specific block numbers. Then I can give a link to the block explorer page with the hash code, as follows:
• The winning lottery ticket numbers will be calculated using the total number N of tickets sold, and the confirmed hash code H of MAXcoin hashchain block number 106520, obtained after block number 106620 has been found (100 confirmations).
That is, once the the cryptoexplore search for block 106620 returns a block rather than
For example, no one can dispute these facts with a straight face, and everyone can easily check them (click the link):
• The hash of block 50000 is 00000000000059b7b1670117eeb04f472036c073f275cd50decce15d3894c8f5 in hex.
• The decimal value of that hash is 144170545449846795252878978589069370515757698399706647721462005.
You can calculate and check that decimal value using this arbitrary precision hex to decimal to hex converter.
If N is 10000, you can compute the winning ticket numbers in your head given the decimal value of the hash.
First prize would go to ticket 2005, second prize to ticket 2146, and third prize to ticket 6477. Note: the 12 least significant digits are 647721462005.
The decimal value of the hash, and the winning ticket numbers for more difficult values of N, are easily calculated using the bc command line tool which comes standard on most every Linux:
144170545449846795252878978589069370515757698399706647721462005
$ echo 'ibase=16;
> h=00000000000059B7B1670117EEB04F472036C073F275CD50DECCE15D3894C8F5;
> ibase=0A;
> n=10000;
> print "first prize: ", h%n, "\nSecond prize: ", (h/n)%n, "\nThird prize: ", ((h/n)/n)%n, "\n"' | bc
first prize: 2005
Second prize: 2146
Third prize: 6477
$ echo 'ibase=16;
> h=00000000000059B7B1670117EEB04F472036C073F275CD50DECCE15D3894C8F5;
> ibase=0A;
> n=9999;
> print "first prize: ", h%n, "\nSecond prize: ", (h/n)%n, "\nThird prize: ", ((h/n)/n)%n, "\n"' | bc
first prize: 9555
Second prize: 4693
Third prize: 2067
$ echo 'ibase=16;
> h=00000000000059B7B1670117EEB04F472036C073F275CD50DECCE15D3894C8F5;
> ibase=0A;
> n=1000;
> print "first prize: ", h%n, "\nSecond prize: ", (h/n)%n, "\nThird prize: ", ((h/n)/n)%n, "\n"' | bc
first prize: 5
Second prize: 462
Third prize: 721
$ echo 'ibase=16;
> h=00000000000059B7B1670117EEB04F472036C073F275CD50DECCE15D3894C8F5;
> ibase=0A;
> n=997;
> print "first prize: ", h%n, "\nSecond prize: ", (h/n)%n, "\nThird prize: ", ((h/n)/n)%n, "\n"' | bc
first prize: 72
Second prize: 550
Third prize: 848
Another place where the lottery operator is asking for unnecessary trust: The assignment of ticket numbers must occur in an automatic and indisputable manner, with no discretion on the part of the lottery operator. The best way to ensure this would have been to state ahead of time that any deposit transaction which is not for an integral number of MAXcoin would be returned. This can be fixed:
• Starting March 1, all transactions must deliver an integral number of MAXcoin, or they will be returned.
• The ticket numbers for earlier transactions will be published on March 2, and any disputes will be resolved before the drawing.
• Subsequent ticket numbers will be assigned in the order the transactions are listed on the block explorer websites. (Experts should be consulted to be certain that this is the same as the order transactions occur in the actual block).
• The lottery will close early enough so that the list of ticket numbers can be published before the drawing.
Regarding payout addresses:
• Starting March 1, the payout address will be the first sending address in the transaction.
• Users of online wallets should send a small amount to the lottery address, and verify that they receive the refund to their online account. If they don't, they would be well advised to switch to a different wallet, or better, to run the standard wallet software on their PC.
• If some vandal tries to DOS the lottery by sending lots of small amounts, the promise to return them is void. Users should check the lottery address before sending their test amount to be sure this is not happening.
See also my earlier posting, which used blockchain timestamps instead of specific block numbers.