Cryptography: ECDSA

Overview "If you can't explain it simply, you don't understand it well enough" Albert Einstein Elliptic curve cryptography (ECC) and digital signature algorithm (ECDSA) are more complex than RSA or ElGamal but I will try my best to hide the hairy math and the implementation details. Here is the ELI5 version in 18 lines of SageMath / Python code. I use Sage because it provides elliptic curves as first-class citizens (`FiniteField` and `EllipticCurve`) and we can take multiplication operation for granted. [Read More]

Cryptography: ElGamal

Overview "If you can't explain it simply, you don't understand it well enough" Albert Einstein ElGamal is a public key cryptosystem that is used in encryption , digital signature and homomorphic cryptography. Here is my take in 12 lines of Python code: 1 p = 7 2 g = [x for x in range(1, p) if len(set([x**i % p for i in range(1, p)])) == p-1][0] 3 k = 4 4 t = g**k % p 5 m = 6 6 import random 7 r = random. [Read More]

Cryptography: RSA

Overview "If you can't explain it simply, you don't understand it well enough" Albert Einstein RSA (Rivest-Shamir-Adleman) needs no introduction, it is well known and most used public-key cryptosystem that governs our digital lives. Here is my take, a simple implementation in 10 lines of Ruby code that is neither the best implementation nor the most efficient one but is enough for the purpose of this article. 1 p = 7 2 q = 11 3 n = p * q 4 phi = (p-1) * (q-1) 5 gcd = ->(a, b) { while(b ! [Read More]