A lot of you commented "GATE" on the reel about designing the passport e-gate. Here's the full breakdown I promised: how I'd answer it in a system design interview, with everything a 70-second reel had to leave out, and every claim linked to a public source.


The question: "Design the passport e-gate."

You've stood in one. Passport open on the reader, glass door in front of you, a camera at eye level, a queue behind you. A few seconds later the doors open and you're through.

Most people picture the obvious system: a camera that looks at your face and searches a database of millions of faces to find out who you are. It sounds right. It's also the wrong design, and an interviewer will push on it straight away:

  • A database of every traveller's face is a huge privacy and security target.
  • Searching millions of faces for every person at every gate is slow and expensive.
  • The bigger the database, the more chances there are for a wrong match.

The real e-gate doesn't do that. It never searches for you. It checks you against one photo that you carried in with you.

If you only remember one line from this post, make it this one:

Don't search for the user. Verify what they carry.

The rest of this post explains how the gate does it, and why that pattern shows up all over system design.


Start with questions, not boxes

Before drawing anything, I'd spend a minute pinning the problem down:

  • What is the gate actually deciding? Not "who is this person?" but "is this person the rightful holder of this passport, and is this passport genuine?"
  • Who can use it? Only holders of chipped e-passports from eligible countries. Everyone else goes to an officer.
  • What happens on any failure? The gate never "lets someone through anyway". A failed check means the doors stay shut and a human takes over.
  • What else must be checked? The person's details against a watchlist. (This matters later, so keep it in mind.)
  • How fast? Seconds per person, at a busy airport, all day.

The first answer changes everything. "Who is this?" is a search problem. "Is this the passport's owner?" is a verification problem. They need completely different designs.


The core idea: one-to-one, not one-to-many

Not a search: one-to-one. Left, 1:N identification compares a live face against a grid of many faces. Right, 1:1 verification compares the live camera face with the one photo on the passport chip.

Biometrics has two very different jobs:

  • One-to-many (1:N), identification: "Here's a face, who is it?" You compare it against everyone in a database.
  • One-to-one (1:1), verification: "Here's a face, is it the person they claim to be?" You compare it against one reference.

NIST, the US standards body, defines one-to-one as biometric verification where the captured data "is compared with that of one, claimed, identity" (NIST glossary).

The e-gate is a 1:1 system. The UK Border Force's own description of an ePassport gate: an "Automated gate which uses facial recognition technology to compare the user's live photo image to the image held in the biometric chip contained in their passport" (ICIBI inspection, 2022).

So the reference photo travels with you, inside the passport. The gate doesn't need a face database at all to answer its question.

Why that's the better design:

1:N search 1:1 verify
Needs a central face database Yes No
Work per traveller Grows with the database One comparison
Chance of a wrong match Grows with the database One comparison's error rate
Privacy exposure Every face, always Your face, at the gate, against your own photo
Works if the network is slow Needs the database The reference is in your hand

The flow, step by step

The e-gate flow: read the photo page, unlock the chip, read the chip, check the country seal, live photo and liveness, watchlist, then open or hand to an officer

Here's what happens between "passport on the reader" and "doors open". Every step below comes from the ICAO e-passport standard (Doc 9303) or the UK inspector's report on ePassport gates.

1. Read the photo page. The gate reads the printed data page first, including the two lines of letters and chevrons at the bottom (the machine-readable zone, or MRZ). The UK inspection report: "The gates work by reading the biodata page in the passport and opening the chip in the passport to read the data it contains."

2. Use the printed page as the key to the chip. The chip won't hand over its data to just anyone. ICAO recommends that states use access control where the reader proves it knows information "retrieved optically/visually from the eMRTD (e.g. from the MRZ)" (Doc 9303 Part 11). In plain words: you have to be holding the open passport to read the chip, which stops someone skimming it from across a room. (It's a "should" in the standard, so most passports do this, not all.)

3. Read the chip. Every e-passport chip must carry two things: a copy of the MRZ data (Data Group 1) and your face (Data Group 2). ICAO: the minimum mandatory data "SHALL be a duplication of the machine readable zone data in Data Group 1 and the holder's facial image in Data Group 2" (Doc 9303 Part 10).

4. Check the country's seal. More on this in the next section. It's what makes the photo trustworthy.

5. Take a live photo and compare. The camera captures you, and the software measures both faces. From the UK report: the algorithm "matches the live image of the passenger at the gate with the image stored on the chip... by pinpointing and measuring facial features... There is a matching threshold above which the passenger is deemed to be the rightful holder." The gates also run "liveness" checks, so a printed photo held up to the camera doesn't work.

6. Check your details against a watchlist. This is the part people miss. The face check is 1:1, but your name and details are still searched: "every passenger's biographical details stored on their passport chip are checked against the watchlist." That's a lookup on text data, not a face search.

7. Open, or hand over to a human. "The gates will open if the passenger and their document pass a number of tests. If the passenger fails any of the tests, they will not be allowed through and must be processed in the normal way."

A good interview answer names step 6 out loud. It shows you know where the 1:1 design stops.


The twist: what if someone swaps the photo on the chip?

The chip is signed by your country: Country Signing CA signs the Document Signer, which signs the hashes; a swapped photo no longer matches the signed hash

This is where the interviewer pushes. If the gate trusts the photo on the chip, couldn't a forger just put their own photo on someone else's passport chip?

No, because your country signs the chip.

The chip holds a Document Security Object (EF.SOD). It "consists of the hashes of the Data Groups used" and "is digitally signed by the issuing State" (Doc 9303). A hash is a short fingerprint calculated from the data: change one pixel of the photo and the fingerprint changes completely.

The gate checks it like this (ICAO calls it Passive Authentication):

  1. The gate already holds each country's Country Signing CA certificate, the root of trust for that country's passports.
  2. It checks that the Document Signer certificate on the chip was issued by that country's root.
  3. It verifies the signature over the security object.
  4. It hashes the photo and data it just read, and compares them with the signed hashes. ICAO: the inspection system "SHALL ensure that the contents of the Data Group are authentic and unchanged by hashing the contents and comparing the result with the corresponding hash value".

Swap the photo and step 4 fails: the hash no longer matches the signed one, and you can't re-sign it without the country's private key. No entry.

"But what if I copy someone else's real chip?"

Good follow-up, and the honest answer is in the standard itself. Passive Authentication "does not prevent exact copying of the contactless IC's content or chip substitution."

So a perfect copy of a genuine chip would pass the signature check. What stops it is step 5: a copied chip carries the original owner's face, not yours. The 1:1 face check fails. Some countries also add an extra layer (Active or Chip Authentication, where the chip proves it holds a secret key that can't be copied), but the face check is what makes the copy useless at a gate.

That's a lovely interview moment: each layer covers the gap in the other.


The pattern to take into any interview

The pattern: issuer signs, holder carries, verifier checks, for e-passports, signed login tokens and TLS certificates

Strip away the passport and you get a pattern that appears everywhere:

A trusted issuer signs a credential. The holder carries it. The verifier checks the signature and the holder, without looking anything up.

  • E-passport: the country signs the chip; the gate verifies the signature and your face.
  • Signed login token (like a JWT): the auth server signs the token; any service verifies the signature with the issuer's public key, without calling a database on every request.
  • TLS certificates: a certificate authority signs a site's certificate; your browser verifies it against roots it already trusts.

Same trade-offs every time:

  • Fast and scalable: verification is local. No central lookup on the hot path.
  • Private: the verifier doesn't need everyone's data.
  • The weak spot is revocation. A signed credential stays valid until it expires, unless the verifier also checks a revocation list. For passports that's the lost and stolen documents check; for tokens it's short expiry times or a deny list.

If an interviewer asks you to "design login for millions of services" or "verify tickets at a stadium without network", this is the same answer.


Failure modes I'd mention

  • No match or low score: doors stay shut, officer takes over. Never "retry until it passes" without limits.
  • Chip unreadable or signature fails: treat as a failed document, officer takes over.
  • Unknown or expired country certificate: the gate can't trust the seal, so it can't verify the passport. Keeping the country certificate store up to date is a real operational job.
  • Spoof attempts (photo, mask, screen): liveness checks at capture.
  • Watchlist hit: a hard stop, routed to an officer.
  • The queue itself: if gates fail too often, the "fast lane" becomes the slow lane. Match thresholds are a trade-off between letting the wrong person through and rejecting the right one, and the UK inspection report spends pages on exactly that tuning.

The rule across all of them: the gate can only say yes automatically. Every "no" or "not sure" goes to a human.


What's changing: contactless gates

Some newer gates don't need you to put your passport on a reader at all. The UK government describes contactless travel that "verifies someone's identity without requiring a passport to be placed on an eGate reader" (gov.uk). The page doesn't say what reference image those gates compare you against, so I won't guess. Everything in this post describes the standard ePassport gate that reads your chip.


Questions they'll ask next

  • "Why not just use a central face database? It would be simpler." Simpler to draw, worse to run: a giant privacy target, slower, more wrong matches as it grows, and a single point of failure.
  • "How does the gate know the country's public key?" It stores each country's signing root certificate in advance. ICAO runs a Public Key Directory so countries can share them.
  • "What stops a perfect copy of a chip?" The face check (the copy has the owner's face), plus optional chip authentication.
  • "Where is it still one-to-many?" The watchlist check on your details.
  • "How would you set the match threshold?" Measure false accepts and false rejects on real traffic, choose the point the border agency can live with, and keep monitoring by demographic group, since face matching accuracy isn't equal for everyone.

The 60-second version

"The gate doesn't identify you, it verifies you. Your passport chip carries your photo, signed by your country. The gate reads the printed page, uses it to unlock the chip, checks the country's signature over the photo's hash, then compares a live photo of you with that one photo: one-to-one, not a search. Your details are still checked against a watchlist. Any failure goes to an officer. The general pattern: don't search for the user, verify a signed credential they carry. It's the same idea as a signed login token."


A checklist to take into the interview

  • Ask what the system is deciding: identify, or verify?
  • Say "one-to-one, not one-to-many" and why it matters (no face database, speed, fewer wrong matches, privacy).
  • Walk the flow: printed page → unlock chip → read photo → check signature → live photo + liveness → compare → watchlist → open or officer.
  • Explain the signature chain: country root → document signer → signed hashes.
  • Handle the copied-chip question: the copy has the wrong face.
  • Name where it's still a search (the watchlist).
  • Every "no" goes to a human.
  • Generalise: issuer signs, holder carries, verifier checks.

Sources

  • ICIBI, An inspection of ePassport gates (June 2020 to January 2021), published January 2022: assets.publishing.service.gov.uk
  • ICAO Doc 9303 Part 10, Logical Data Structure: PDF
  • ICAO Doc 9303 Part 11, Security Mechanisms: PDF
  • NIST CSRC glossary, one-to-one: csrc.nist.gov
  • gov.uk, contactless travel using eGates: gov.uk
  • gov.uk, faster travel through the UK border: gov.uk

Passport images in the reel and this post use ICAO's official specimen ("Utopia"), not a real person.