Skip to content

vortexchat/mceliece.js

 
 

Repository files navigation

mceliece.js

Overview

The McEliece post-quantum asymmetric cipher compiled to WebAssembly using Emscripten. A simple JavaScript wrapper is provided to make McEliece easy to use in web applications.

The parameters are configured to slightly above 128-bit strength.

The underlying cipher implementation in use is McBits.

Example Usage

(async () => {
	const keyPair /*: {privateKey: Uint8Array; publicKey: Uint8Array} */ =
		await mceliece.keyPair()
	;

	const plaintext /*: Uint8Array */ =
		new Uint8Array([104, 101, 108, 108, 111, 0]) // "hello"
	;

	const encrypted /*: Uint8Array */ =
		await mceliece.encrypt(plaintext, keyPair.publicKey)
	;

	const decrypted /*: Uint8Array */ =
		await mceliece.decrypt(encrypted, keyPair.privateKey) // same as plaintext
	;

	console.log(keyPair);
	console.log(plaintext);
	console.log(encrypted);
	console.log(decrypted);
})();

Note: McEliece generally shouldn't be used to directly encrypt your data; in most cases, you'll want to pair it with a symmetric cipher and use it to encrypt symmetric keys.

Changelog

Breaking changes in major versions:

3.0.0:

  • As part of upgrading from asm.js to WebAssembly (with asm.js included as a fallback), the API is fully asynchronous.

2.0.0:

  • Switched to McBits from HyMES.

  • Removed some undocumented functions as part of minor API cleanup.

Credits

Thanks to Shane Curran for donating the npm package name!

About

JavaScript wrapper for a WebAssembly build of McEliece.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 42.6%
  • Makefile 36.6%
  • C 20.8%