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 🙏

© 2026 – Pkg Stats / Ryan Hefner

crypto-toys

v1.0.3

Published

Scripts for computing DLP and EC toy examples

Downloads

3

Readme

crypto-toys

Library for computing Discrete Logarithm, Elliptic Curve and Pairings toy examples.

Crypto-Toys may be either installed as a library, or else one may clone the project, build it and run its command line tool.


Requirements

Node.js v14 or later


Crypto-Toys Library

To add crypto-toys to a node.js project:

npm i crypto-toys

Next import the library using one of these methods:

const toys = require("crypto-toys")
import * as toys from "crypto-toys"

The most important configuration structure to be aware of is ECurve, defined as follows:

interface ECurve {
    fieldN: number;
    coeffA?: number;
    coeffB?: number;
    rorder?: number;
    iSQR?: number;
}

These are the parameters defining the field, EC and sub-group order over which computations are to be computed.


Toy Examples from Literature

Example 1 - Weil Pairing Computation

Source: On The Implementation Of Pairing-Based Cryptosystems - Ben Lynn (page 53 to 55)

Computing e(P, Q) given additional points R and S.

const toys = require("crypto-toys")

// Prepare curve parameters
let ec = {
        fieldN: 59,
        coeffA: 1,
        coeffB: 0,
        rorder: 5
    }

//Points for which the example is to be worked
let P = [[25,0], [30,0]]
let Q = [[(59-25),0], [0,30]]
let R = [[40,0], [54,0]]
let S = [[48,55], [28,51]]

//Pairing computation
toys.weilPairing(ec, P, Q, R, S, true)

//Expected Result: e(P, Q) = 46 + 56i

Example 2 - Weil Pairing Computation

Source: Pairings for beginners - Craig Costello (page 69 to 70)

Computing e(P, Q) given additional points R and S.

const toys = require("crypto-toys")

// Prepare curve parameters
let ec = {
        fieldN: 23,
        coeffA: -1,
        coeffB: 0,
        rorder: 3
    }

//Points for which the example is to be worked
let P = [[2,0], [11,0]]
let Q = [[21,0], [0,12]]
let R = [[0,17], [21,2]]
let S = [[18,10], [13,13]]

//Pairing computation
toys.weilPairing(ec, P, Q, R, S, true)

//Expected Result: e(P, Q) = 11 + 15i

Example 3 - Tate Pairing Computation

Source: Pairings for beginners - Craig Costello (page 74)

Computing e(P, Q) given additional point R.

const toys = require("crypto-toys")

// Prepare curve parameters
let ec = {
        fieldN: 19, 
        coeffA: 14, 
        coeffB: 3, 
        rorder: 5
    }


//Points for which the example is to be worked
let P = [[17,0], [9, 0]]
let Q = [[16,0], [0,16]]
let R = [[18,2], [14,5]]

//Pairing computation
toys.tatePairing(ec, P, Q, R, true)

//Expected Result: e(P, Q) = 2 + 15i

Clone and Build

git clone https://github.com/kaxxa123/crypto-toys.git
cd crypto-toys
npm install
npm run build

Crypto-Toys Command-Line Tool

After building crypto-toys, check all possible command line operations by running:

# List of all commands from npm
npm run help

# List of all commands from node
node ./build/src/toyscli --help

# Help for individual commands
node ./build/src/toyscli ecipoints --help

For each command, an npm script is available that allows to quickly see the command in action without entering any parameters. For example, to quickly see ecipoints in action:

npm run ecipoints

From here one can copy the command line used to generate the output and customize it to the required EC. For example (at the time of writing) the command generated for ecipoints is:

node ./build/src/toyscli.js ecipoints --fieldN 11 --coeffA 4 --coeffB 3

In this case fieldN is the integer field over which the EC operation is being computed. Whereas coeffA and coeffB are the A and B coefficients in the EC formula: y2 = x3 + Ax + B

For complete details on the parameters check the help for each command.


PLONK by Crypto-Toys

See details on how to run PLONK setup using Crypto-Toys.


References