Skip to content

Commit

Permalink
Merge pull request #241 from privacy-scaling-explorations/feat/setup-…
Browse files Browse the repository at this point in the history
…local-key

feat(setup-local-keys): do not compute zkeys again
  • Loading branch information
ctrlc03 authored Dec 29, 2023
2 parents cd58f8f + a4da4e8 commit f0c965b
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions packages/phase2cli/src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { zKey } from "snarkjs"
import boxen from "boxen"
import { createWriteStream, Dirent, renameSync } from "fs"
import { createWriteStream, Dirent, renameSync, existsSync } from "fs"
import { pipeline } from "node:stream"
import { promisify } from "node:util"
import fetch from "node-fetch"
Expand Down Expand Up @@ -537,20 +537,33 @@ const setup = async (cmd: { template?: string; auth?: string }) => {
`clock`
)
spinner.start()
await zKey.newZKey(
r1csLocalPathAndFileName,
getPotLocalFilePath(circuit.files.potFilename),
zkeyLocalPathAndFileName,
undefined
)
spinner.succeed(
`Generation of the genesis zKey for citcui ${theme.text.bold(circuit.name)} completed successfully`
)

if (existsSync(zkeyLocalPathAndFileName)) {
spinner.succeed(
`The genesis zKey for circuit ${theme.text.bold(circuit.name)} is already present on disk`
)
} else {
await zKey.newZKey(
r1csLocalPathAndFileName,
getPotLocalFilePath(circuit.files.potFilename),
zkeyLocalPathAndFileName,
undefined
)
spinner.succeed(
`Generation of the genesis zKey for circuit ${theme.text.bold(circuit.name)} completed successfully`
)
}

const hashSpinner = customSpinner(
`Calculating hashes for circuit ${theme.text.bold(circuit.name)}...`,
`clock`
)
hashSpinner.start()
// 4. calculate the hashes
const wasmBlake2bHash = await blake512FromPath(wasmLocalPathAndFileName)
const potBlake2bHash = await blake512FromPath(getPotLocalFilePath(circuit.files.potFilename))
const initialZkeyBlake2bHash = await blake512FromPath(zkeyLocalPathAndFileName)
hashSpinner.succeed(`Hashes for circuit ${theme.text.bold(circuit.name)} calculated successfully`)

// 5. upload the artifacts

Expand Down

0 comments on commit f0c965b

Please sign in to comment.