Engineering & Architecture Brief Published: 2026-11-15
A CKKS gallery that scores cosine similarity as a plain inner product works only while every enrolled 512-dimensional embedding has unit L2 norm. When one enrollment channel began submitting unnormalized vectors, a handful of identities started surfacing as the top candidate for probes they had nothing to do with. Nothing in the homomorphic pipeline failed. The arithmetic was exact to within its precision budget, and it faithfully computed the wrong quantity.
What the operators saw The first signal was statistical, not an alarm: in the 1-to-N search logs, a small set of gallery slots appeared as the best match for unrelated probes far more often than chance allows, and the scores they returned sat just above the decision threshold. Verification traffic, the 1-to-1 path, looked mostly healthy, which pointed people at the search index and the rotation-and-sum kernel first. Both were fine. Decrypting the per-slot scores for a controlled test set showed that the offending templates scored high against everyone, which is the signature of a vector whose magnitude, not its direction, is driving the result. In embedding spaces this behaviour has a name, hubness, and encryption had made it invisible until the decision layer exposed it.
Trigger versus assumption The trigger was mundane: a capture SDK update on one enrollment channel moved L2 normalization out of the client library and into an optional post-processing call that the integration never invoked. That is the event, and it is a reasonable thing for a vendor to change. The underlying assumption is the part worth writing down in the postmortem: the matcher's design treated unit norm as a property of the data, when it was really a convention enforced in exactly one place, on the client, before encryption. Once a template is encrypted, the server cannot inspect it, so the invariant lost its only observer the moment the ciphertext left the device. With a 40-bit scaling factor and inner products bounded by 1, the parameter set was sized for scores in a known range, and an embedding with a norm well above one stretched every score it touched while still decrypting cleanly. No noise overflow, no failed bootstrap, no error path to catch it: the scheme did what CKKS does, approximate arithmetic on whatever you give it.
What keeps the search honest when one channel drifts The fix that held was moving the invariant check to a point where the property is still observable: at enrollment, the server computes the encrypted squared norm with one ciphertext multiplication and a rotation sum, and the key holder decrypts only that scalar and rejects anything outside a tolerance band, which leaks a single number about a template the system already knows belongs to the enrollee. Each template now carries the extractor model identifier and the normalization version in its metadata, so a channel that changes either is quarantined from the shared gallery rather than mixed into it. Computing true cosine under encryption, with a homomorphic inverse square root, was evaluated and rejected for the hot path, because the polynomial approximation costs extra multiplicative depth on every probe to defend against a fault that a one-time enrollment check catches. As an estimate, the enrollment check adds well under a tenth of the cost of a single full gallery scan, and it fails closed. The template protection requirements in biometric standards such as ISO/IEC 24745 were never in tension with this: irreversibility and unlinkability constrain what the server learns about the template, and a bounded norm attestation stays inside that envelope.
The decision rule that came out of this is simple to apply: any property the match score depends on, whether norm, model version or quantization, must be either verified at the last point it is visible or made irrelevant by the encrypted computation itself, and if neither is affordable it has to be monitored in the decrypted score distribution as a known unguarded assumption.
Technical FAQ: Why not just normalize the vector homomorphically on the server for every enrollment? You can, but CKKS has no exact division or square root, so normalization means a polynomial approximation of the inverse square root over an assumed input range. If the incoming norm falls outside that range, the approximation silently diverges, which reproduces the original failure one layer deeper. Checking the norm and rejecting out-of-band templates is cheaper and fails visibly, and the remaining cost is operational: a broken enrollment channel now produces rejections that someone has to triage instead of corrupting search results that nobody sees.