OPAQUE: logging in without ever sending your password

How the OPAQUE augmented PAKE works, from the OPRF up, with diagrams, live demos and Python, C++ and Rust code.

1 min read

Almost every login form on the internet works the same way. You type your password, the browser sends it to the server over TLS, and the server hashes it and compares the result with a stored hash. It works, and with a good password hash it is far better than storing plaintext. But look at what the server gets: your actual password, in memory, on every login.

OPAQUE is a protocol where that never happens. The server stores something derived from your password, the client proves it knows the password, and both sides end up with a shared key. At no point does the password, or anything an eavesdropper or the server could use to test a guess without the server’s secret key, cross the wire. It was standardised in 2025 as RFC 9807, and it is what OpenVireo uses for sign-in.

This post builds OPAQUE from the bottom up: first the problem, then the one clever primitive it rests on (an oblivious PRF), then registration, login and the key schedule, and finally what happens when the database leaks. There are five interactive demos along the way, all running real cryptography in your browser, and reference code in three languages from a public repo, opaque-examples.

The problem with “send the password over TLS”

TLS protects the password between the browser and whoever terminates TLS. After that it is plaintext, and it travels further than most people think:

  • The server sees it on every login. A logging middleware that dumps request bodies, an error tracker that captures the failing request, a debug print left in a hotfix: each of these has leaked plaintext passwords at large, careful companies.
  • TLS often ends early. CDNs, load balancers and corporate inspection proxies all decrypt traffic. Every one of them is a place the password exists in the clear.
  • A database dump enables offline guessing straight away. The attacker has the hash and the salt. They can try a billion candidate passwords without talking to you, limited only by how slow your hash is.
sequenceDiagram
    participant C as Client
    participant S as Server
    participant A as Attacker
    C->>S: TLS { user, password }
    Note over S: sees the plaintext<br/>hash(password, salt) == stored?
    S-->>C: OK
    S--)A: database dump: salt + hash
    Note over A: guess offline, as fast<br/>as the hash allows

What we want instead: the client proves it knows the password, the server learns nothing it could use to recover the password, and a stolen database is useless on its own. That is a PAKE.

PAKEs in one paragraph

A password-authenticated key exchange lets two parties who share a password agree on a strong key without exposing the password to eavesdroppers. Balanced PAKEs (such as CPace) assume both sides know the password. Augmented (or asymmetric) PAKEs assume the server holds only a verifier derived from it, so a server breach doesn’t hand over the password itself. The familiar example is SRP, which has had TLS cipher suites for years and which Apple uses for iCloud Keychain recovery. SRP works, but it has real weaknesses: the server sends the user’s salt to anyone who asks before authentication, so an attacker can precompute a dictionary for a specific user and crack the verifier the moment it leaks. It is also awkward to implement and doesn’t fit modern elliptic-curve groups cleanly.

OPAQUE fixes the salt problem with a single idea: the salt is replaced by a secret key the server never reveals, applied obliviously. The salt is no longer public, so precomputation becomes impossible.

The building block: an oblivious PRF

A pseudorandom function F(k,x)F(k, x) behaves like a random function to anyone who doesn’t know the key kk. An oblivious PRF splits it between two parties: the client holds the input xx (the password), the server holds the key kk, and at the end the client learns F(k,x)F(k, x) and the server learns nothing: not xx, and not the output.

The construction OPAQUE uses (RFC 9497) is short. Let H′H' hash a string onto a group element and HH be an ordinary hash. Then

F(k,x)=H(x, H′(x)k)F(k, x) = H\big(x,\ H'(x)^k\big)

and the oblivious evaluation goes:

  1. Blind. The client picks a random scalar rr and sends a=H′(x)ra = H'(x)^r.
  2. Evaluate. The server sends back b=ak=H′(x)rkb = a^k = H'(x)^{rk}.
  3. Unblind. The client computes b1/r=H′(x)kb^{1/r} = H'(x)^k and hashes it with xx.

Why is this safe? aa is H′(x)H'(x) raised to a fresh random power, which makes it a uniformly random group element, independent of xx. The server sees noise. And the client can’t compute FF for a different password without asking the server again, because that needs kk. This second property matters later: it is what makes offline guessing impossible without the server’s key.

sequenceDiagram
    participant C as Client (knows x)
    participant S as Server (knows k)
    Note over C: pick random r
    C->>S: a = H'(x)^r
    Note over S: sees a random<br/>group element
    S->>C: b = a^k
    Note over C: b^(1/r) = H'(x)^k<br/>F(k,x) = H(x, H'(x)^k)

Try it. The demo below runs exactly these three steps on the ristretto255 group in your browser. Run it once, press New blind (r), and run it again: the bytes the server sees are completely different, but the final output is identical. Change the server key and the output changes.

Interactive OPRF demo: blind, evaluate and unblind on ristretto255. Needs JavaScript; the diagram above shows the same steps.

The same thing in code. This is a teaching OPRF: RFC 9497 hashes to the group with expand_message_xmd and a domain-separation tag, while this uses plain SHA-512 so every step stays visible. All three versions, and the demo above, produce the same output for the same rr and kk; the repo’s CI checks that.

python/oprf.py
def hash_to_group(x: bytes) -> bytes:
# H'(x): map 64 uniform bytes onto the group
return s.crypto_core_ristretto255_from_hash(hashlib.sha512(x).digest())
def blind(x: bytes, r: bytes) -> bytes:
return s.crypto_scalarmult_ristretto255(r, hash_to_group(x)) # a = H'(x)^r
def evaluate(k: bytes, a: bytes) -> bytes:
return s.crypto_scalarmult_ristretto255(k, a) # b = a^k
def finalize(x: bytes, r: bytes, b: bytes) -> bytes:
r_inv = s.crypto_core_ristretto255_scalar_invert(r)
unblinded = s.crypto_scalarmult_ristretto255(r_inv, b) # H'(x)^k
return hashlib.sha512(x + unblinded).digest() # F(k, x)
cpp/oprf.cpp
static Point blind(const std::string& x, const Scalar& r) {
return mul(r, hash_to_group(x)); // a = H'(x)^r
}
static Point evaluate(const Scalar& k, const Point& a) {
return mul(k, a); // b = a^k
}
static Digest finalize(const std::string& x, const Scalar& r, const Point& b) {
Scalar r_inv;
crypto_core_ristretto255_scalar_invert(r_inv.data(), r.data());
return outer_hash(x, mul(r_inv, b)); // H(x, H'(x)^k)
}
rust/src/bin/oprf.rs
fn hash_to_group(x: &[u8]) -> RistrettoPoint {
RistrettoPoint::hash_from_bytes::<Sha512>(x) // H'(x)
}
fn blind(x: &[u8], r: &Scalar) -> RistrettoPoint {
hash_to_group(x) * r // a = H'(x)^r
}
fn evaluate(k: &Scalar, a: &RistrettoPoint) -> RistrettoPoint {
a * k // b = a^k
}
fn finalize(x: &[u8], r: &Scalar, b: &RistrettoPoint) -> Vec<u8> {
let unblinded = b * r.invert(); // H'(x)^k
Sha512::new().chain_update(x).chain_update(unblinded.compress().as_bytes()).finalize().to_vec()
}

Registration

Registration turns the OPRF output into a record the server can store. The client runs the OPRF with the server (the server picks a key kk for this user), then:

  1. Stretches the OPRF output with a key-stretching function (KSF) such as Argon2id, and combines the two with HKDF-Extract into randomized_password. This is what makes every later guess expensive.
  2. Derives keys from randomized_password with HKDF-Expand: a masking_key, and, mixed with a fresh envelope_nonce, an auth_key, an export_key and a seed for the client’s long-term key pair (RFC 9807 §4.1.2).
  3. Seals an envelope: the nonce plus a MAC (auth_tag) under auth_key over the client’s public key and the server’s public key and identities.
  4. Uploads the record: the client’s public key, the masking_key and the envelope.
sequenceDiagram
    participant C as Client
    participant S as Server
    Note over C: blind the password
    C->>S: RegistrationRequest<br/>(blinded_message)
    Note over S: evaluate with<br/>this user's k
    S->>C: RegistrationResponse<br/>(evaluated_message, server_public_key)
    Note over C: unblind, KSF, derive keys,<br/>seal envelope
    C->>S: RegistrationRecord<br/>(client_public_key,<br/>masking_key, envelope)
    Note over S: store record + k

Notice what the server stores: no password, no hash of the password, and no salt. The client’s private key isn’t stored anywhere; it is re-derived from the password on every login. The client stores nothing at all, so it can log in from a fresh device with just the password.

With libopaque (Python and C++) and opaque-ke (Rust), registration is four calls. In each snippet both parties run in one process so the flow reads top to bottom; every -> comment is a network message in a real deployment.

python/opaque_flow.py
IDS = opaque.Ids("alice", "example.com") # idU, idS
def register(password: str) -> bytes:
# Client: blind the password. The server never sees it.
client_sec, request = opaque.CreateRegistrationRequest(password)
# Server: evaluate the OPRF with a fresh per-user key.
server_sec, response = opaque.CreateRegistrationResponse(request)
# Client: unblind, harden (Argon2id), seal the envelope.
reg_record, export_key = opaque.FinalizeRequest(client_sec, response, IDS)
# Server: store this. No password, no password hash.
return opaque.StoreUserRecord(server_sec, reg_record)
cpp/opaque_flow.cpp
const op::Ids kIds{"alice", "example.com"};
op::Bytes register_user(std::string_view password) {
auto client = op::create_registration_request(password); // -> request
auto server = op::create_registration_response(client.request); // <- response
auto fin = op::finalize_request(client.sec, server.response, kIds); // -> record
return op::store_user_record(server.sec, fin.record); // server stores this
}
rust/src/bin/opaque_flow.rs
fn register(setup: &ServerSetup<Suite>, password: &[u8]) -> ServerRegistration<Suite> {
let client = ClientRegistration::<Suite>::start(&mut OsRng, password).unwrap(); // -> request
let server = ServerRegistration::start(setup, client.message, b"alice").unwrap(); // <- response
let k = ksf();
let upload = client
.state
.finish(&mut OsRng, password, server.message, ClientRegistrationFinishParameters::new(IDS, Some(&k)))
.unwrap(); // -> record
ServerRegistration::finish(upload.message) // the server stores this
}

The C++ version is a small RAII wrapper (op::) over libopaque’s C API: buffers are std::vectors sized by the library’s constants, secrets are wiped with sodium_memzero when they go out of scope, and failures become exceptions. It is in cpp/opaque.hpp.

Login

Login is three messages, conventionally called KE1, KE2 and KE3 (RFC 9807 §6). Two things happen at once: an OPRF run to recover the envelope, and an authenticated key exchange (3DH) that produces a session key and proves each side to the other.

  • KE1 (client → server): a fresh blinded password, a nonce, and an ephemeral public key.
  • KE2 (server → client): the OPRF evaluation; the server’s public key and the envelope, masked with a pad derived from masking_key, so only someone who knows the password can unmask them; the server’s nonce and ephemeral key; and a MAC over the whole transcript.
  • The client unblinds, re-derives randomized_password, unmasks and opens the envelope, recovers its private key, and runs 3DH:

ikm=DH(eU,ES) ∥ DH(eU,PS) ∥ DH(sU,ES)\mathit{ikm} = \mathrm{DH}(e_U, E_S) \,\|\, \mathrm{DH}(e_U, P_S) \,\|\, \mathrm{DH}(s_U, E_S)

where eU,sUe_U, s_U are the client’s ephemeral and long-term private keys and ES,PSE_S, P_S the server’s ephemeral and long-term public keys. HKDF over ikm\mathit{ikm} and a hash of the transcript gives the session key and two MAC keys. The client checks the server’s MAC. A wrong password fails here: different OPRF output, wrong keys, MAC mismatch.

  • KE3 (client → server): the client’s MAC. The server checks it, and both sides now hold the same session_key.
sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: KE1: blinded_message,<br/>client_nonce, client_keyshare
    Note over S: OPRF eval, mask envelope,<br/>3DH, server MAC
    S->>C: KE2: evaluated_message,<br/>masked_response, server_nonce,<br/>server_keyshare, server_mac
    Note over C: unblind, KSF, unmask,<br/>open envelope, 3DH,<br/>check server MAC
    C->>S: KE3: client_mac
    Note over S: check client MAC
    Note over C,S: both hold session_key

Step through a real run below. It is a genuine RFC 9807 exchange (opaque-ke compiled to WebAssembly), with both the client and the server running in the page. Tick Wrong password to see where it fails, and open the Wire tap to see every byte an eavesdropper would capture next to a classic login with TLS stripped away.

Interactive login demo: registration and KE1, KE2, KE3 step by step, with a wire tap. Needs JavaScript; the diagrams above show the same flow.

Two details are worth noticing in the demo. The export_key at login matches the one from registration, so an app can use it to encrypt data that only a client with the password can decrypt. And with the wrong password, the server never finds out why KE3 didn’t arrive; it can’t tell a wrong password from a dropped connection. Neither can an attacker watching the wire.

Here is login in code. In every language the wrong password fails inside the protocol (the server MAC check in RecoverCredentials or ClientLogin::finish), not on a string comparison.

python/opaque_flow.py
CONTEXT = b"opaque-examples-v1" # bind the protocol to this app
def login(password: str, record: bytes) -> bool:
ke1, client_sec = opaque.CreateCredentialRequest(password) # -> KE1
ke2, server_session_key, server_auth_state = opaque.CreateCredentialResponse(
ke1, record, IDS, CONTEXT) # <- KE2
try:
client_session_key, ke3, export_key = opaque.RecoverCredentials(
ke2, client_sec, CONTEXT, IDS) # -> KE3
except ValueError:
return False # wrong password: the server's MAC did not verify
try:
opaque.UserAuth(server_auth_state, ke3)
except ValueError:
return False
return client_session_key == server_session_key
cpp/opaque_flow.cpp
constexpr std::string_view kContext = "opaque-examples-v1";
bool login(std::string_view password, const op::Bytes& record) {
auto client = op::create_credential_request(password); // -> KE1
auto server = op::create_credential_response(client.ke1, record, kIds, kContext); // <- KE2
try {
auto rec = op::recover_credentials(server.ke2, client.sec, kContext, kIds); // -> KE3
if (!op::user_auth(server.expected_ke3, rec.ke3)) return false;
return sodium_memcmp(rec.session_key.data(), server.session_key.data(),
rec.session_key.size()) == 0;
} catch (const op::Error&) {
return false; // wrong password: KE2's MAC did not verify
}
}
rust/src/bin/opaque_flow.rs
fn login(setup: &ServerSetup<Suite>, password: &[u8], record: &ServerRegistration<Suite>) -> bool {
let params = || ServerLoginParameters { context: Some(CONTEXT), identifiers: IDS };
let client = ClientLogin::<Suite>::start(&mut OsRng, password).unwrap(); // -> KE1
let server =
ServerLogin::start(&mut OsRng, setup, Some(record.clone()), client.message, b"alice", params()).unwrap(); // <- KE2
let k = ksf();
let Ok(done) = client.state.finish(
&mut OsRng, password, server.message,
ClientLoginFinishParameters::new(Some(CONTEXT), IDS, Some(&k)),
) else {
return false; // wrong password: the server MAC did not verify
}; // -> KE3
let Ok(server_done) = server.state.finish(done.message, params()) else { return false };
done.session_key == server_done.session_key // done.export_key stays on the client
}

All three print the same thing:

make test
stored record: 256 bytes
'correct horse battery staple': user authenticated
'correct horse battery stapler': user NOT authenticated

(The Rust record is 192 bytes: opaque-ke derives each user’s OPRF key from one server-wide seed, while libopaque stores a per-user key and key pair in the record.)

The key schedule

Everything on the client hangs off one value. The password and the server’s OPRF key give the OPRF output; the KSF and HKDF-Extract turn it into randomized_password; HKDF-Expand with different labels gives four independent keys. The session key comes from a separate place, the 3DH exchange, so it is fresh on every login.

flowchart TD
    pw[password] --> out[OPRF output]
    k[OPRF key k<br/>server] --> out
    out --> ksf[KSF: Argon2id]
    ksf --> rp[randomized_password]
    out --> rp
    rp --> mk[masking_key]
    rp --> ak[auth_key]
    rp --> ek[export_key]
    rp --> sk[client private key]
    sk --> dh[3DH]
    eph[ephemeral keys] --> dh
    ssk[server private key] --> dh
    dh --> sess[session_key]

The explorer below lets you click any key to see where it comes from and what it protects, then mark keys as leaked to see what an attacker can compute. Try the three scenarios: a database dump alone, a dump plus the server’s secrets, and a phished password.

Interactive key schedule explorer. Needs JavaScript; the flowchart above shows the same tree.

When the database leaks

This is where OPAQUE earns its keep. Compare what an attacker gets from three kinds of dump:

DumpWhat the attacker hasCan they precompute?Cost per guess
bcrypt / Argon2id hashessalt + hash per userNo (salted), but the salt is in the dumpone hash
SRP verifierssalt + gH(s,pw)g^{H(s, pw)}Yes: the salt was public before the breachone hash + one modexp
OPAQUE records onlypublic key, masking key, envelopeNocan’t test a guess at all
OPAQUE records + OPRF keysthe above + kkNo: nothing was ever publicone OPRF evaluation + one KSF run

The third row is the important one. To check whether a guess is right, the attacker has to compute F(k,guess)F(k, \text{guess}), which needs kk. If the server keeps OPRF keys somewhere separate from the user table (an HSM, a secrets manager, a different database), a dump of the user table on its own gives away nothing that can be tested offline.

If the attacker gets kk too, OPAQUE falls back to being as strong as its KSF, the same as a well-tuned Argon2id password hash. The win over a classic hash is everything before that point: no precomputation (since no salt was ever sent), no plaintext password on the server at any time, and nothing useful on the wire. RFC 9807 §10.11 puts it the same way.

flowchart LR
    dump[stolen database] --> bc[bcrypt hashes]
    dump --> srp[SRP verifiers]
    dump --> op[OPAQUE records]
    bc --> g1[guess offline:<br/>1 hash each]
    srp --> g2[precomputed table<br/>ready at breach]
    op --> nok{have k?}
    nok -- no --> stop[can't test<br/>any guess]
    nok -- yes --> g3[guess offline:<br/>OPRF + KSF each]

The simulator below races a small dictionary attack against each scheme. The numbers are illustrative orders of magnitude, not benchmarks; the shape is the point.

Interactive breach simulator. Needs JavaScript; the table above has the same comparison.

Running it: Python server, C++ and Rust clients

The snippets above run both parties in one process. The repo also has a real round trip: a small Python server built on the standard library’s http.server that holds records in a dict, a C++ client using plain sockets, and a Rust client.

python/server.py
if path == "/login/start":
ke2, session_key, expected_ke3 = opaque.CreateCredentialResponse(
body, records[user], ids, CONTEXT)
session = secrets.token_hex(16)
pending_login[session] = (user, expected_ke3, session_key)
return 200, session.encode() + b"\n" + ke2
if path == "/login/finish":
user, expected_ke3, session_key = pending_login.pop(q["session"][0])
opaque.UserAuth(expected_ke3, body) # raises ValueError on a bad MAC
return 200, b"user authenticated"

The C++ client uses libopaque, the same library as the server. The Rust client uses opaque-ke, a completely separate implementation. It still works, because both follow the same spec and every parameter matches: ristretto255, SHA-512, the same context string and identities, and the same KSF settings.

scripts/interop.sh
== C++ client -> Python server
registered alice
user authenticated
== Rust client -> Python server
registered carol
user authenticated
== C++ registers frank, Rust logs in
user authenticated
== same, but Rust uses opaque-ke's default Argon2 parameters (expected to fail)
user NOT authenticated

The last two lines are the interesting ones. The KSF runs only on the client, so the server never notices which parameters a client used. A single client can use any settings and work fine. It breaks only when two client implementations share a record. Here, a user registered from C++ (libopaque hard-codes Argon2id with libsodium’s INTERACTIVE limits: 64 MiB, 2 passes) can log in from Rust only if the Rust side sets the same parameters. With opaque-ke’s defaults, the right password is rejected.

Footguns

OPAQUE is a strong protocol, but there is plenty of room to get the details wrong.

  • Bind identities and context. Pass the user and server identities (idU, idS) and an application context string on both sides. They go into the envelope MAC and the transcript, which stops a record or a message from one deployment being replayed against another (§10.3).
  • Normalise the password first. “é” can be one code point or two. Apply Unicode NFKC before the password goes in, or a user who types on a different keyboard can’t log in. Also check that your binding really passes bytes: one JavaScript wrapper passed the UTF-16 string length as the byte length, which silently truncated non-ASCII passwords.
  • Never ship a test build. libopaque has a NORANDOM compile flag for test vectors that replaces the random number generator with a fixed sequence. A prebuilt JavaScript bundle of it was built with that flag (and with tracing that prints passwords to the console), so every login sent the same nonce and key share. OpenVireo’s clients refuse to run a build whose KE1 nonce is 00 01 02 ….
  • Don’t copy old tutorial code. Pre-RFC implementations are fine for learning but not for production; one popular Go example generates a 512-bit RSA server key, which can be factored on rented hardware in hours.
  • Pin versions. Draft-era implementations are not wire-compatible with each other or with the RFC. Pin the library commit and the KSF parameters, and test interop between every client you ship.
  • Don’t reveal which users exist. If login/start errors for an unknown user, anyone can list your accounts. The RFC’s answer is a fake record, so the response looks identical and the failure only shows at KE3 (§10.9).
  • Rate-limit. OPAQUE stops offline guessing. It does nothing about someone trying passwords against your live login endpoint (§9.2).

How OpenVireo uses it

OpenVireo is a password manager, so its sign-in has a harder job than most: the server must never be able to read your vault, even if it is breached or malicious. OPAQUE handles sign-in. The desktop client calls libopaque directly (see OpaqueClient.cpp), the server uses libopaque’s Python binding, and the TypeScript SDK behind the web client uses opaque-ke compiled to WebAssembly with libopaque’s Argon2 parameters, for exactly the reason in the interop section above, with a test that checks both directions against the C library. Every client binds the protocol to the context ov-opaque-v1 and the account email and issuer as identities, and normalises the password to NFKC first. Unknown emails get a fake record derived from a server secret, so the login responses look the same.

The vault key is deliberately not derived from OPAQUE. It comes from the password stretched separately and a random 128-bit Secret Key that exists only on the user’s devices. So even an attacker with the OPAQUE records, the OPRF keys and a correctly guessed password still can’t decrypt a vault without the Secret Key. OPAQUE proves who you are, and the Secret Key protects what you store. For now export_key isn’t used.

Further reading