mceliece-legacy
v1.0.4
Published
JavaScript wrapper for a WebAssembly build of McEliece
Downloads
14
Maintainers
Readme
mceliece-legacy
Note
The variant of McEliece used in this package is no longer recommended. Instead prefer Classic McEliece, which is currently being evaluated for standardization as a NIST PQC Round 4 candidate. An implementation of Classic McEliece is provided by mceliece.
Overview
The McEliece post-quantum asymmetric cypher 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 cypher implementation in use is McBits.
Example Usage
import {mceliece} from 'mceliece-legacy';
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 is a low-level cryptographic primitive, not a high-level construct like libsodium's crypto_box. This module can be combined with a symmetric cypher and a MAC to provide such a construct, but you should avoid using mceliece directly for anything important if you lack the experience to do so.