Apex › Cryptography
Dividing mod m (extended Euclid & the modular inverse)
You can’t divide mod m, but you can multiply by an inverse — and the extended Euclidean algorithm computes it. Euclid’s gcd runs dividend = q·divisor + remainder down to the gcd; the extended version carries coefficients with the same quotients so it also returns x, y with a·x + m·y = gcd (Bézout). When gcd(a,m)=1, a·x + m·y = 1 ⇒ a·x ≡ 1, so x is a⁻¹ mod m — exactly how RSA computes d = e⁻¹ mod φ(n). Verified in node: a·x + m·y = gcd for all pairs, and a·a⁻¹ ≡ 1 across 12230 inverses. Invert a number mod m and watch the chain run.
More in Cryptography
- Cryptography
- Classical ciphers
- One-time pad
- AES internals
- ECB penguin / modes
- Feistel / DES
- CTR & AEAD
- ChaCha20
- Poly1305 MAC
- Timing attacks
- SHA-256 internals
- Broken hashes
- Length-extension attack
- HMAC
- Padding oracle attack
- Montgomery multiplication
- How public-key crypto works
- RSA
- Is this number prime? (Miller–Rabin)
- Finding a factor by accident (Pollard’s rho)
- One number, many remainders (Chinese Remainder Theorem)
- Elliptic curves
- Exponentiation that doesn’t leak (Montgomery ladder)
- ECDSA & nonce reuse
- Square roots mod a prime (Tonelli–Shanks)
- EdDSA (Ed25519)
- Pedersen commitment
- Blind signatures
- Verifiable random function
- Oblivious transfer
- Compute on secrets (Yao garbled circuits)
- Hiding what you access (Path ORAM)
- Fetching a record privately (PIR)
- Homomorphic (Paillier)
- ElGamal encryption
- Zero-knowledge (Schnorr)
- One signature for a thousand signers (BLS aggregation)
- Proving a huge sum cheaply (sumcheck)
- A clock you can’t rush (verifiable delay function)
- Diffie–Hellman
- Cracking a discrete log (baby-step giant-step)
- DH man-in-the-middle
- TLS downgrade
- How HTTPS secures a connection
- Password hashing
- Post-quantum (LWE)
- How LLL reduces a lattice (& breaks crypto)
- NTT (Kyber engine)
- Quantum key (BB84)
- Secret sharing
- Envelope encryption (KMS)
- Verifiable secret sharing
- Threshold signatures
- Proof of Work
- Double Ratchet
- X3DH key agreement
- MLS / TreeKEM (group messaging)
- Merkle tree
- A whole set in one number (RSA accumulator)
- Lamport signatures
- Hash chain