@squirrelchat/opaque-wasm-client
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

opaque-wasm client

License npm

Wrapper for opaque-ke to implement the OPAQUE protocol in JavaScript/WASM.

This library uses the following OPAQUE configuration, based on the recommendations of the OPAQUE draft and the Argon2 RFC:

  • OPRF: ristretto255-SHA512
  • KDF: HKDF-SHA-512
  • MAC: HMAC-SHA-512
  • Hash: SHA-512
  • KSF: Argon2id(S = zeroes(16), p = 4, T = Nh, m = 2^16, t = 3, v = 0x13, K = nil, X = nil, y = 2)
  • Group: ristretto255

Installation

The client requires an environment compatible with WebAssembly ESM. For example,

npm i @squirrelchat/opaque-wasm-client
yarn add @squirrelchat/opaque-wasm-client
pnpm add @squirrelchat/opaque-wasm-client

Usage

Registration

import { startRegistration } from '@squirrelchat/opaque-wasm-client'

try {
	const registration = startRegistration('mewn supy€w sekyuwe paffw0wdy! UwU')
	console.log(registration.request) // <Uint8Array ...>
	// ~> send this to the server

	const response = ... // <~ response from the server

	const { exportKey, serverPublicKey, record } = registration.finish(response)
	console.log(record) // <Uint8Array ...>
	// ~> send this to the server

	console.log('export key:', exportKey) // <Uint8Array ...>
	console.log('server public key:', serverPublicKey) // <Uint8Array ...>
} catch (e) {
	console.error('Registration failed!', e)
}

Login

import { startLogin } from '@squirrelchat/opaque-wasm-client'

try {
	const login = startLogin('mewn supy€w sekyuwe paffw0wdy! UwU')
	console.log(login.request) // <Uint8Array ...>
	// ~> send this to the server

	const response = ... // <~ response from the server

	const { exportKey, sessionKey, serverPublicKey, message } = registration.finish(response)
	console.log(record) // <Uint8Array ...>
	// ~> send this to the server

	console.log('export key:', exportKey)
	console.log('session key:', sessionKey)
	console.log('server public key:', serverPublicKey)
} catch (e) {
	console.error('Login failed!', e)
}

Readme

Keywords

none

Package Sidebar

Install

npm i @squirrelchat/opaque-wasm-client

Weekly Downloads

0

Version

0.1.2

License

BSD-3-Clause

Unpacked Size

144 kB

Total Files

7

Last publish

Collaborators

  • cyyynthia