Keygen
Encrypt
Decrypt
Util
Help
Your private key is your choice of number in (1, (P-1) / 2). Make sure you copy and paste this and keep it safe. If you lose it, not even Alan Turing can get it back!
 
The public key is derived from the private key.
Place someone's public key here to encrypt with it. It can only be decrypted with the matching private key.
Message to encode:
The plaintext message is this number:
The ciphertext is TWO numbers, separated by a comma. Note that encryption involves randomness, so it will be different each time even with the same inputs.
Your private key; the same number you used to generate your public key in "Keygen."
 
The ciphertext to decrypt. This should be two big numbers, separated by a comma.
The resulting plaintext is this number:
Decoded as base-100:
In here you can sort or shuffle lines. Sorting happens by numeric value (2 < 10). Word wrap is disabled so it's clearer where the lines end.


Math emergencies only: Check whether a number is a quadratic residue mod P. This means that it is of the form n2k for some k. Half the numbers in the group are residues. In this Santa setup, all public keys are quadratic residues, because we always use an even private key (it is multiplied by 2 behind the scenes).
 
Secret Santa protocol by Tom 7!

Phase 1

Decide on an ordering for the players P1, P2, ... Pn. The player Pn is the distinguished "Chair." They have a special job so it should be someone who knows how to do this right! The Chair starts things off:

The Chair

On the keygen tab, the Chair generates a session key pair. This consists of a private key and a public key. Both of these are just numbers. They copy the session private key somewhere safe, and write down that it's the session key so that they don't mix it up with something else. They publish the session public key to the e-mail thread for everyone to see.

Everybody

Everybody generates a personal key pair, which they do on the keygen tab. They copy their personal private key somewhere safe, noting that it's their own private key (keeping it straight from the session key, for example). They never share this. The public key is a pseudonym, so revealing it outside the protocol would give away your identity and is forbidden! Thrilled to be following such strict rules, the players get excited to participate in the chain mail, if they want.

Chain mail

The goal of the chain mail is to get all of the public keys to the Chair without the Chair knowing who anybody is. All the personal public keys shared at this point are encrypted with the session public key.

A player can encrypt their key on the encrypt tab. The keys are just numbers, so you need to encrypt them as numbers (the box on the right) not as base-100 text (the box on the left). Use the session public key in the box on the top, and paste your personal public key in the box on the right. The encrypted key is the pair of big numbers separated by a comma in the box on the bottom.

P1 sends the first message. A message is sent privately from one person to the next, in the order decided upon at the beginning. The message contains the set of encrypted public keys. For Player Pk, they see encrypted keys from P1, P2, ... Pk-1. The player adds their own encrypted key, and shuffles the list (perhaps using the util tab). They pass (only) the list to the next player.

If a player breaks the e-mail chain then the dead girl comes out of the TV, which is really bad news. Don't let that happen!

The Chair, Pt. 2

The chair receives the list of the encrypted keys last. They can add their encrypted key to the list if they want to feel what it's like to be a regular participant, but there's not much point because their next job is to decrypt each of the encrypted keys to get the public keys for each player. They do this on the decrypt. They decrypt each message individually, always using the session private key. The decrypted personal public keys are the numeric plaintexts, not the base-100 decoded "message," which should look like gibberish unless hackers are afoot.

Once the Chair has all the decrypted public keys, they add their personal public key to this list and sort it numerically in ascending order (perhaps using the util tab). They publish this list of numbers to the e-mail thread for everyone to see.

We are done with the session key now, and the Chair no longer has a special role. Everything else happens with the personal keys.

Phase 2

Everybody

Next, everybody needs to make sure their public key is part of that list. They shouldn't ever reveal which one is theirs. They should just say something like "Looks good!" or "Mine isn't on the list!" If the Chair is competent and nobody is messing around, then everybody's public key should be on that sorted list, and the number of keys should be correct as well.

Informing your Santa

Each player should find their own public key in the list. The entry before them is their Santa. (The first entry wraps around to find their Santa as the last entry.) They don't know who this is, but they can send them a message.

Using their Santa's public key, the player encrypts a text message. They do this on the encrypt tab, this time using the text (base 100) entry form. The message should contain the player's own name and mailing address (or other instructions, like P.O. box, etc.). It can also contain hints about what you like, or holiday cheer. They publish (only) the encrypted message to the e-mail thread. They don't mention the public key (this would give away their own identity).

Becoming Santa

Each participant sees all of these encrypted messages on the thread. They try decrypting each one using their own personal private key on the decrypt tab. All but one of these will "decrypt" to gibberish, but one should contain the message from their Santee.

As a final check: Only after all the messages have been sent, participants should check that there are n messages, and everybody should confirm that they decrypted exactly one message.