# RSA key generation: why use lcm(p-1, q-1) instead of the totient ϕ(n)?

As far as I can see, generating a private key from two prime numbers p and q, having calculated n = pq, starts with calculating λ(n) = lcm(p-1, q-1). This is the detailed explanation given in the wikipedia article for RSA, it's also the implementation I've found in most Python cryptography libraries, and, searching through the openssl source code, it's also how they seem to do it, so I'd say this looks like the standard.

So my question is, why do some implementations appear to use ϕ(n) instead, which is simply (p-1)(q-1)? I understand that you can calculate λ(n) = ϕ(n) / gcd(p-1, q-1), so I suppose these two can be equal if p-1 and q-1 are coprime, but what's with the two different implementations?

This way to generate the "private modulo" is used for example in the somewhat popular python program rsatool, it's also mentioned in this popular article detailing how RSA keys are generated, but my problem is, taking the two same prime numbers p and q, these two methods will not generate the same private key, so assuming the former is the proper, standard way, where did this other one come from?

I assume the 1st method is simply the standard since. As pointed out by a comment $$\lambda(n)$$ will always be smaller or equal to $$\phi(n)$$. In RSA, as pointed by Dave Thompsons, $$\lambda(n) \neq \phi(n)$$. $$\lambda(n)$$ possibly leads to faster calculations(?) but what interested me was where that 2nd version came from, and it comes from the original RSA paper, turns out.
• Yes, your second version (with $\varphi$ or $\Phi$ or $\phi$) is the chronologically first published. Notice the other (with $\lambda$) subdivides into $e\,d\equiv1\pmod{\lambda(n)}$ with $0<d<n$ (PKCS#1), or $d=e^{-1}\bmod{\lambda(n)}$ (FIPS 186-4).