You glance at your phone, it flashes for an instant and the screen unlocks. The comfortable explanation is that the handset “recognises your face”, as if it compared one photograph with another. It does not compare flat images at all: it projects a pattern of thirty thousand dots of infrared light onto your face, measures how that pattern deforms as it hits your nose, cheekbones and eye sockets, and builds a three-dimensional depth map. Only then does it decide whether that geometry matches the one it stored the last time you set the phone up.
That shift — from image to relief — is what separates a toy face unlock from a biometric system a bank will accept as an authentication factor. It also explains why a printed photo, a video or even a well-made mask is not enough to fool it.
The trouble with seeing the world in two dimensions
A conventional camera records light intensity per pixel. Flattening that information onto a plane loses the third dimension: a real face and a photograph of that face, held at the right distance and under the right lighting, produce almost identical images. Early software-only face unlock systems fell into that trap easily, which is why many manufacturers demoted them to a convenience feature with no security value.
Recovering depth requires adding new information. There are two families of solutions. The first is stereoscopic: two cameras separated by a known baseline plus triangulation, much like our eyes. It works well on richly textured surfaces but struggles with smooth ones and in low light. The second is structured light: instead of waiting for the world to light itself, the device illuminates it with a pattern it knows in advance and watches how that pattern deforms. This is what the front camera of iPhones has used since 2017, and what we find, in variations, in many high-end Android phones and industrial scanners.
A projector that draws invisible dots
The key component is a dot projector built on an array of VCSEL lasers (vertical-cavity surface-emitting lasers), tiny near-infrared emitters typically around 940 nanometres. That wavelength has two advantages: it is invisible to the human eye, so it does not distract, and it passes reasonably well through skin and most glasses, though not all of them.
In front of the emitter sits an optical element — a lens with an etched pattern, or a diffraction assembly — that replicates the beam into thousands of dots and spreads them pseudo-randomly. It is not a regular grid: an irregular pattern avoids ambiguity, because each dot can be identified by its neighbourhood rather than by its position alone. The result is a constellation of roughly thirty thousand dots falling on the face like an extremely fine drizzle.
An infrared camera, placed at a known distance from the projector, captures that constellation. Here is the geometric trick: if the face were flat, every dot would appear exactly where the projector’s geometry predicts. With relief present, the dots shift sideways in the image, and that shift — the disparity — is proportional to depth. Using the distance between emitter and sensor as a triangulation baseline, the system turns every pair of dots into a three-dimensional coordinate. The process repeats in milliseconds and yields a point cloud, not a photograph.
The same module includes a flood illuminator, which emits infrared without a pattern to obtain a clean 2D image even in the dark, and sometimes a proximity sensor. Combining the 2D image with the depth map produces what engineers call a 2.5D representation: texture and relief aligned pixel by pixel.
From point cloud to decision
The comparison is not made against a stored photo. During enrolment the phone captures several poses, computes a facial model — a reference mesh with relative distances between eyes, nose, mouth and outline — and derives from it a compact mathematical representation, a biometric template. The face is not stored as an image, only those descriptors.
On every unlock, the system projects, captures, corrects for pose and extracts the same descriptors. It then computes a distance between the freshly obtained vector and the stored one. If it falls below a threshold, it authenticates. The threshold is not arbitrary: it is calibrated so the false-positive rate is extremely low. Apple puts the odds of a different face passing for the owner’s at roughly one in a million, against one in fifty thousand for the fingerprint reader of earlier generations; these are manufacturer figures rather than independent audits, but they convey the order of magnitude being targeted.
The model adapts with use: every successful unlock, followed by entering the passcode, supplies examples that refine the template and absorb gradual changes such as a beard, a haircut or new glasses. That adaptation is useful and at the same time a risk: an attacker who managed to lock the system with their own face could, in theory, train it. Hence failed attempts are strictly limited and the passcode always remains the master key.
The enclave: where your face never leaves home
All this arithmetic happens in a subsystem isolated from the main processor, the Secure Enclave: a coprocessor with its own verified boot, encrypted memory and a dedicated cryptographic engine. The operating system and applications cannot read the template; they only receive a boolean answer — match or no match — through a very narrow interface. The infrared image is processed and discarded. This separation is what allows a bug in an application not to expose biometric data, which moreover counts as a special category under the European General Data Protection Regulation.
The design includes countermeasures against physical and replay attacks: attempt counters, increasing delays, temporary sensor lockout, and the obligation to enter the passcode after several failures or after a reboot. The passcode is not a mere backup: it is the boot secret from which the keys protecting the template are derived, so without it the encrypted data is indistinguishable from noise.
Why a mask is not enough (and why sometimes it is)
Liveness checking relies on several signals at once. Depth rules out a flat photo. Infrared rules out a screen emitting only visible light. Skin texture and the response to different wavelengths rule out much of the silicone mask market, although researchers have shown that high-quality resin masks, with eye sockets and proper paint, can fool some systems if attention is not required.
That is why the most recent models demand attention: detecting that the eyes are open, that they look towards the screen and that the gaze does not wander. It is a simple and highly effective defence against the most common case, which is not a laboratory attack but someone picking up a sleeping person’s phone and pointing it at their face. Distance is also checked — the useful range is roughly 25 to 50 centimetres — and the device refuses if there is too much direct sunlight, whose infrared floods the sensor.
Identical twins remain a borderline case, and sunglasses with an infrared filter can block the reading. None of this is magic: it is a chain of sensors, geometry and statistics in which every link adds a barrier and every convenience subtracts a little rigour. When the system fails and asks for your passcode, it is not broken: it is being honest about what it was able to measure.
Next time the screen lights up on its own as you look at it, think about what has just happened: thirty thousand dots of invisible light bounced off your face, a camera measured their deviations and a hardened processor compared that geometry with a numerical memory of you. All in less time than it takes you to blink.






