UNPKG

@chainwayxyz/phase2cli

Version:

All-in-one interactive command-line for interfacing with zkSNARK Phase 2 Trusted Setup ceremonies

89 lines (78 loc) 3.19 kB
#!/usr/bin/env node import { createCommand } from "commander" import { readFileSync } from "fs" import { dirname } from "path" import { fileURLToPath } from "url" import { setup, auth, authSIWE, authBandada, contribute, observe, finalize, clean, logout, validate, listCeremonies } from "./commands/index.js" import setCeremonyCommands from "./commands/ceremony/index.js" // Get pkg info (e.g., name, version). const packagePath = `${dirname(fileURLToPath(import.meta.url))}/..` const { description, version, name } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8")) const program = createCommand() // Entry point. program.name(name).description(description).version(version) // User commands. program.command("auth").description("authenticate yourself using your Github account (OAuth 2.0)").action(auth) program .command("auth-bandada") .description("authenticate yourself in a privacy-perserving manner using Bandada") .action(authBandada) program .command("auth-siwe") .description("authenticate yourself using your Ethereum account (Sign In With Ethereum - SIWE)") .action(authSIWE) program .command("contribute") .description("compute contributions for a Phase2 Trusted Setup ceremony circuits") .option("-c, --ceremony <string>", "the prefix of the ceremony you want to contribute for", "") .option("-e, --entropy <string>", "the entropy (aka toxic waste) of your contribution", "") .option("-a, --auth <string>", "the Github OAuth 2.0 token", "") .action(contribute) program .command("clean") .description("clean up output generated by commands from the current working directory") .action(clean) program.command("list").description("List all ceremonies prefixes").action(listCeremonies) program .command("logout") .description("sign out from Firebae Auth service and delete Github OAuth 2.0 token from local storage") .action(logout) program .command("validate") .description("validate that a Ceremony Setup file is correct") .requiredOption("-t, --template <path>", "The path to the ceremony setup template", "") .option("-c, --constraints <number>", "The number of constraints to check against") .action(validate) // Only coordinator commands. const coordinate = program.command("coordinate").description("commands for coordinating a ceremony") coordinate .command("setup") .description("setup a Groth16 Phase 2 Trusted Setup ceremony for zk-SNARK circuits") .option("-t, --template <path>", "The path to the ceremony setup template", "") .option("-a, --auth <string>", "The Github OAuth 2.0 token", "") .action(setup) coordinate .command("observe") .description("observe in real-time the waiting queue of each ceremony circuit") .action(observe) coordinate .command("finalize") .description( "finalize a Phase2 Trusted Setup ceremony by applying a beacon, exporting verification key and verifier contract" ) .option("-a, --auth <string>", "the Github OAuth 2.0 token", "") .action(finalize) setCeremonyCommands(program) program.parseAsync(process.argv)