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

sindri

v0.0.1-alpha.61

Published

The Sindri Labs JavaScript SDK and CLI tool.

Downloads

1,321

Readme

Sindri CLI and TypeScript SDK

Build License Version

CLI Quickstart | CLI Docs | SDK Quickstart | SDK Docs | Development

Sindri is a platform that makes compiling Zero-Knowledge Proof circuits in any framework and generating proofs with full GPU acceleration as easy and scalable as serverless platforms like AWS Lambda. The CLI tool offers an easy and intuitive interface for circuit development and deployment that will feel very familiar to anyone who has used Docker, Git, Heroku, or NPM.

For more information about the Sindri platform, please check out sindri.app. The best way to get started with the Sindri CLI is to begin with the Sindri CLI Quickstart and to then refer to the Sindri CLI Reference Docs for more detailed information about the CLI commands and options. For the TypeScript SDK, you can similarly check out the TypeScript SDK Quickstart and the TypeScript SDK Reference Docs.

Why Should I Use Sindri?

Sindri makes it easy to develop circuits in the framework of your choice, and to deploy them in a highly scalable and cost-effective way. You only pay for what you use, and you can scale up to thousands of GPUs in seconds. Our public circuit registry also makes it easy to share and reuse circuits, so you can build off of circuits that have already been audited and battle tested even if they're written in a different framework than the one you're using.

Using the Sindri CLI

This section provides the essentials to get started with the CLI. The Sindri CLI Quickstart goes into more detail on each of these steps and is the recommended way to get started.

Installation

The Sindri CLI tool is available as an NPM package and can be installed with the following command:

npm install -g sindri@latest

Authentication

To compile circuits on Sindri, you'll need to have an account and authenticate the CLI to use it. Visit sindri.app to find more details about account creation. You can then use the sindri login command to create a machine-local API key that will be used for subsequent commands.

sindri login

Circuit Project Creation

The Sindri CLI provides a project scaffolding tool to help you get started with circuit development. The sindri init command will initialize a new circuit project for you with everything you need to get started.

sindri init my-circuit

Linting Circuits

You can run sindri lint from within your circuit project directory to perform local checks to ensure your circuit is valid and ready for compilation. This will not actually compile your circuit, but will perform basic checks to uncover issues that would prevent your circuit from compiling successfully.

sindri lint

Circuit Compilation

To compile your circuit on the Sindri platform, you can use the sindri deploy command to upload and compile it. If there are compilation errors, they will be reported, and the command will exit with a non-zero exit code.

sindri deploy

Proof Generation

You can use the sindri proof create command to create a new proof for your circuit.

sindri proof create --input proof-input.json

Using the TypeScript SDK

This section provides the essentials to get started with the TypeScript SDK. The SDK is fully compatible with both TypeScript and JavaScript, NodeJS and browser environments, and CommonJS and ES Module import systems. For more detailed information about getting started, please take a look at the TypeScript SDK Quickstart and the TypeScript SDK Reference Docs.

Installation

The TypeScript SDK is provided by the same sindri package that provides the CLI tool. You can add it to your project by running.

npm install sindri@latest

Authentication

When you run sindri login, a machine-local API key will automatically be stored in a config file in your home directory and used for authentication with both the CLI and the SDK. You can alternatively set a SINDRI_API_KEY environment variable to override this, or specify an API key manually when authorizing the client. Visit https://sindri.app/signup/ to create an account first and https://sindri.app/z/me/page/settings/api-keys to create an API key.

import sindri from "sindri";

sindri.authorize({ apiKey: "my-key-here" });

Circuit Compilation

You can use the SindriClient.createCircuit() method to compile a new version of a circuit.

import sindri from "sindri";

// Compile the circuit in the `/path/to/my/circuit/` directory.
const circuit = await sindri.createCircuit("/path/to/my/circuit/");

Proof Generation

You can use the SindriClient.proveCircuit() method to generate a proof for a circuit.

import sindri from "sindri";

const circuitIdentifier = "my-circuit";
const proofInput = JSON.stringify({ X: 5, Y: 32 });
const proof = await sindri.proveCircuit(circuitIdentifier, proofInput);

Development

Using Docker

Most of the project commands should be relatively easy to run natively on any system with node and npm installed, but a Docker Compose configuration is provided as a convenience. In addition to ensuring that the proper dependencies are available, the container is also configured to install the package globally as a symbolic link with npm link and automatically rebuild it whenever files change. This means that the sindri command inside the container should always reflect your local code changes.

You can bring the container up in the usual way.

docker compose up

This will install the latest packages and start the build process in watch mode so that it rebuilds whenever local files change.

To drop into a shell in the running container, you can run the following.

docker compose exec sindri-js bash

From here, you can use the sindri command or run any of the npm script invocations for linting, formatting, etc.

Integrating With Local Development Server

Inside of the Docker container, you can run

sindri -d login -u http://host.docker.internal login

to authenticate against a Sindri development backend running locally on port 80. Both your credentials and the local base URL for the server will be stored in sindri.conf.json and used in subsequent requests.

Installing Dependencies

To install the project dependencies:

npm install

Building

Development Build

To run the build process in development mode and watch for file changes:

npm run build:watch

This command will run automatically in the container if you're using Docker Compose.

Production Build

To perform a production build with minified outputs:

npm run build

Testing

Test Production Builds

The test suite can be run with:

npm run test

This will first build the project and then run the tests against the build outputs using pre-recorded fixtures for network requests. To skip the build step, you can use npm run test:fast.

Test Watcher

In development, you can use

npm run test:watch

to rebuild the project and rerun the tests whenever there are code changes. Additionally, this command will allow network requests without fixtures to go through, so this is useful when writing new tests.

Recording Test Fixtures

This command will build the project and record new fixtures for all network requests.

npm run test:record

You will need to have your environment authenticated with an API key for the "Sindri CLI/SDK Testing Team" organization on Sindri in order to make the necessary network requests for recording fixtures. The credentials stored by sindri login will be used automatically for the tests.

Updating the API Client

This will fetch the latest OpenAPI schema for the Sindri API and autogenerate an updated API client in src/lib/api/.

npm run generate-api

To develop against unreleased API features, you can use these variants to target a local development server:

# If you're not using Docker:
npm run generate-api:dev

# Or...

# If you are using Docker:
npm run generate-api:docker

You can also generate against stage with:

npm run generate-api:stage

Updating Sindri Manifest JSON Schema

The Sindri Manifest JSON Schema is stored in sindri-manifest.json and needs to be manually updated and committed when the schema changes. The file can be updated by running:

npm run download-sindri-manifest-schema

To develop against an unreleased version of the schema, you can use these variants to target a local development server:

# If you're not using Docker:
npm run download-sindri-manifest-schema:dev

# Or...

# If you are using Docker:
npm run download-sindri-manifest-schema:docker

Linting

To lint the project with Eslint and Prettier:

npm run lint

This check will already run on CI.

Formatting

To reformat the project using Prettier:

npm run format

Type Checking

To check the TypeScript types:

npm run type-check

This check will already run on CI.