How Key Logins Work and How Search Ranks Pages

Passkeys and SSH keys prove a secret without sending it, and search engines rank pages with TF-IDF, BM25 and PageRank. Both explained with small examples.
Every day you rely on two clever bits of maths without seeing them: the one that lets a website know it is you, and the one that decides which page comes first in a search. Here is how both work, with numbers you can check.
A password is a secret you hand over
With a password, you send the secret itself (inside an encrypted connection) and the server compares it with what it stored. Anyone who copies it, or steals the server's password list, can try it elsewhere.
A key login works differently. Your device makes a pair of keys: a private key that never leaves it and a public key that it gives to the server when you sign up.
Challenge and answer
Open the Public-key login lab and make the classic textbook keys: p = 61, q = 53 and e = 17. The lab works out:
- the public key: n = 3233 and e = 17
- the private key: d = 2753
Now log in. The server sends a fresh random challenge. Your device answers with challenge to the power d, modulo n. The server raises that answer to the power e, modulo n. If the challenge comes back, only the holder of d could have made the answer.
Look at the table of what crossed the network: the public key once, then a challenge and an answer. No secret travels.
- Replay attack: someone records your answer and sends it next time. It fails, because the next challenge is different.
- Wrong key: an answer signed with another private key does not check out.
Real systems use keys of 2048 bits or more, add hashing and padding, and passkeys also check which site is asking. The lab uses tiny numbers so every step fits on the screen.
The Break a small key tab shows why the numbers must be huge: once n is split back into p and q, the private key follows at once. Nine-digit primes fall in a blink in your browser.
How search orders the results
The Search ranking lab has a made-up baking website of twelve pages. Search for sourdough bread and compare three ways of scoring:
- All words (Boolean AND): a page either has every word or it does not. There is no order at all.
- TF-IDF: a word counts more when it appears often on the page (term frequency) and on few pages overall (inverse document frequency). A word found on every page counts for nothing.
- BM25: the method behind many search engines. Each repeat of a word counts less than the one before (the k1 setting), and long pages are pulled down a little (the b setting).
Then raise the PageRank share. PageRank scores pages by links: a page linked from many pages, or from well-linked pages, ranks higher. In the baking site, Bread basics has the most links in, so it climbs.
Try it
Make keys with Pick primes and attack them, then paste a few of your own pages into the Search ranking lab, link them with double square brackets, and see which page wins. While you are at it, a long random passphrase from the Password and passphrase generator is still the best choice wherever a site only offers passwords.