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

jigg

v1.0.1

Published

JavaScript Implementation of Garbled Gates (two-party computation library for boolean circuits)

Downloads

32

Readme

JIGG

JavaScript implementation of garbled gates and 2PC boolean circuit protocols.

Requirements and Installation

This library is implemented entirely in JavaScript. Running the server requires Node.js, npm (both installed via yum install nodejs npm or brew install npm on macOS), Socket.IO, and libsodium.

Run npm to install all JIGG dependencies:

npm install

Project Layout

├─ circuits/        Circuit files
│  ├─ macros/       Macro files to assemble circuits using [CASM](https://github.com/wyatt-howe/macro-circuit-assembler)
│  └─ bristol/      Bristol format files
├─ demo/            Demo for client-server deployment scenario
├─ src/             Library modules implementing protocol steps for participants
│  ├─ comm/         Communications modules (such as for OT)
│  ├─ modules/         Data structure modules (such as circuits)
│  └─ utils/        Other utility modules (such as cryptographic primitives)
├─ test/            End-to-end tests
└─ tutorial/        Interactive tutorial on using JIGG

Running The tutorial

You can run the tutorial interactively on your local machine, after cloning JIGG, by using

cd path/to/JIGG
npm run tutorial

Running Demo Circuit Applications

Start the communications server from server.js with the command below:

node demo/server.js <port number>

As a Browser Party

Parties can go to http://localhost:<port>/ in a web browser supporting JavaScript to begin communications.

As a Node.js Party

Connect a new party in Node.js by running:

node demo/party.js <port> <role> <input> <encoding> <circuitName>
# <role>: Garbler or Evaluator
# <input>: string with no whitespaces
# <encoding>: bits, number, or hex
# <circuitName>: must include file extension
#                demo will run bristol circuit found at
#                'circuits/bristol/<circuitName>'

For example to join an AES-128 computation as the garbler, run:

node demo/party.js 3000 Evaluator 00000000000000000000000000000000 hex aes-128-reverse.txt

Server + Garbler/Evaluator

The server may also run as a garbler or evaluator. You can acheive this by running the server with the same arguments as a party:

node demo/server.js <port> <role> <input> <encoding> <circuitName>

Demo Circuits

We have a variety of circuits available under circuits/bristol mostly from this page.

Circuit Format

JIGG can parse a circuit in the standardized 'Bristol Format' which is supported by several compiled MPC libraries such as SCALE-MAMBA.

4 8
2 2 2
1 3
2 1 0 1 4 AND
2 1 2 3 5 XOR
1 1 5 6 INV
2 1 4 6 7 AND

Circuit Assembler

To create a new circuit, write a macro with existing circuits as its gates and run the macro-circuit-assembler with:

npm run casm -- <path_to_macro> <output_path>

For example, this macro assembles an AND circuit over 8 bits using existing 4 bit AND circuits:

npm run casm -- circuits/macros/and-8.casm circuits/and-8.txt

Running Tests

All of the built-in test vectors can be verified in npm test. The tests will run a server automatically. These are end-to-end tests.

Capabilities

JIGG is designed for semi-honest parties (in either node or in the browser). We support point-and-permute, free-XOR, free single-input gates, and encryption from a random oracle (fixed-key XChaCha20). The half-AND optimization is compatible but not yet supported. The default label size is 128 bits and relies on JavaScript's Uint8Array class. The simple-labels branch demonstrates dynamically-sized labels (that are 53 bits in length or less) without using arrays. Some potential improvements are listed in the to-do section.

Contributing

JIGG is fully functional as it is now, but there's still more to do (see the list below) before version 1. Pull requests are welcome for any improvement. The JIGG source is maintained with the help of ESLint for style and the included test suite for stability.

To Do

  • Half-AND gate optimization
  • Standardize JSON/serialized/compressed formats for inter-party messages compatible with SIGG

Information and Collaborators

More information about this project, including collaborators and publications, can be found at multiparty.org.