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

zenschnorr

v1.0.0

Published

Based on `zenroom`, uses curve `BLS461` from the Millagro library.

Downloads

3

Readme

Schnorr Crypto

Based on zenroom, uses curve BLS461 from the Millagro library.

The way it works is that Zenroom uses the Milagro library for the elliptic curve and finite field stuff. It's all written in C and scriptable using Lua. This is then compiled into wasm using emscripten.

The arguments for the Lua scripts are passed as JSON encoded strings. To get output back from the scripts, the print(JSON.encode({})) command is used.

So the cryptography is implemented in Lua, see scripts/*.lua.

There is a build.js script that prepends the contents of prelude.lua to each other script and produces lua-scripts.js. Run npm run bundle-lua to update this file.

API

const S = require('zenroom-schnorr')
  • random(rngseed) => hex
  • keypair(rngseed) => {private, public}
  • sign(keypair, message, rngseed) => {s, R}
  • verify(signature, public, message) => bool

All calls are async/Promise.

Deterministic behaviour

You can pass a random number generator seed to the functions that use random numbers (random, keypair, sign) to make them deterministic.

Watch out that you don't generate a keypair with the same nonce.

// must be 256 bytes
const rngseed = '04b0848f3b3b5c62c6867a6fb53d2afbdcc76d9f5d22ad7a35fdb2dbe3122ec2939feb70fb3f5887d51f7dd30461e48d460f0f0e31251f3d5023f7d123ca2947e16aa496f31775b4e509d77bf0d8895b3cca732b4a4b4d34c2195d0d7c3405e78977b5810d9eb7a3e29476ba517efd6d7504b0848f3b3b5c62c6867a6fb53d2afbdcc76d9f5d22ad7a35fdb2dbe3122ec2939feb70fb3f5887d51f7dd30461e48d460f0f0e31251f3d5023f7d123ca2947e16aa496f31775b4e509d77bf0d8895b3cca732b4a4b4d34c2195d0d7c3405e78977b5810d9eb7a3e29476ba517efd6d750d9eb7a3e29476ba0d9eb7a3e29476ba517efd6d75517efd6d756d75d6d6'

Generating a random number

const rnd = await S.random(rngseed)

Creating a keypair

const {private, public} = await S.keypair(rnd)

Signing a message

const m = 'deadbeef'
const {r, R} = await S.sign({private, public}, m, rnd)

Verifying a signature

const isValid = await S.verify({s, R}, public, m)