Security • 2026-09-24 • 3 min read
How We Designed the Wident Security API: mTLS, Ed25519 and Sub-2ms Latency
A security API becomes a bottleneck the moment token verification is slow, because everything waits on it. The design decisions that kept validation under two milliseconds.

A security API sits in front of everything else, which means its latency is added to every request in the system. Ours validates tokens, answers IAM audit questions and serves CVE data. The budget we set was two milliseconds at p99 for validation, and that number shaped every decision below.
Ed25519 rather than RSA
Signature verification is the hot path. Ed25519 verification is roughly an order of magnitude faster than RSA-2048, the keys are 32 bytes, and there are no parameters to get wrong — no padding mode, no curve selection, no key size debate. Fewer choices is itself a security property.
verifying_key
.verify_strict(message, &signature)
.map_err(|_| AuthError::InvalidSignature)?;verify_strict rather than verify: it rejects small-order points and the malleable encodings that let the same message carry two valid signatures. The difference never shows up in testing and matters when someone is trying.
Keys in memory, with a bounded refresh
Fetching a public key per request would make the datastore the latency floor. Keys live in an in-process cache with a short TTL and a background refresh, so a rotation propagates within seconds and no request waits on the fetch.
Cache the *absence* of a key too, briefly. Otherwise a flood of requests citing an unknown key id becomes a flood of datastore lookups, which is a cheap denial-of-service against your own backend.
Decisions precomputed, not evaluated
Policy evaluation was the second-largest cost. Rather than walking a policy tree per request, we compile each principal's effective permissions into a bitset when the policy changes, and a check becomes a bitwise test. Policy changes are rare; checks are constant. Moving work to the rare side of that ratio is most of the performance story.
Graviton
ARM64 instances gave us about 30 percent better price-performance on this workload than the equivalent x86, and a Rust binary cross-compiles to it without ceremony. The only friction was a C dependency in the build that needed its own toolchain — which we removed, and which we would have wanted to remove anyway.
What we measure
- Verification latency at p50, p99 and p99.9, separately from total request time
- Cache hit rate on keys, alerting when it drops rather than when latency rises
- Failed verifications by reason, which is both an operational and a security signal
- Clock skew between the signer and the verifier, because a replay window that is tighter than your skew rejects honest traffic
The part that is not about speed
Every rejection returns the same response shape and the same timing. An API that answers "unknown key" faster than "bad signature" tells an attacker which of the two they got wrong, and that is enough to turn guessing into searching. The constant-time comparison inside the crypto library is necessary and not sufficient; the surrounding control flow has to agree.
Request signing is covered in more detail in the Ed25519 signing article, and the transport layer in mTLS with rustls.