npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dashlane/pqc-kem-ntrulpr857-node

v1.0.0

Published

JavaScript wrapper generator of WebAssembly builds of each round-3 finalists of NIST Post-Quantum Cryptography Competition

Downloads

7

Readme

pqc.js

Overview

This project provides JS bindings and playground of post-quantum asymmetric cipher compiled to WebAssembly using emscripten with a fallback in plain JS.

The available methods are the finalists (and alternate candidates) of NIST Post-Quantum Cryptography Competition:

The C implementations used to create the bindings are the clean versions provided by PQClean.

This project has been inspired by ntru.js that used to provide an NTRU JS binding.

Playground

It is possible to test the bindings, to compare them in real-world conditions on this playground.

How to download pre-built bindings and NPM packages

Pre-built bindings are available on the playground.

How to build

  • sudo apt install emscripten
  • npm ci
  • make clean
  • make kem-<the KEM algorithm you want to build> or make sign-<the signature algorithm you want to build>
  • All bindings can be built using make all

The output directory is docs/bin/ and each output binding is made of a JS module and its associated WebAssembly file, a browser package, and a node package.

How to use

Key Encapsulation

import kemBuilder from 'pqc-kem-<algoName>.js'

async function run() {
    const kem = await kemBuilder();
    
    const { publicKey, privateKey } = await kem.keypair();
    const { ciphertext, sharedSecret: sharedSecretA } = await kem.encapsulate(publicKey);
    const { sharedSecret: sharedSecretB } = await kem.decapsulate(ciphertext, privateKey);
    // sharedSecretA === sharedSecretB
}

run();

Signature

import signBuilder from 'pqc-sign-<algoName>.js'

async function run() {
    const sign = await signBuilder();
    
    const message = new Uint8Array([0x44, 0x61, 0x73, 0x68, 0x6c, 0x61, 0x6e, 0x65]);
    
    const { publicKey, privateKey } = await sign.keypair();
    const { signature } = await sign.sign(message, privateKey);
    const validSignature = await sign.verify(signature, message, publicKey);
    // validSignature === true
}

run();

Disable WebAssembly execution

The first optional parameter of the builders is set to true is you want to disable WebAssembly execution.

If it is set to false, the fallback JavaScript may still be used if the WebAssembly fails.

Change the path of the WebAssembly

The second optional parameter of the builders is the path to the WebAssembly file.

Implementation notes

  • Random generation is provided by libsodium that is using crypto.randomBytes.
  • SHA-2 and AES implementations are provided by SubtleCrypto that is an implementation of Web Crypto API. This may slow down the execution of the bindings because of the asynchronous calls to SubtleCrypto, even more when AES-ECB is used because in this case AES-CTR is called for each block.
  • SHA-2 PQClean implementation is still used by sphincs-sha256-* bindings because they are using incremental version of sha256 that do not exist in Web Crypto API.
  • SHA-3 PQClean implementation is still used by NTRU, Kyber, SABER, FrodoKEM and McEliece-Classic because there are no implementations in Web Crypto API.