Lion Cipher Lab
Build the Paillier homomorphic cryptosystem from scratch (and compute on data you cannot see)
- Foundations
- Advanced
- ~90 min
- Free · no account required
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
- Homomorphic encryption
- Paillier cryptosystem
- Miller-Rabin primality testing
- Privacy-preserving aggregation
- Cryptographic failure analysis
Steps in this lab
- The one idea: compute on data you are not allowed to see
- The number theory you need — and a primality test you write yourself
- Generate a Paillier key pair
- Encrypt and decrypt — with fresh randomness every time
- The magic trick: add two numbers you cannot read
- Build the real thing: a private salary-sum across parties
- Failure mode #1: reuse the nonce r and encryption goes deterministic
- Failure mode #2: it is malleable BY DESIGN — so the math alone cannot protect a tally
- Failure mode #3: toy primes are breakable, and what security actually rests on
- How a pro does it better — and where FHE takes over