ntru
TypeScript icon, indicating that this package has built-in type declarations

4.0.4 • Public • Published

ntru

Overview

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

The default parameter set is sntrup1277 (roughly 256-bit strength).

Example Usage

import {ntru} from 'ntru';

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

const {cyphertext, secret} /*: {cyphertext: Uint8Array; secret: Uint8Array} */ =
	await ntru.encrypt(keyPair.publicKey)
;

const decrypted /*: Uint8Array */ =
	await ntru.decrypt(cyphertext, keyPair.privateKey) // same as secret
;

console.log(keyPair);
console.log(secret);
console.log(cyphertext);
console.log(decrypted);

Changelog

Breaking changes in major versions:

4.0.0:

  • Switched from legacy NTRUEncrypt to NTRU Prime. For backwards compatibility with previous versions of this package, use ntru-legacy.

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:

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

Versions

Current Tags

Version History

Package Sidebar

Install

npm i ntru

Weekly Downloads

4

Version

4.0.4

License

MIT

Unpacked Size

175 kB

Total Files

9

Last publish

Collaborators

  • cyphinc