RSA key generation basics

Learn Algorithms · 2:34

Listen on 93

Lyrics

[Verse 1]
Step one in the crypto game, we need two primes that ain't the same
P and Q, they gotta be large, random numbers taking charge
Keep em secret, keep em safe, computational power we chase
Miller-Rabin test will show, if they're prime then we can go

[Chorus]
Prime times Prime equals N, that's the modulus my friend
Phi of N is P minus one, times Q minus one, we're having fun
Choose your E, make it small, sixty-five oh thirty-seven for all
GCD with phi must be one, then the magic has begun

[Verse 2]
Public exponent E we pick, with phi it cannot click
Greatest common divisor stays at one, that's how we know we're not done
Seventeen or three will do, as long as they're coprime it's true
This becomes our public key, paired with N for all to see

[Chorus]
Prime times Prime equals N, that's the modulus my friend
Phi of N is P minus one, times Q minus one, we're having fun
Choose your E, make it small, sixty-five oh thirty-seven for all
GCD with phi must be one, then the magic has begun

[Bridge]
Extended Euclidean time, finding D is so sublime
E times D mod phi equals one, private key computation done
If the result comes negative, add phi back, that's the trick
Now we got our secret sauce, without P and Q we're lost

[Verse 3]
Public key is E and N, share with everyone again
Private key is D alone, guard it well, it's yours to own
P and Q must disappear, factoring N we always fear
If someone breaks our modulus down, our security hits the ground

[Outro]
Generate, validate, calculate, encrypt the data state
RSA algorithm flow, now you know the way to go
Keep those primes forever hidden, that's the rule that can't be ridden
Asymmetric crypto king, that's the song that we all sing

← Modular exponentiation | Radix sort →