Archive for September, 2015

TOTALLY mental poker

Posted on September 19th, 2015 2 Comments

A few weeks ago when the HR lady called me and told me that I too was now among a number of people who had been laid off as a result of “business decisions”, I could scarcely contain my enthusiasm. “That’s great!”, I replied giddily. There was a moment of silence before I caught myself. “I mean, that sucks … terrible .. but it’s great that I know about it sooner rather than later”, I sputtered. Good save.

I clumsily explained that, having spoken to colleagues and being aware of the changes, I could now live without the uncertainty, then swung the conversation back around to me getting fired.

“Yeah, no, that’s bad news,” I assured her but added that the severance would be helpful.

I was lying – I was elated.

Thing is, I’d been working on a project in my spare time that it was probably best to keep hush-hush. So it was. The main complication was the fact that the project is an online poker game and I was – until recently – working for a company that had bought PokerStars. It wasn’t that I was “borrowing” code or secrets or clients or anything like that, and I genuinely liked working for them, it’s just that the whole situation felt complicated.

biermarkt on the esplanade

Besides I just thought that the idea was too damn good to risk any potential roadblocks, especially early on. So I assumed an alias and toned down my writing style.

I was asked why I included a cryptographic identity when I first announced the project on Reddit, and this is why. I was probably being a little too paranoid but so far everyone I’ve discussed it with thinks it’s a pretty darned good idea. I’ve even seen it suggested that if such a thing could be built it would be “super revolutionary“, “so obviously disruptive“, “a killer app“, and other encouraging adjectives, so protecting the work by keeping my identity hidden seemed wise.

I hope you can see how one might foresake blogging for a bit in order to concentrate on such a project, but I did at least hint at it when I was starting to see some solid first results. I wasn’t just talking out of my ass there.

So since we’re at the part of the story where I’m unveiled as the guy behind the project I might as well call it by its real name: CypherPoker.

Okay, so it’s an online poker game, right? So what?

Well, for starters, it really is quite unique, disruptive, and revolutionary – it’s almost entirely bass-ackwards to the way that online poker currently works.

I’m sure that I’m not giving anything away when I say that most online gaming sites operate under a “client-server” model. This means that they own and operate computers with big internet connections that “serve” game information to the players’  computers or “clients”. In effect, games take place almost entirely on the operators’ computers; clients are used mostly to display the results of the games in a nice way.

This makes sense. You can see how it’d be problematic if the clients (players/peers) were to decide how cards should be dealt – someone would just need to hack the software to enable all sorts of cheating. In the client-server approach hackers would have to get at the servers which is much more difficult (but not impossible).

Players must also trust that operators are being fair and honest, and when they are, that they are able to properly monitor their systems for cheating. This has not always been the case.

With CypherPoker this approach is turned almost entirely on its head and in a way that seems paradoxical. For example, players play directly with each other (a.k.a. peer-to-peer) – no servers are needed.

But didn’t I just finish talking about how problematic it’d be if players were allowed to “deal” each other cards over the internet?

Yeah. In fact, the problem was described much more succinctly in a somewhat obscure MIT paper entitled “Mental Poker“:

Can two potentially dishonest players play a fair game of poker without using any cards … over the phone?

Even though this question seems like a real mind fuck, there’s actually a viable solution to the problem and the authors go on to show you how it’s done.

Because the answer uses math (cryptography), and since we’re no longer living in the Dark Ages, substituting “phone” with “networked computing device” is a simple but necessary step; I ain’t doing the calculations on paper!

casa loma

Back when “Mental Poker” was still a fresh and new idea, computers just weren’t capable of handling the kinds of computations needed to play a decent game. I remember reading that a card “shuffle” operation in an early Mental Poker implementation required hours of calculation. Can you imagine how long a single game would last? Yikes! Well, it’s 2015 and modern hardware is finally capable of crunching the numbers in a reasonable amount of time.

Paradoxically, visualizing how the game works requires no math skills whatsoever.

First we need to get our hands on 52 identical, peek-proof lock boxes with a miraculous ability to repel any markings (scratches, dents, paints, decals, etc.) In addition we’ll need 52 identical locks with the same miraculous abilities and one master key to open them all. My opponent, you, also has 52 miracle locks and a key to go with them.

Now I start by distributing the cards in my card deck into the boxes – one per – and lock them all. I mix up the boxes for good measure and call Larry’s Super Courier service to deliver them to you. You soon get the boxes and apply your own locks so that now all of the boxes are double-locked. With the way that each box is secured, either lock can come off first. Even though this is easy to achieve using physical lock boxes (just use a big latch), it’s a very important property – we need to be able to add or remove locks in any order for this process to work.

After being mixed up again the 52 double-locked boxes are returned to me.

Since we’re playing Texas Hold’em, I need to select two private (hole) cards for myself so I simply pick two boxes and send them to you. You remove your locks from them so that only my locks remain. When the boxes are returned to me I remove my locks and extract my cards – simple. Notice that even though I locked all the boxes first, I had to unlock these two boxes last – after you removed your locks. Without the ability to add or remove locks in any order this all wouldn’t work.

Of course you need to repeat this process in order to “unlock” other cards, and there are other types of exchanges that are required for a full card game, but that’s the gist of it.

If we use numbers to represent physical cards – 1=Ace of Spades, 2=Two of Spades, etc. – we can use cryptography to “lock” and “unlock” them. As long as the cryptography is “commutative”, or can be applied and removed in any order, we can effectively play a fair game of poker over a telephone. Or maybe over the internet with a computer to do the calculations and display the results.

The “Mental Poker” idea is plenty cool all by itself but if you throw the serendipitous rise of Bitcoin into the mix, the whole thing starts to take on new dimensions. When you add anonymity via something like Tor or I2P to the game and the associated services (for example, introducing random internet players to each other), the possibilities absolutely blossom.

sunflowers @ jarvis and richmond

CypherPoker is well beyond the idea stage; the game exists and is available to play today. I spent the time writing versatile and solid code so the game is functional but the user interface sucks. However, now that I can drop the alias I can also drop the hammer so we’ll see about getting that and other shortcomings rectified forthwith.

In addition, I’m going to spend more quality time with TCL and my other blog again, partially to prevent any future fears regarding my freedom and well-being, partially to put my new camera to good use (other one disappeared a while back), but also to document and discuss the project’s progress more closely and regularly now that I don’t have to censor my output. I haven’t found any “Mental Poker” implementations that are as far along as mine so it’s hard to say exactly what lies ahead but that tingly feeling in my gut tells me that it’s probably going to be awesome.

Filed under: B Sides, Patrick Bay, Pictures