@vexahub/opaque-client
v0.1.0-alpha.1
Published
OPAQUE (RFC 9807) client (WASM)
Maintainers
Readme
@vexahub/opaque-client
OPAQUE (RFC 9807) client library for browser and Node.js.
Built in Rust, compiled to WASM.
Part of the @vexahub/opaque project.
Install
npm install @vexahub/opaque-clientUsage
import { startRegistration, finishRegistration, startLogin, finishLogin } from '@vexahub/opaque-client';
// Registration
const { clientRegistrationState, registrationRequest } = startRegistration({ password });
// ... send registrationRequest to server, receive registrationResponse ...
const { registrationRecord, exportKey, serverStaticPublicKey } = finishRegistration({
password,
registrationResponse,
clientRegistrationState,
});
// Login
const { clientLoginState, startLoginRequest } = startLogin({ password });
// ... send startLoginRequest to server, receive loginResponse ...
const result = finishLogin({
clientLoginState,
loginResponse,
password,
});
if (!result) throw new Error('Login failed');
const { finishLoginRequest, sessionKey, exportKey, serverStaticPublicKey } = result;Key Stretching
The default KSF preset is MemoryConstrained (Argon2id, 64 MiB, t=3, p=4).
Pass keyStretching to finishRegistration and finishLogin to override:
finishRegistration({
password,
registrationResponse,
clientRegistrationState,
keyStretching: 'vexahub', // 128 MiB, t=3, p=4
});Available presets: high, memory-constrained, vexahub, or custom:
keyStretching: { custom: { memory: 131072, iterations: 3, parallelism: 4 } }Memory limit for custom is 1 GiB (1048576 KiB) otherwise it will throw an error.
We recommended that you use
highpreset if you reach that limit.
Related packages
| Package | Description |
|----------------------------------------------------------------------------------|--------------------------|
| @vexahub/opaque | Client + server combined |
| @vexahub/opaque-server | Server only |
License
This package is dual-licensed under the MIT License or Apache-2.0 License.
