Security

Jacky Hossein: Architecting Zero-KYC User Verification — Delivering High-Assurance OTP SMS on Privacy-First Infrastructure

How to build zero-KYC OTP verification that is still high assurance: RFC 6238 TOTP generation, SHA-256 token hashing, constant-time comparison, attempt budgets, and multi-channel fallback.

JH
Jacky Hossein
β€’ Principal Telecommunications Architect β€’ Published Oct 15, 2026 β€’ 13 min read

The support ticket read: “I never received a code and now my account is locked.” Behind it was a sequence every authentication engineer recognises. The user had requested a code three times, the first had arrived after a routing delay, and the platform had invalidated the earlier codes when the later ones were issued. By the time the user typed the code they could see, the challenge had been superseded twice. The security model was fine. The state machine was not.

Verification is where privacy engineering and security engineering collide most visibly. A privacy-first provider removes the identity documents from the equation, which raises an obvious question: if nobody verified who the user is, how can the login be trusted? The answer is that identity verification and authentication assurance are different problems, and conflating them produces both bad security and unnecessary surveillance.

This article is about the second problem. It covers the threat model an OTP actually addresses, the cryptographic mechanics of generating and validating codes correctly, the attempt budgets and rate limits that stop enumeration, and the fallback ladder that keeps a login flow usable when a message is delayed. It deliberately does not claim that SMS alone constitutes strong authentication — no honest engineer should — and it explains exactly where SMS sits in the assurance hierarchy and how to compensate.

Can OTP verification be high assurance without KYC?

Key Takeaway / Direct Answer

Yes, but only if you are precise about what is being assured. KYC establishes who a person is; OTP verification establishes control of a channel. A zero-KYC system can be high assurance for the second problem by using cryptographically uniform codes, HMAC-SHA256 storage with constant-time comparison, hard attempt budgets, per-number and per-IP rate limits, short expiry windows, and single-use invalidation. What it cannot do is claim identity assurance: NIST SP 800-63B classifies PSTN-delivered out-of-band authenticators such as SMS as restricted authenticators, usable at AAL1 but not acceptable for AAL2 or AAL3, so pair SMS with a phishing-resistant factor when the stakes demand it.

The distinction has a practical consequence. Teams that try to make SMS carry identity assurance end up bolting on document checks, device fingerprinting, and vendor identity databases — an expensive stack that still does not solve the underlying problem. Teams that accept SMS as a possession factor and design the rest of the flow properly get a system that is cheap, private, and genuinely resistant to the attacks that matter: enumeration, replay, brute force, and SIM-swap-driven account takeover when paired with a second factor.

What an OTP actually defends against

A threat model is only useful if it names the adversary. The table below lists what a well-implemented OTP stops, what it partially mitigates, and what it does not address at all. Most production incidents come from the middle column being treated as the first.

Attack OTP effectiveness Required compensating control
Credential stuffing with leaked passwords Effective Attempt budgets and per-account lockout thresholds
Code brute force / enumeration Effective Five-attempt ceiling, single-use codes, short TTL
Replay of a previously valid code Effective Invalidate on first successful use
Real-time phishing relay (user forwards code) Weak Passkey or hardware-backed factor
SIM swap / SS7 interception Weak Second factor plus carrier port-freeze guidance
SMS interception on the air interface Effective Modern networks encrypt signalling; legacy 2G does not

The two “weak” rows are why SMS belongs in a layered flow rather than as the sole factor for high-value actions.

Generating codes: look-up secrets versus TOTP

There are two distinct mechanisms in play and mixing them up is a common source of design error. An SMS code is a look-up secret: the verifier generates a random value, stores a verifier-side record, and compares the submitted value against that record. A TOTP code, defined by RFC 6238 on top of the HMAC-based construction in RFC 4226, is a derived value: both parties share a secret and independently compute the same code from the current time step, so no per-code storage is required. SMS flows need the first; authenticator apps need the second; a good fallback ladder uses both.

Property SMS look-up secret TOTP (RFC 6238)
Where the code comes from CSPRNG on the server HMAC of a counter, both sides
Server-side storage Required (hashed) Only the shared secret
Delivery channel SMS, voice, email Authenticator app or hardware token
Clock skew tolerance Not applicable (absolute TTL) ±1 step typically accepted
Phishing resistance None None (passkeys are required for that)
Typical lifetime 2–10 minutes, single use 30 seconds per step

The implementation below is the SMS path, because that is where the subtle bugs live. Two details are worth calling out before reading it. The code is generated with rejection sampling rather than a plain modulo, because a bare random % 10^6 over a 32-bit range biases the low values and shrinks effective entropy. And the stored value is an HMAC bound to the challenge identifier, so a leaked digest from one challenge cannot be replayed against another.

otp.mjs
Node.js 22
import crypto from "node:crypto";

const DIGITS = 6;
const TTL_MS = 5 * 60 * 1000;                 // challenge lifetime
const MAX_ATTEMPTS = 5;                       // attempts per challenge
const SECRET = process.env.OTP_HMAC_SECRET;   // 32 random bytes, rotated quarterly

// Cryptographically uniform N-digit code via rejection sampling.
export function generateCode() {
  const space = 2 ** 32;
  const max = 10 ** DIGITS;
  const limit = Math.floor(space / max) * max;
  let n;
  do {
    n = crypto.randomBytes(4).readUInt32BE(0);
  } while (n >= limit);                       // discard the biased tail
  return String(n % max).padStart(DIGITS, "0");
}

// Store only a digest, bound to the challenge id.
export function hashCode(challengeId, code) {
  return crypto
    .createHmac("sha256", SECRET)
    .update(`${challengeId}:${code}`)
    .digest("hex");
}

export function verifyCode(challenge, code) {
  if (challenge.consumedAt) return { ok: false, reason: "already_used" };
  if (Date.now() > challenge.expiresAt) return { ok: false, reason: "expired" };
  if (challenge.attempts >= MAX_ATTEMPTS) return { ok: false, reason: "locked" };

  challenge.attempts += 1;

  const expected = Buffer.from(challenge.codeHash, "hex");
  const actual = Buffer.from(hashCode(challenge.id, code), "hex");
  const match =
    expected.length === actual.length &&
    crypto.timingSafeEqual(expected, actual);

  if (!match) return { ok: false, reason: "mismatch" };

  challenge.consumedAt = Date.now();          // single use
  return { ok: true };
}

Three lines in that snippet carry more weight than the rest. crypto.timingSafeEqual prevents an attacker from learning the code one byte at a time through response-timing differences, which a naive string comparison leaks. The length check before it is mandatory, because timingSafeEqual throws on mismatched buffer lengths and an exception is itself an observable signal. And consumedAt converts the challenge into a single-use token, which is what closes the replay window that otherwise stays open for the whole TTL.

Rate limiting and attempt budgets

A six-digit code has a million possibilities, which sounds comfortable until you divide it by the number of attempts an attacker can make. With no limit, a scripted attacker reaches a fifty-percent chance of success in roughly seven hundred thousand requests. That is minutes of work against an unprotected endpoint. Attempt budgets are therefore not a nicety; they are the mechanism that makes a six-digit code safe in the first place.

Control Recommended value Why this bound
Attempts per challenge 5 Caps brute-force success at 5 in 10^6
Challenge TTL 5 minutes Long enough for delayed delivery, short enough to bound exposure
Issuance per number 3 per 15 min Stops SMS-pumping loops and cost amplification
Verification per IP 20 per 15 min Throttles distributed enumeration attempts
Cooldown after lockout exponential, 30s → 1h Penalises repeat offenders without locking out real users
Code entropy 6–8 digits Higher entropy allows a longer TTL for slow corridors

Values are starting points for a consumer login flow. Raise entropy before extending the TTL when delivery in a target market is slow.

Two mistakes are common enough to name explicitly. The first is rate-limiting on the wrong axis: limiting only by IP fails against a botnet, and limiting only by phone number fails against an attacker who spreads across many numbers. You need both, plus a per-account dimension when the account is known. The second is returning distinguishable errors — a response that says “wrong code” for a mismatch but “expired” for a stale challenge hands an attacker a free oracle about which challenges are still live. Return one generic failure to the client and log the specific reason server-side.

The multi-channel fallback ladder

The support ticket from the opening of this article was not a security failure; it was a usability failure caused by a missing fallback path. When a message is delayed, the correct response is not to keep reissuing codes and invalidating the previous ones. It is to offer a different channel against the same underlying challenge state, so that whatever the user eventually receives remains valid.

Tier Channel Trigger Assurance note
0 Passkey / WebAuthn Always offered first where supported Phishing-resistant; the only tier that is
1 Authenticator app (TOTP) Enrolled users Possession factor, no carrier dependency
2 SMS Default for phone-first signup Restricted authenticator; AAL1
3 Voice call with spoken code SMS undelivered after 45–60 s Same PSTN restrictions apply
4 Email link with signed token Voice also fails Different channel; watch for mailbox compromise
5 Manual review / recovery codes All automated channels exhausted Highest social-engineering risk; log and rate-limit

Escalate on delivery failure, never on verification failure. Repeated wrong codes indicate an attacker, and offering more channels to an attacker is the opposite of helpful.

Implementing the TOTP tier is a dozen lines, and it gives users an option that does not depend on a carrier at all. The implementation follows RFC 6238: derive a counter from the current time divided by the step, HMAC it with the shared secret, apply dynamic truncation, and reduce modulo the code space.

totp.mjs
RFC 6238
import crypto from "node:crypto";

// RFC 6238 TOTP over HMAC-SHA1, the interoperable default for
// authenticator apps. Pass step/digits explicitly if your app differs.
export function totp(secret, at = Date.now(), step = 30, digits = 6) {
  const counter = Math.floor(at / 1000 / step);

  const buf = Buffer.alloc(8);
  buf.writeUInt32BE(Math.floor(counter / 2 ** 32), 0); // high word
  buf.writeUInt32BE(counter % 2 ** 32, 4);             // low word

  const mac = crypto.createHmac("sha1", secret).update(buf).digest();
  const offset = mac[mac.length - 1] & 0x0f;            // dynamic truncation

  const bin =
    ((mac[offset] & 0x7f) << 24) |
    (mac[offset + 1] << 16) |
    (mac[offset + 2] << 8) |
    mac[offset + 3];

  return String(bin % 10 ** digits).padStart(digits, "0");
}

// Accept the current step plus one either side to tolerate clock skew.
export function verifyTotp(secret, submitted, at = Date.now()) {
  for (const skew of [-1, 0, 1]) {
    if (totp(secret, at + skew * 30_000) === submitted) return true;
  }
  return false;
}

Where SMS sits in the assurance hierarchy

NIST’s digital identity guidelines classify out-of-band authenticators delivered over the public switched telephone network — SMS and voice — as restricted authenticators, on the grounds that the PSTN was not designed as a secure channel and that number-based delivery is exposed to interception and number takeover. The practical consequence is that a restricted authenticator may be used at the lowest assurance level but cannot by itself satisfy the higher levels. That is the technical basis for the position taken throughout this article: SMS is an excellent possession factor for consumer onboarding, and it is not a substitute for a phishing-resistant factor when the account controls money or sensitive data.

Two engineering responses follow. First, offer passkeys where you can, and treat SMS as the fallback rather than the default for privileged actions. Second, layer independently: a password plus SMS OTP is materially stronger than either alone, and the combination defeats credential stuffing even though neither factor is phishing-resistant. The mistake to avoid is treating an SMS code as proof of identity rather than proof of channel control, which is how teams end up writing “verified” into a database column that should have said “reached at this number on this date.”

Frequently asked questions

How long should an SMS OTP be valid?

Five minutes is the usual compromise: long enough that a delayed message in a slow corridor still arrives while the challenge is live, short enough to bound the window in which a leaked code is useful. If delivery in your target markets is consistently slower, increase the code length to eight digits before extending the lifetime, because entropy is cheaper than exposure.

Should I hash OTP codes or store them in plaintext?

Hash them, always. A plaintext code in a database or a log is a valid credential for anyone who reads it, and logs are the most commonly leaked artefact in real incidents. An HMAC-SHA256 digest bound to the challenge identifier lets you verify without storing anything usable, and a per-challenge binding prevents a digest stolen from one challenge being replayed against another.

Why do users sometimes receive an older code after a newer one?

Because SMS delivery is not ordered. Two messages sent seconds apart can be delivered in either order, and a message sent over one route may arrive after a message sent later over another. Design for it: keep the previous challenge valid alongside the current one for a short grace period, and accept either. Invalidating strictly on reissue is the mistake that produced the support ticket in this article.

Is SMS OTP acceptable for financial or admin actions?

As a sole factor, no. NIST classifies PSTN-delivered out-of-band authenticators as restricted, and the two attacks that matter for high-value accounts — real-time phishing relay and number takeover — both defeat SMS alone. Use SMS as one layer, require a phishing-resistant factor for privilege escalation, and add step-up verification with a short re-authentication window for sensitive operations.

Does a zero-KYC provider weaken OTP security?

No, because the account relationship is not part of the authentication decision. What protects the user is code entropy, storage hygiene, attempt budgets, and rate limits — all of which you control. What a zero-KYC provider changes is what you must disclose to obtain a sending route, not how well a code is generated or verified. The two concerns are orthogonal, and treating them as linked is what pushes teams into unnecessary data collection.

JH

Jacky Hossein

Verified Author

Principal Telecommunications & Cryptographic Systems Architect at SMSRoute. Specializes in carrier-grade SS7/SMPP routing protocols, non-custodial cryptocurrency billing rails, and zero-knowledge telecommunications privacy.

Send Global SMS in Under 60 Seconds Without KYC

Sign up with email only. Top up with Bitcoin, USDT, Monero, or Ethereum. Instant carrier interconnects to 149 countries from $0.004/msg.