Lion Cipher Lab

Build the Paillier homomorphic cryptosystem from scratch (and compute on data you cannot see)

Why it matters

Almost every system that touches sensitive data faces the same wall: you want to COMPUTE on data you are not allowed to SEE — sum salaries across companies for a benchmark, tally votes without learning who voted how, add up medical counts across hospitals. Homomorphic encryption is the branch of cryptography that makes this possible, and Paillier is the cleanest way to actually feel it working: an untrusted server does arithmetic directly on ciphertext and only the key-holder ever sees a plaintext result. Building it from ~60 lines — then breaking it three ways — gives you the durable,…

What you'll learn

Steps in this lab

  1. The one idea: compute on data you are not allowed to see
  2. The number theory you need — and a primality test you write yourself
  3. Generate a Paillier key pair
  4. Encrypt and decrypt — with fresh randomness every time
  5. The magic trick: add two numbers you cannot read
  6. Build the real thing: a private salary-sum across parties
  7. Failure mode #1: reuse the nonce r and encryption goes deterministic
  8. Failure mode #2: it is malleable BY DESIGN — so the math alone cannot protect a tally
  9. Failure mode #3: toy primes are breakable, and what security actually rests on
  10. How a pro does it better — and where FHE takes over

Open the full interactive lab →