Bill P. Godfrey et al

Wednesday, June 28, 2006


Now I feel ikky.

Monday, June 26, 2006

Stacking the deck

So I was reading this website, it had an article talking about how an on-line casino is publishing the mathematical "hash" of the virtual deck of cards before the game but without revealing everyone's state of play.

An anonymous commenter wrote...
"The integrity of the deck doesn't matter worth *anything*. The hash insures (or is supposed to) that they haven't changed the cards middeck. There is NO protection against stacking the deck."

Now this got me thinking, and I think I've worked out a way to have a dealer which everyone could be sure is fair. I stress that I think I've worked out a way. If I've made an error, (or dare I say, you think it's perfect) please leave a comment and tell me.

A deck of 52 cards has 52! (or approx 8×1067) possible shuffles. This is comfortably within the realm of 256 bits. The dealer's shuffler code will need 256 bits to perform its task.
  1. Dealer selects 256 bits, his contribution to the shuffle function, k0.
  2. Dealer selects another 256 bits for the secret salt value (salt).
  3. Dealer calculates the dealer's hash. SHA256(k0 + salt) and transmits it to all players.
  4. Each player selects their own contribution to the shuffle function, kn.
  5. Each player calculates and publishes the result of SHA256(kn).
  6. Once everyone has the player's hashes from step 5, each players publishes their kn value from step 4.
  7. Each player and dealer may audit the other player's hash by repeating the SHA256 calculation.
  8. Dealer calculates SHA256(k0 + k1 ... kn + salt) and shuffles the virtual deck with the result. (The shuffle function should be published in advance and be deterministic only on the seed value.)
  9. Dealer and players play with shuffled deck until the winner is decided.
  10. Once the game is over, dealer publishes k0 and salt, allowing everyone to audit the dealer's actions.
Note that player's kn values can be any length, within reason, depending on how difficult that player wants to make it for others to cheat. If a player trusts all other parties, that player could just use no bits at all as thier kn value.

Here's my own attempt at attacking this algorithm. Stop me if I've missed anything.
  • Neither dealer nor players can "stack the deck" by choosing a favourable kn, because all parties contribute into the final hash that seeds the shuffler.
  • The dealer can't choose a favourable k0 or salt after the each player's kn has been revealed, as the dealer will already have revealed the dealer's hash which the player's can check afterwards.
  • The last player in line can't choose favourable kn material with knowledge of all the other k inputs - even if he colludes with the dealer - as the other players don't have to reveal their actual kn value until all the players have revealed their hash.
  • Players can't change thier chosen kn value after step 5, as they will have already revealed the SHA256 of their kn value and the other players can check it.
  • Players can't collude against the dealer or other players, as salt will not be revealed until the game is over.
  • The dealer can't use different shuffled deck, as all of the dealer's actions may be repeated once the game is over and all hidden values are revelead.
Any comments please?

Its possible I'm talking rubbish. Its also possible I'm the millionth person to think of this.

UPDATE: Looking over it again, I don't think the salt value adds anything and I can't remember why I added it in the first place. Without the salt, the algorithm is the same for dealers and players, except the dealer's reveal of k0 comes after the game has completed.

Sunday, June 25, 2006


This is a rather serious and emotional piece. If you are easily upset, you may prefer to give this one a miss.

Saturday, June 24, 2006

The world has gone bonkers, part 6

The regimental goat of the 1st Battalion Royal Welch has been demoted. [...] Fusiliers will no longer have to stand to attention when Billy - demoted from Lance Corporal to Fusilier - passes by.

Twelve reasons to be happy (9)

Mr. Blue Sky
(Video by Shawn Couzens. Music by ELO.)

I love this song.

Saturday, June 17, 2006

Conversations with an atheist

An interesting set of conversations between christian pastor Tim Harlow and atheist Hemant Mehta. These discussions have an unfortunate tendancy to descend into a shouting match exchanging chichés, so it was good to hear a civilised conversation.

Go listen. Annoyingly, they don't have an MP3 version, only WMA and Real-Audio formats. (As I write this, I've only heard the first segment, ~50 minutes.)

Sunday, June 11, 2006

Guardian of evil

Who needs a bear patrol?

BBC - Tabby cat terror for black bear

Saturday, June 10, 2006

Wikipedia ergo sum

Friday, June 09, 2006

Early attempts at comedy.

In my second year of secondary school (I would have 12 or 13 - ish), my school were planning a mini-variety show. Therein, I almost had my first break.

As luck would have it, the show was announced shortly after I saw a cartoon version of Romeo and Juliet on television. All I recall after watching the ending of fake deaths and suicides was thinking that "This makes no sense!"

That ending was the seed for my epic work. The basic idea was I'd start with the Romeo and Juliet ending, then other characters would come on and kill themselves in increasingly strange ways for increasingly strange reasons.

Instead of Italians, my play had all the chacters as Chinese. Half were called Ping who would introduce themselves with "Me Ping". The other half were all called Pong who would introduce themselves with "Me Pong". (I was young and political correctness hadn't been invented yet. Don't judge me.)

Perhaps it was the need for expensive pyrotechnics, or the scene requiring 50 rickshaws to pile up, or the fact my script wasn't really that funny. In the end, my production did not go ahead.

Instead, we had a performance from some of the older students revolving around the catchphrase "Flaming hell!" to which the others on stage would responding shouting "Block!"

That one didn't make a lot of sense either, but it was funny.

Tuesday, June 06, 2006

Scaring children

In England, we believe in terrifying children.

Monday, June 05, 2006

I'm in the money...

No, seriously, how much? (Sour Grapes)

My blog is worth $2,822.70.
How much is your blog worth?

Wow. Any offers?