I'm simplifying a lot here, but if you connect to a website, say google.com, that needs to be resolved to an IP Address. Your PC asks your ISPs DNS server "which IP is google.com". That server says "Idk, but the server for the .com tld is over there".
So then you ask the .com DNS server "who is google.com" and that server says "Idk, but the server for google.com is over there". You then ask the server responsible for google.com for the IP address, and get back something like 80.230.56.122.
Now how do you actually make sure that 80.230.56.122 is actually google.com and not just someone claiming to be Google.com.
That's where Public Key Cryptography comes in. Essentially 80.230.56.122 has to first prove that it's actually Google.com. It does that to trusted certificate authorities (CAs), like Let's encrypt, DigiCert, GlobalSign or Sectigo. You do that by controlling the DNS entry, meaning you own the domain. The CA asks you to put a certain value on your server, say google.com/challenge/16272515/value.txt and if the CA can reach it asking DNS for that value it proves that you control the domain. Then they give google.com a certificate.
A certificate consists of a private and public key pair. The public key is, well, public, and the private key stays on Googles servers. If you sign something with a private key, by knowing the public key you can prove that it has been signed with that private key without knowing the actual private key. That is, Google can prove that they own the certificate. But how do you know that the public key actually belongs to Google, and that certificate is valid?
Well certificates are signed with the CAs private key, proving that the CA actually signed them. This certificate "chain" ends in "root" certificates whose private keys are physically stored behind incredibly secure layers in incredibly secure locations, and whose public keys are distributed with OSes and browsers. Any time you connect to a website, that chain is followed back to a trusted root certificate, proving that you connect to the real website. Each individual certificate in the chain is vouched for by the next one up, until you reach the known, trusted "root".
Recently, the private keys of a CA called eMudhra have been leaked, meaning you could sign fake certificates.
Normally, private keys for something like elliptic curve Cryptography are at least 256bits long, so a number between 0 and 2256. This makes it impossible to guess a corresponding private key.
eMudhras private key was the number "4". They also had 7 other certificates leaked with numbers in the low 100s. Ten thousand times that is still WAY too low of a number for a private key.
Not quite. What you're thinking of is part of RSA key generation, and even with RSA the private key itself is not limited to prime numbers. The eMudhra incident involved NIST P-384 elliptic curve cryptography.
The private key having to be prime would substantially limit the amount of valid keys, which defeats their purpose.
The math for key generation, signing and validation stays the same, regardless of how small the actual numbers are. In the end, it's all just bits. NIST P-384 private keys have a length of, well, 384 bits. The number 4 as a private key is 381 zeroes, then a one, then the last two zeros again. You can plug that into the elliptic curve math like any other key with any other bits set.
Here is a video explaining how elliptic curve cryptography works.
Keep in mind, the curves that are used are way more complicated in real life. The names given to the cryptography method, like NIST P-348 refers to the different curves used, the math is the same.
View all comments
Show parent comment
58
u/Ragnor_ Oct 24 '26 edited Oct 24 '26
I'm simplifying a lot here, but if you connect to a website, say google.com, that needs to be resolved to an IP Address. Your PC asks your ISPs DNS server "which IP is google.com". That server says "Idk, but the server for the .com tld is over there".
So then you ask the .com DNS server "who is google.com" and that server says "Idk, but the server for google.com is over there". You then ask the server responsible for google.com for the IP address, and get back something like 80.230.56.122.
Now how do you actually make sure that 80.230.56.122 is actually google.com and not just someone claiming to be Google.com.
That's where Public Key Cryptography comes in. Essentially 80.230.56.122 has to first prove that it's actually Google.com. It does that to trusted certificate authorities (CAs), like Let's encrypt, DigiCert, GlobalSign or Sectigo. You do that by controlling the DNS entry, meaning you own the domain. The CA asks you to put a certain value on your server, say google.com/challenge/16272515/value.txt and if the CA can reach it asking DNS for that value it proves that you control the domain. Then they give google.com a certificate.
A certificate consists of a private and public key pair. The public key is, well, public, and the private key stays on Googles servers. If you sign something with a private key, by knowing the public key you can prove that it has been signed with that private key without knowing the actual private key. That is, Google can prove that they own the certificate. But how do you know that the public key actually belongs to Google, and that certificate is valid?
Well certificates are signed with the CAs private key, proving that the CA actually signed them. This certificate "chain" ends in "root" certificates whose private keys are physically stored behind incredibly secure layers in incredibly secure locations, and whose public keys are distributed with OSes and browsers. Any time you connect to a website, that chain is followed back to a trusted root certificate, proving that you connect to the real website. Each individual certificate in the chain is vouched for by the next one up, until you reach the known, trusted "root".
Recently, the private keys of a CA called eMudhra have been leaked, meaning you could sign fake certificates.
Normally, private keys for something like elliptic curve Cryptography are at least 256bits long, so a number between 0 and 2256. This makes it impossible to guess a corresponding private key.
eMudhras private key was the number "4". They also had 7 other certificates leaked with numbers in the low 100s. Ten thousand times that is still WAY too low of a number for a private key.