OPAQUE
Register and log in with OPAQUE-3DH (RFC 9807).
from oxcrypto.pake.opaque import OPAQUE
from oxcrypto.password.argon2 import Parameters
suite = OPAQUE.RISTRETTO255_SHA512
ksf = Parameters()
setup = suite.generate() # server; persist with setup.to_bytes()
# Registration
client, request = suite.start_registration(b"password")
response = setup.registration_response(request, credential_identifier=b"alice")
record, export_key = client.finish(b"password", response, ksf=ksf)
# The server stores `record` for b"alice".
# Login
client, ke1 = suite.start_login(b"password")
server, ke2 = setup.start_login(record, ke1, credential_identifier=b"alice")
ke3, session_key, export_key = client.finish(b"password", ke2, ksf=ksf)
assert server.finish(ke3) == session_keyServerSetup holds the OPRF seed, the server key pair and a dummy key. Create
it once with generate() (OS random generator), store to_bytes() and reload
it with load_server_setup. public_key() returns the server public key.
The client passes ksf explicitly to both finish calls: an
oxcrypto.password.argon2.Parameters selects Argon2id (version 0x13, with the
all-zero salt that opaque-ke uses), and None selects the Identity function
from the RFC test vectors, which does no key stretching: with None the
caller must stretch the password before passing it in. Registration and
login must use the same value. context, client_identity and
server_identity are keyword options; both sides must pass the same values.
Without identities, RFC 9807 uses the public keys.
Pass None as the record in start_login when the user is unknown. The server
then answers with a fake response, and the client's finish raises
InvalidTag, as it does for a wrong password. ServerLogin.finish raises
InvalidTag when the client's KE3 does not verify. Malformed messages and
states, including inputs with trailing bytes, raise ValueError. export_key
is the same for registration and every login, and can encrypt data that only
the client can open.
Important
Every state is single use: a second finish, or finish after a failed
one, raises ValueError.
to_bytes() serializes an unfinished state, and
OPAQUE.load_client_registration, load_client_login and load_server_login
restore it. The serialized states and ServerSetup.to_bytes() contain secrets.
States and server setups cannot be pickled or copied, and their repr shows
only the suite.
| Suite | OPRF | Key exchange group | Hash, KDF, MAC |
|---|---|---|---|
RISTRETTO255_SHA512 | ristretto255-SHA512 | ristretto255 | SHA-512 |
X25519_SHA512 | ristretto255-SHA512 | X25519 (curve25519) | SHA-512 |
P256_SHA256 | P256-SHA256 | P-256 | SHA-256 |
P384_SHA384 | P384-SHA384 | P-384 | SHA-384 |
P521_SHA512 | P521-SHA512 | P-521 | SHA-512 |
| Standard | RFC 9807 (Informational, CFRG, July 2025); OPRF from RFC 9497 |
| Crate | opaque-ke 5.0.0-pre.0 (Meta, MIT OR Apache-2.0), pre-release; voprf 0.6.0-pre.2; p256, p384, p521 0.14 |
| Audit | NCC Group reviewed opaque-ke 0.5.0 in 2021 (public report); no published audit of 5.0.0-pre.0 |
| MSRV | 1.88, builds with the project MSRV 1.88 |
| Experimental | No for the RFC 9807 3DH suites; the crate release is a pre-release |
| Test vectors | RFC 9807 Appendix C.1 (ristretto255, curve25519 and P-256); P-384 and P-521 have round-trip tests only |
Zeroization
Note
opaque-ke derives ZeroizeOnDrop for its protocol states, key pairs, OPRF seed
and envelope, and wraps intermediate buffers in Zeroizing; voprf wipes its
blinding scalar. oxcrypto has not verified this independently. The
ClientLoginFinishResult and ClientRegistrationFinishResult structs that
carry session_key and export_key are not zeroized on drop, so oxcrypto
wipes its copies after building the Python bytes. The Argon2id KSF runs on a
memory buffer that oxcrypto allocates and wipes, because argon2 0.6.0 frees
its own buffer without wiping it; MemoryError is raised when that buffer
cannot be allocated. During finish, opaque-ke leaves short-lived stack
copies of the OPRF output and the stretched password unwiped.
Python bytes passed in or returned (passwords, session keys, export keys,
serialized states) are not wiped, and Python may copy them. Constant-time
behavior comes from opaque-ke and its dependencies and has not been verified
by oxcrypto.