Here is a game you can play. It is essentially the simplified version of poker over the telephone from Section 18.2. There are five cards: ten, jack, queen, king, ace
. We have chosen to abbreviate them by the following: ten, ace, que, jac, kin. They are shuffled and disguised by raising their numbers to a random exponent mod the prime 300649. You are supposed to guess which one is the ace.
First, the cards are entered in and converted to numerical values by the following steps:
>> cards=[’ten’;’ace’;’que’;’jac’;’kin’];
>> cvals=text2int1(cards)
cvals =
200514
10305
172105
100103
110914
Next, we pick a random exponent that will be used in the hiding operation. We use the semicolon after khide so that we cannot cheat and see what value of is being used.
>> p=300649;
>> k=khide(p);
Now, shuffle the disguised cards (their numbers are raised to the th power mod and then randomly permuted):
>> shufvals=shuffle(cvals,k,p)
shufvals =
226536
226058
241033
281258
116809
These are the five cards. None looks like the ace; that’s because their numbers have been raised to powers mod the prime. Make a guess anyway. Let’s see if you’re correct.
>> reveal(shufvals,k,p)
ans =
jac
que
ten
kin
ace
Let’s play again:
>> k=khide(p);
» shufvals=shuffle(cvals,k,p)
shufvals =
117135
144487
108150
266322
264045
Make your guess (note that the numbers are different because a different random exponent was used). Were you lucky?
>> reveal(shufvals,k,p)
ans =
kin
jac
ten
que
ace
Perhaps you need some help. Let’s play one more time:
>> k=khide(p);
» shufvals=shuffle(cvals,k,p)
shufvals =
108150
144487
266322
264045
117135
We now ask for advice:
>> advise(shufvals,p);
Ace Index: 4
We are advised that the fourth card is the ace. Let’s see:
>> reveal(shufvals,k,p)
ans =
ten
jac
que
ace
kin
How does this work? Read the part on “How to Cheat” in Section 18.2. Note that if we raise the numbers for the cards to the power mod , we get
>> powermod(cvals,(p-1)/2,p)
ans =
1
300648
1
1
1
Therefore, only the ace is a quadratic nonresidue mod .
18.219.208.117