Skip to content

privacy-scaling-explorations/snark-artifacts

Repository files navigation

🗄️ SNARK Artifacts

A streamlined mechanism for distributing SNARK artifacts.

P0tion has made conducting SNARK phase 2 trusted setup ceremonies easier for many zero-knowledge projects. However, there still seems to be no simple mechanism for distributing the artifacts generated in ceremonies. This project aims to build step-by-step a simple and easily accessible mechanism for distributing zero-knowledge artifacts (wasm/zkey files).

For more info here see: OVERVIEW.md.

Interested in contributing to this project? See the board and upcoming issues to work on or propose other ideas.

Note

This system is probably best suited to small and medium-sized circuits.

Artifacts

Package Version Downloads Circuits JS library
@zk-kit/poseidon-artifacts NPM version Downloads poseidon-proof.circom @zk-kit/poseidon-proof
@zk-kit/semaphore-artifacts NPM version Downloads semaphore.circom @semaphore-protocol/proof
@zk-kit/semaphore-identity-artifacts NPM version Downloads identity-proof.circom @semaphore-extensions/identity-proof

🚀 Features

  • Reliable endpoints: A curated set of SNARK artifacts ready for use in various zero-knowledge proof applications across major CDNs.
  • Easy Integration: Seamless integration with existing cryptographic frameworks and systems through utility functions.
  • Linear versioning mechanism: A simple and consistent versioning system that reflects changes in relative circuits.
  • File integrity: A system that guarantees the integrity of the artifacts.
  • Automated Distribution: A system that automatically distributes artifacts after the ceremony (possibly through P0tion).

📜 Getting Started

To add a new set of artifacts for your project, simply add your NPM package to the packages folder. The packages are published on NPM and made available on your preferred CDN (e.g. https://unpkg.com).

You can also create issue and let the core contributors add your files.

Partial clone

For a more manageable clone that includes only the packages relevant to you or none of them, we use git's sparse-checkout and --filter features. This will reduce clone time and improve git performance.

git clone --sparse --filter=blob:none <forkedUrl>

And finally, if you need a specific package:

git sparse-checkout add packages/<package>

For convenience we provide an interactive setup script.
It will ask you where to clone the repository, and what packages you want to sparse checkout.

bash <(curl https://raw.githubusercontent.com/privacy-scaling-explorations/snark-artifacts/main/scripts/bin/setup.bash) fetch

After the first time clone, you can use the following npm scripts:

  • npm run sparse-checkout: to add/remove packages from sparse checkout.
  • npm run gprf: pull rebase your active branch with --filter=blob:none to avoid downloading what you may not want (unfortunately sparse checkout alone won't prevent syncing what you haven't sparsed checkout).

Downloading artifacts

ZK-Kit provides a set of functions to automatically download your artifacts. For example:

import { maybeGetSnarkArtifacts, Project } from '@zk-kit/artifacts'

// It will return the artifacts' paths.
const { wasm, zkey } = await maybeGetSnarkArtifacts(Project.POSEIDON, {
  parameters: [2],
  version: '1.0.0',
})

console.log(wasm) // "/tmp/@zk-kit/poseidon-artifacts@1.0.0/poseidon-2.wasm"
console.log(zkey) // "/tmp/@zk-kit/poseidon-artifacts@1.0.0/poseidon-2.zkey"

// Paths on browsers will be the `unpkg` URLs directly.
// e.g. https://unpkg.com/@zk-kit/poseidon-artifacts@1.0.0/poseidon-2.zkey

You can download all artifacts from this repository with:

bash <(curl -sSL https://raw.githubusercontent.com/privacy-scaling-explorations/snark-artifacts/main/scripts/bin/dowload-artifacts.bash) -h