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 🙏

© 2025 – Pkg Stats / Ryan Hefner

circomkit-ffi

v0.0.12

Published

<p align="center"> <h1 align="center"> Circomkit FFI </h1> <p align="center"><i>Rust-based static libraries for alternative provers.</i></p> </p>

Downloads

121

Readme

This repository contains an all-in-one adapter for several backends, mainly to be used by existing Javascript code via FFI. It features prover backends via:

It also provides SnarkJS exports for both prover backends, to export proof objects and public signals.

Installation

The FFI libraries are exposed through an SDK, which is published on NPM.

npm install circomkit-ffi

The libraries are kept under this repository's releases, and supports the following platforms & architectures:

  • Linux amd64
  • Linux arm64
  • MacOS Intel (amd64)
  • MacoS Apple Silicon (arm64)
  • Windows x86_64 (amd64)

Usage

The SDK exposes two types of classes:

  • CircomkitFFIBun is exported at /circomkit-ffi/bun and uses bun:ffi and must be used within a Bun runtime.
  • CircomkitFFINode uses ffi-rs and can be used by both Bun and Node.

[!NOTE]

CircomkitFFINode has a peer dependency for ffi-rs as well:

npm install ffi-rs

Downloading the library

First you need to download the library suited to your machine. We provide some utilities for this:

import { downloadRelease, getLibPath } from "circomkit-ffi";
import { existsSync } from "fs";

// you can point to any directory for the library to be downloaded at:
const libDir = "~/path/to/somewhere";

// you can get the path to library with `getLibPath`, it will attach the machine information to the file,
// e.g.: on MacOS & Apple Silicon it will be:
//   ~/path/to/somewhere/libcircomkit_ffi-macOS-arm64.dylib
const libPath = getLibPath(libDir);

// now we can download if needed
if (!existsSync(libPath)) {
  console.info("Downloading FFI library.");
  await downloadRelease(libDir);
}

Preparing Node SDK

The Node SDK is exported from /node path, and requires ffi-rs as a peer dependency.

import { CircomkitFFINode } from "circomkit-ffi/node";
import { open, load, close } from "ffi-rs";

// assume library exists at path `libPath`
const lib = new CircomkitFFINode(libPath, open, close, load);

Preparing Bun SDK

The Bun SDK is exported from /bun path, and works only for Bun runtime; trying to import this within Node runtime will cause an error.

import { CircomkitFFIBun } from "circomkit-ffi/bun";

// assume library exists at path `libPath`
const lib = new CircomkitFFIBun(libPath);

Using the SDK

We are all set! We now have access to all the functions within our static library. For example, we can call arkworks_prove to generate a proof using Arkworks. We just have to provide the necessary paths to R1CS, witness file and the prover key.

We can use a Circomkit instance to get these paths, but they can be manually written as well:

const { proof, publicSignals } = lib.arkworks_prove(
  circomkit.path.ofCircuitWithInput(circuitName, inputName, "wtns"),
  circomkit.path.ofCircuit(circuitName, "r1cs"),
  circomkit.path.ofCircuit(circuitName, "pkey")
);

[!TIP]

If for any reason you have to know whether you are in Bun or Node, you can use the isBun function exported by our SDK.

Development

Clone the repository:

git clone https://github.com/erhant/circomkit-ffi

Library

The library called by FFI is written in Rust. You can build the library (for your own machine) using:

cargo build

You can run the tests with:

cargo test

Before running tests:

  • you need to have installed SnarkJS globally, to verify that the FFI-generated proof is valid.
  • you need generated circuit files, which can be done using the commands below.
# preparations (do only once)
cd example
bun install

# create circuit (e.g. multiplier_3) artifacts for tests
CIRCUIT=multiplier_3
bunx circomkit witness $CIRCUIT default
bunx circomkit prove $CIRCUIT default
bunx circomkit json wtns $CIRCUIT default
bunx circomkit json r1cs $CIRCUIT

[!TIP]

You can take the library directly from within /target/debug/libcircomkit_ffi.<your-extension> and use with the SDK, for easier debugging with the SDK tests.

SDK

The SDK that provides an interface to the FFI-library is written in TypeScript, and we use Bun for this. Install packages with:

bun install

Run tests with:

bun test

You can build the package using:

bun run build.ts

Note that we only export ESM modules, we do not have CommonJS support.

Example

See the example folder.

Benchmarks

See the bench folder.

Acknowledgements

This project is kindly supported by Soulforge zkBankai grant, with the application here.

Some helpful resources for this project on FFI usage were:

License

This project is MIT licensed.