How Okamoto–Uchiyama works
Tatsuaki Okamoto and Shigenori Uchiyama's system uses a key of the form p2 × q, and a trick that works modulo p2. Messages have to be smaller than the secret prime p, so they're short compared with the key.
Making the keys
- Pick secret primes p and q, and publish n = p2 × q.
- Pick a base g whose power gp−1 mod p2 isn't 1, and publish it.
- Publish h = gn mod n as well. The public key is (n, g, h).
The L function
Decryption uses L(x) = (x − 1) / p. Raising anything to the power p − 1 modulo p2 leaves a number that's 1 more than a multiple of p, so the division is exact.
Locking and unlocking
- Encrypt a message m smaller than p: pick a random r and send c = gm × hr mod n.
- Work out a = L(cp−1 mod p2) and b = L(gp−1 mod p2).
- Decrypt: m = a × b−1 mod p. The random r drops out, because hp−1 leaves L equal to 0.
The whole thing with tiny numbers
What the puzzle gives you
An Okamoto–Uchiyama puzzle gives a public key (n, g, h) and a ciphertext c. Paste each one into its own box.
Already know p?
If the puzzle hands you the secret prime, fill it in and the worksheet uses it instead of factoring.
Split n into p × p × q
Only p, the repeated prime, is needed to decrypt.
Work modulo p2
Raise c and g to the power p − 1 modulo p2, and apply L(x) = (x − 1) / p to each.
Decrypt: m = a × b−1 mod p
Divide a by b modulo p: multiply by the inverse of b.
Read the message
m is a number, and the puzzle decides how it turns back into words or coordinates. If the puzzle says how the message was encoded, use that reading.
If none of these look like anything
Decryption scrambles everything when even one digit of an input is off, so a wrong input doesn’t give a slightly wrong answer; it gives noise. Recount the digits of each number against the puzzle (the counts are shown next to every box).
If the inputs are right, the message may use a different encoding: the puzzle text usually says which one. Lining the blocks up from the end, or skipping some digits first, helps when a short message is tacked onto something else.
If every digit matches the puzzle and every reading is still noise, you may be using the wrong system. Check that the puzzle really describes this one: what it calls each number, how many public numbers it gives, and how it says the message was locked.