Distant Poker with Cheaters Presentation

56
How to Play Distant Poker with Cheaters Using Number Theory Kelly Bresnahan November 13, 2015

Transcript of Distant Poker with Cheaters Presentation

Page 1: Distant Poker with Cheaters Presentation

How to Play Distant Poker with CheatersUsing Number Theory

Kelly Bresnahan

November 13, 2015

Page 2: Distant Poker with Cheaters Presentation

Table Of Contents

1 Flipping a Coin Over the Phone

IntroductionProcedureHow the Fair Coin Toss Procedure Guarantees FairnessDrawbacks to the Scheme

2 Distant Poker

Aspects of a Fair GameAnalogy of the Distant Poker SchemeProcedureHow to Cheat

Page 3: Distant Poker with Cheaters Presentation

Flipping a Coin Over the Phone: Introduction

It is difficult to perform a fair coin toss over the phone.For example,

”Alice is living in Anchorage and Bob is living in Baltimore. Afriend, not realizing that they are no longer together, leavesthem a car in his will. Bob phones Alice and says he’ll flip acoin. Alice chooses ”Tails” but Bob says ”Sorry, it was Heads.”So Bob gets the car.”

Is Bob telling the truth?

Page 4: Distant Poker with Cheaters Presentation

Introduction

We need a way for Alice to keep her choice a secret, while stillhaving to commit to that choice.

We also need a way for Bob to prove he is, or is not the winner

Page 5: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure

i) Alice chooses two large primes p and q such that p and qare congruent to 3 modulo 4. She then defines n = pq,sending n to Bob while keeping p and q secret.

ii) Bob chooses a random number x and computes

y ≡ x2 (mod n)

By definition y is a quadratic residue modulo n, therefore

x ≡ ±yp+14 (mod p)

andx ≡ ±y

q+14 (mod q)

Page 6: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure

i) Alice chooses two large primes p and q such that p and qare congruent to 3 modulo 4. She then defines n = pq,sending n to Bob while keeping p and q secret.

ii) Bob chooses a random number x and computes

y ≡ x2 (mod n)

By definition y is a quadratic residue modulo n, therefore

x ≡ ±yp+14 (mod p)

andx ≡ ±y

q+14 (mod q)

Page 7: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure

i) Alice chooses two large primes p and q such that p and qare congruent to 3 modulo 4. She then defines n = pq,sending n to Bob while keeping p and q secret.

ii) Bob chooses a random number x and computes

y ≡ x2 (mod n)

By definition y is a quadratic residue modulo n, therefore

x ≡ ±yp+14 (mod p)

andx ≡ ±y

q+14 (mod q)

Page 8: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

iii) Bob keeps x secret and send y to Alice

iv) Alice finds ±a and ±b such that

x ≡ ±a (mod n) or x ≡ ±b (mod n)

Alice computes c ≡ yp+14 (mod p) and d ≡ y

q+14 (mod q)

Therefore x ≡ ±c (mod p) and x ≡ ±d (mod q)

Alice uses the Chinese Remainder Theorem to find the foursolutions:x ≡ ±a (mod n) or x ≡ ±b (mod n)

Page 9: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

iii) Bob keeps x secret and send y to Alice

iv) Alice finds ±a and ±b such that

x ≡ ±a (mod n) or x ≡ ±b (mod n)

Alice computes c ≡ yp+14 (mod p) and d ≡ y

q+14 (mod q)

Therefore x ≡ ±c (mod p) and x ≡ ±d (mod q)

Alice uses the Chinese Remainder Theorem to find the foursolutions:x ≡ ±a (mod n) or x ≡ ±b (mod n)

Page 10: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

iii) Bob keeps x secret and send y to Alice

iv) Alice finds ±a and ±b such that

x ≡ ±a (mod n) or x ≡ ±b (mod n)

Alice computes c ≡ yp+14 (mod p) and d ≡ y

q+14 (mod q)

Therefore x ≡ ±c (mod p) and x ≡ ±d (mod q)

Alice uses the Chinese Remainder Theorem to find the foursolutions:x ≡ ±a (mod n) or x ≡ ±b (mod n)

Page 11: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

iii) Bob keeps x secret and send y to Alice

iv) Alice finds ±a and ±b such that

x ≡ ±a (mod n) or x ≡ ±b (mod n)

Alice computes c ≡ yp+14 (mod p) and d ≡ y

q+14 (mod q)

Therefore x ≡ ±c (mod p) and x ≡ ±d (mod q)

Alice uses the Chinese Remainder Theorem to find the foursolutions:x ≡ ±a (mod n) or x ≡ ±b (mod n)

Page 12: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

iii) Bob keeps x secret and send y to Alice

iv) Alice finds ±a and ±b such that

x ≡ ±a (mod n) or x ≡ ±b (mod n)

Alice computes c ≡ yp+14 (mod p) and d ≡ y

q+14 (mod q)

Therefore x ≡ ±c (mod p) and x ≡ ±d (mod q)

Alice uses the Chinese Remainder Theorem to find the foursolutions:x ≡ ±a (mod n) or x ≡ ±b (mod n)

Page 13: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

v) Alice chooses one solution at random, say ±b.

This is the flip.

vi) Alice send her choice to Bob

If ±b ≡ x (mod n), then Alice winsIf ±b 6≡ x (mod n), then Bob wins

Page 14: Distant Poker with Cheaters Presentation

Fair Coin Toss Procedure (cont)

v) Alice chooses one solution at random, say ±b.

This is the flip.

vi) Alice send her choice to Bob

If ±b ≡ x (mod n), then Alice winsIf ±b 6≡ x (mod n), then Bob wins

Page 15: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

How can Bob prove he is the winner?

If Alice guesses b, but x = ±a (mod n), then Bob canfactor n.

- Computing gcd(x − b, n) will give a nontrivial factor of n.

If Bob cannot factor n, then he loses.

Page 16: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

How can Bob prove he is the winner?

If Alice guesses b, but x = ±a (mod n), then Bob canfactor n.

- Computing gcd(x − b, n) will give a nontrivial factor of n.

If Bob cannot factor n, then he loses.

Page 17: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

How can Bob prove he is the winner?

If Alice guesses b, but x = ±a (mod n), then Bob canfactor n.

- Computing gcd(x − b, n) will give a nontrivial factor of n.

If Bob cannot factor n, then he loses.

Page 18: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

How can Bob prove he is the winner?

If Alice guesses b, but x = ±a (mod n), then Bob canfactor n.

- Computing gcd(x − b, n) will give a nontrivial factor of n.

If Bob cannot factor n, then he loses.

Page 19: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

Can Alice cheat by sending a random integer b′ in place of ±aor ±b?

No, because Bob can always check to see that(b′)2 6≡ x (mod n)

Page 20: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

Can Alice cheat by sending a random integer b′ in place of ±aor ±b?

No, because Bob can always check to see that(b′)2 6≡ x (mod n)

Page 21: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

Can Alice cheat by sending Bob n = pqr , where p, q, and r arethree distinct primes?

She can, but this will actually reduce her chances ofwinning from 50% to 25% since there are now 8 squareroots of y

Page 22: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

Can Alice cheat by sending Bob n = pqr , where p, q, and r arethree distinct primes?

She can, but this will actually reduce her chances ofwinning from 50% to 25% since there are now 8 squareroots of y

Page 23: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

Can Bob purposefully lose?

Yes! Bob can always claim his value of x was exactly whatAlice sent him. Alice has no way of verifying this.

Page 24: Distant Poker with Cheaters Presentation

How Does this Prevent Cheating?

Can Bob purposefully lose?

Yes! Bob can always claim his value of x was exactly whatAlice sent him. Alice has no way of verifying this.

Page 25: Distant Poker with Cheaters Presentation

Distant Poker: Introduction

We have to assume that Alice and Bob are not trustful. Wewant to ensure that,

1 Alice is able to read her cards without Bob seeing them

2 Bob deals the cards out fairly

3 All cards are being used.

Page 26: Distant Poker with Cheaters Presentation

Analogy to Distant Poker Scheme

Bob takes 52 identical boxes, puts a card in each box, and putsa lock on each one of them. Then Alice puts her locks onBob’s boxes, so that each box has two locks.

This is akin to leaving the cards face down.

In addition, neither player is able to see the cards without theother person’s consent.

Page 27: Distant Poker with Cheaters Presentation

Analogy to Distant Poker Scheme

Bob takes 52 identical boxes, puts a card in each box, and putsa lock on each one of them. Then Alice puts her locks onBob’s boxes, so that each box has two locks.

This is akin to leaving the cards face down.

In addition, neither player is able to see the cards without theother person’s consent.

Page 28: Distant Poker with Cheaters Presentation

Analogy to Distant Poker Scheme

Bob takes 52 identical boxes, puts a card in each box, and putsa lock on each one of them. Then Alice puts her locks onBob’s boxes, so that each box has two locks.

This is akin to leaving the cards face down.

In addition, neither player is able to see the cards without theother person’s consent.

Page 29: Distant Poker with Cheaters Presentation

Procedure: Initialization

i) Alice and Bob agree on a large prime, p

ii) Alice picks a secret integer α such that gcd(α, p − 1) = 1

iii) Bob chooses a secret integer β such that gcd(β, p− 1) = 1

iv) Alice computes α′ such that αα′ = 1 (mod p − 1)

v) Bob computes β′ such that ββ′ = 1 (mod p − 1)

Page 30: Distant Poker with Cheaters Presentation

Procedure: Initialization

i) Alice and Bob agree on a large prime, p

ii) Alice picks a secret integer α such that gcd(α, p − 1) = 1

iii) Bob chooses a secret integer β such that gcd(β, p− 1) = 1

iv) Alice computes α′ such that αα′ = 1 (mod p − 1)

v) Bob computes β′ such that ββ′ = 1 (mod p − 1)

Page 31: Distant Poker with Cheaters Presentation

Procedure: Initialization

i) Alice and Bob agree on a large prime, p

ii) Alice picks a secret integer α such that gcd(α, p − 1) = 1

iii) Bob chooses a secret integer β such that gcd(β, p− 1) = 1

iv) Alice computes α′ such that αα′ = 1 (mod p − 1)

v) Bob computes β′ such that ββ′ = 1 (mod p − 1)

Page 32: Distant Poker with Cheaters Presentation

Note

We ask for this so we can use Fermat’s theorem(ap−1 ≡ 1 (mod p))

Page 33: Distant Poker with Cheaters Presentation

Procedure: Dealing

vi) Each card is changed into a distinct integer ci (mod p) viasome scheme

vii) Bob computes bi ≡ cβi (mod p) for 1 ≤ i ≤ 52

viii) Bob randomly permutes (i.e. shuffles) the numbers andsends them to Alice

ix) Alice chooses five cards bi1 , bi2 , bi3 , bi4 , andbi5 andcomputes

bαij (mod p)

for 1 ≤ j ≤ 5(This is analogous to Alice encrypting, or locking her cardsso Bob can’t see them.)

Page 34: Distant Poker with Cheaters Presentation

Procedure: Dealing

vi) Each card is changed into a distinct integer ci (mod p) viasome scheme

vii) Bob computes bi ≡ cβi (mod p) for 1 ≤ i ≤ 52

viii) Bob randomly permutes (i.e. shuffles) the numbers andsends them to Alice

ix) Alice chooses five cards bi1 , bi2 , bi3 , bi4 , andbi5 andcomputes

bαij (mod p)

for 1 ≤ j ≤ 5(This is analogous to Alice encrypting, or locking her cardsso Bob can’t see them.)

Page 35: Distant Poker with Cheaters Presentation

Procedure: Dealing

vi) Each card is changed into a distinct integer ci (mod p) viasome scheme

vii) Bob computes bi ≡ cβi (mod p) for 1 ≤ i ≤ 52

viii) Bob randomly permutes (i.e. shuffles) the numbers andsends them to Alice

ix) Alice chooses five cards bi1 , bi2 , bi3 , bi4 , andbi5 andcomputes

bαij (mod p)

for 1 ≤ j ≤ 5(This is analogous to Alice encrypting, or locking her cardsso Bob can’t see them.)

Page 36: Distant Poker with Cheaters Presentation

Procedure: Dealing

vi) Each card is changed into a distinct integer ci (mod p) viasome scheme

vii) Bob computes bi ≡ cβi (mod p) for 1 ≤ i ≤ 52

viii) Bob randomly permutes (i.e. shuffles) the numbers andsends them to Alice

ix) Alice chooses five cards bi1 , bi2 , bi3 , bi4 , andbi5 andcomputes

bαij (mod p)

for 1 ≤ j ≤ 5(This is analogous to Alice encrypting, or locking her cardsso Bob can’t see them.)

Page 37: Distant Poker with Cheaters Presentation

Procedure: Dealing

x) Alice sends her cards to Bob to take his locks off, i.e. tocompute

(bij)β′ = ((cβij )β

′)α = (cij)

α (mod p)

xi) Alice computes (cαij )α′

(mod p) = cij to unlock her cardsand get her hand

xii) Alice chooses 5 more numbers, bi , and sends them to Bob.This is his hand.

xiii) Bob raises his hand to β′ (mod p) to get his hand.

Page 38: Distant Poker with Cheaters Presentation

Procedure: Dealing

x) Alice sends her cards to Bob to take his locks off, i.e. tocompute

(bij)β′ = ((cβij )β

′)α = (cij)

α (mod p)

xi) Alice computes (cαij )α′

(mod p) = cij to unlock her cardsand get her hand

xii) Alice chooses 5 more numbers, bi , and sends them to Bob.This is his hand.

xiii) Bob raises his hand to β′ (mod p) to get his hand.

Page 39: Distant Poker with Cheaters Presentation

Procedure: Dealing

x) Alice sends her cards to Bob to take his locks off, i.e. tocompute

(bij)β′ = ((cβij )β

′)α = (cij)

α (mod p)

xi) Alice computes (cαij )α′

(mod p) = cij to unlock her cardsand get her hand

xii) Alice chooses 5 more numbers, bi , and sends them to Bob.This is his hand.

xiii) Bob raises his hand to β′ (mod p) to get his hand.

Page 40: Distant Poker with Cheaters Presentation

Procedure: Dealing

x) Alice sends her cards to Bob to take his locks off, i.e. tocompute

(bij)β′ = ((cβij )β

′)α = (cij)

α (mod p)

xi) Alice computes (cαij )α′

(mod p) = cij to unlock her cardsand get her hand

xii) Alice chooses 5 more numbers, bi , and sends them to Bob.This is his hand.

xiii) Bob raises his hand to β′ (mod p) to get his hand.

Page 41: Distant Poker with Cheaters Presentation

Procedure: Dealing

xiv) Alice now locks the remaining cards by raising each card toα (mod p).This ensures that neither Bob, nor Alice, can look at theremaining cards without the other’s consent.

Page 42: Distant Poker with Cheaters Presentation

Exchanging Cards

What if Alice wants to discard and pick up three new cards?

Alice takes her cards she wants to replace, ci and raisesthem to α (mod p)

She sends them to Bob, who computes cαβi (mod p)

Alice chooses three new cards and sends them to Bob,who raises them to β′

Alice raises her three new cards to α′ to unlock them.

Page 43: Distant Poker with Cheaters Presentation

Exchanging Cards

What if Alice wants to discard and pick up three new cards?

Alice takes her cards she wants to replace, ci and raisesthem to α (mod p)

She sends them to Bob, who computes cαβi (mod p)

Alice chooses three new cards and sends them to Bob,who raises them to β′

Alice raises her three new cards to α′ to unlock them.

Page 44: Distant Poker with Cheaters Presentation

Exchanging Cards

What if Alice wants to discard and pick up three new cards?

Alice takes her cards she wants to replace, ci and raisesthem to α (mod p)

She sends them to Bob, who computes cαβi (mod p)

Alice chooses three new cards and sends them to Bob,who raises them to β′

Alice raises her three new cards to α′ to unlock them.

Page 45: Distant Poker with Cheaters Presentation

Exchanging Cards

What if Alice wants to discard and pick up three new cards?

Alice takes her cards she wants to replace, ci and raisesthem to α (mod p)

She sends them to Bob, who computes cαβi (mod p)

Alice chooses three new cards and sends them to Bob,who raises them to β′

Alice raises her three new cards to α′ to unlock them.

Page 46: Distant Poker with Cheaters Presentation

Exchanging Cards

What if Alice wants to discard and pick up three new cards?

Alice takes her cards she wants to replace, ci and raisesthem to α (mod p)

She sends them to Bob, who computes cαβi (mod p)

Alice chooses three new cards and sends them to Bob,who raises them to β′

Alice raises her three new cards to α′ to unlock them.

Page 47: Distant Poker with Cheaters Presentation

Cheating

Can Alice deduce Bob’s cards, or vice versa?

Probably not, as Alice would need to solve several discretelog problems which are generally assumed to be difficultwhen p is large.

But no game of poker would be complete without thepossibility of cheating.

Page 48: Distant Poker with Cheaters Presentation

Quadratic Residues

Definition: Quadratic Residue Modulo pAn integer r (mod p) is a quadratic residue modulo p if theequation

r = x2 (mod p)

has a solution.

n is a nonresidue if n = x2 (mod p) has no solutions.

Page 49: Distant Poker with Cheaters Presentation

Quadratic Residues

Definition: Quadratic Residue Modulo pAn integer r (mod p) is a quadratic residue modulo p if theequation

r = x2 (mod p)

has a solution.

n is a nonresidue if n = x2 (mod p) has no solutions.

Page 50: Distant Poker with Cheaters Presentation

Quadratic Residues

There is an easy way to tell whether or not an integerz 6≡ 0 (mod p) is a quadratic residue:

zp−12 ≡

{+1 (mod p) if z is a qudratic residue modulo p−1 (mod p) if z is a nonresidue modulo p

Page 51: Distant Poker with Cheaters Presentation

Quadratic Residues

Theorem: If c is a quadratic residue modulo p if and only ifcα, cβ, and cα

βare also quadratic residues.

Proof: Since gcd(α, p − 1) = gcd(β, p − 1) = 1, then α and βare odd, hence(

cβ) p−1

2=

(c

p−12

)β= (±1)β = ±1 (mod p)

Page 52: Distant Poker with Cheaters Presentation

Quadratic Residues

Theorem: If c is a quadratic residue modulo p if and only ifcα, cβ, and cα

βare also quadratic residues.

Proof: Since gcd(α, p − 1) = gcd(β, p − 1) = 1, then α and βare odd, hence(

cβ) p−1

2=

(c

p−12

)β= (±1)β = ±1 (mod p)

Page 53: Distant Poker with Cheaters Presentation

Cheating

Now all the cards in the deck fall into two sets: quadraticresiudes, R, and nonresidues N

Bob can more easily predict Alice’s cards

Alice can choose Bob’s hand so that they are all R’s, sohis hand is chosen from 26 cards instead of 52

Alice can choose p such that only the Ace, King, Queen,Jack, and Ten of Spades are quadratic residues.

She may now choose the five residues, i.e. the royal flushfor herself to win the game

Page 54: Distant Poker with Cheaters Presentation

Cheating

Now all the cards in the deck fall into two sets: quadraticresiudes, R, and nonresidues N

Bob can more easily predict Alice’s cards

Alice can choose Bob’s hand so that they are all R’s, sohis hand is chosen from 26 cards instead of 52

Alice can choose p such that only the Ace, King, Queen,Jack, and Ten of Spades are quadratic residues.

She may now choose the five residues, i.e. the royal flushfor herself to win the game

Page 55: Distant Poker with Cheaters Presentation

Cheating

Now all the cards in the deck fall into two sets: quadraticresiudes, R, and nonresidues N

Bob can more easily predict Alice’s cards

Alice can choose Bob’s hand so that they are all R’s, sohis hand is chosen from 26 cards instead of 52

Alice can choose p such that only the Ace, King, Queen,Jack, and Ten of Spades are quadratic residues.

She may now choose the five residues, i.e. the royal flushfor herself to win the game

Page 56: Distant Poker with Cheaters Presentation

Questions