Never Program Mad

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

    1.0.2 • Public • Published

    ntru-legacy

    Note

    The variant of NTRU used in this package is no longer recommended. Instead prefer NTRU Prime, which is a more robust alternative that was a NIST PQC Round 3 alternate candidate. An implementation of NTRU Prime is provided by ntru.

    That being said, unless you specifically require NTRU, Kyber should be preferred. Kyber is a NIST PQC winner that has been selected for standardization, and works similarly to NTRU (both being lattice-based). An implementation of Kyber is provided by kyber-crystals.


    Overview

    The NTRU 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 EES743EP1 (roughly 256-bit strength, as per NTRU's documentation).

    Example Usage

    import {ntru} from 'ntru-legacy';
    
    const keyPair /*: {privateKey: Uint8Array; publicKey: Uint8Array} */ =
    	await ntru.keyPair()
    ;
    
    const plaintext /*: Uint8Array */ =
    	new Uint8Array([104, 101, 108, 108, 111, 0]) // "hello"
    ;
    
    const encrypted /*: Uint8Array */ =
    	await ntru.encrypt(plaintext, keyPair.publicKey)
    ;
    
    const decrypted /*: Uint8Array */ =
    	await ntru.decrypt(encrypted, keyPair.privateKey) // same as plaintext
    ;
    
    console.log(keyPair);
    console.log(plaintext);
    console.log(encrypted);
    console.log(decrypted);
    

    Note: NTRU 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 ntru directly for anything important if you lack the experience to do so.

    Install

    npm i ntru-legacy

    DownloadsWeekly Downloads

    26

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    148 kB

    Total Files

    9

    Last publish

    Collaborators

    • cyphinc