1
$\begingroup$

I want to implement Mental Poker in JavaScript as a toy program and lead in to a larger serious project so I did my research and found Massey-Omura cryptosystem and the Shamir three-pass protocol however I couldn't find any implementations of them, and the information on how to do SRA is scant. Would anyone be able to shed some light on how to implement Commutative Encryption with SRA(RSA) or know of a Massey-Omura/Shamir library?

$\endgroup$
  • $\begingroup$ This question is a bit broad. Note that JavaScript is not often the preferred language to implement specific cryptographic algorithms in. $\endgroup$ – Maarten Bodewes Nov 1 '14 at 23:30
  • $\begingroup$ @owlstead An example in how to do it in any framework would be a step in the right direction. I investigated; NaCl, Crypto++ and GNU Crypto and came up with nothing. It wouldn't be the first time that I have studded one well documented library so I could augment another. And option z is I reimplement one of the above ciphers. $\endgroup$ – xanth Nov 2 '14 at 0:22
1
$\begingroup$

Why can't you use RSA? Look at their description of a function on pp. 41-42, and you'll see that it is a perfectly valid choice.

So you have two users, $A$ and $B$, who want to play. One user, say $A$, selects $p \cdot q = n$, as per $RSA$, and sends that information to $B$. Both $A$ and $B$ independently choose large primes (or large numbers they confirm are coprime to $\phi(n)$) $e_A$ and $e_B$, and then compute $d_ae_a \equiv 1 \pmod n$ and $d_be_b \equiv 1 \pmod n$. Then, $E_A = m^{e_A} \pmod n$, and so on.

Any crypto library with $RSA$ support should allow for calling the encrypt and decrypt functions with your choice of exponent and modulus. The one downside is needing to generate a reasonably large new public exponent for each hand, but that isn't too bad on a modern system.

$\endgroup$
  • $\begingroup$ The product of public and private exponent must be 1 modulo $\phi(n)$, not $n$! And if you have a public key for $n$ and also know $\phi(n)$, you can always calculate the private key - the difficult part is calculating $\phi(n)$ when you don't know have the factorization of $n$. The problem with this mental poker variant is that you'd need some trusted third party to generate the key pairs, so no participant knows $\phi(n)$ - which means it wouldn't be mental poker anymore. $\endgroup$ – Stefan Jul 6 '17 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.