Skip to content

Commit

Permalink
Merge pull request #1029 from privacy-scaling-explorations/fix/circui…
Browse files Browse the repository at this point in the history
…ts-shell
  • Loading branch information
ctrlc03 authored Jan 16, 2024
2 parents 4e64f8f + 4c121ca commit 2ba8855
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions circuits/ts/compile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type CircomkitConfig, type CircuitConfig, Circomkit } from "circomkit";

import { execSync } from "child_process";
import { execFileSync } from "child_process";
import fs from "fs";
import path from "path";

Expand Down Expand Up @@ -60,7 +60,8 @@ export const compileCircuits = async (cWitness?: boolean, outputPath?: string):
if (cWitness) {
try {
// build
execSync(`cd ${outPath}/${circuit.name}_cpp && make`);
execFileSync("cd", [`${outPath}/${circuit.name}_cpp`]);
execFileSync("make");
} catch (error) {
throw new Error(`Failed to compile the c witness for ${circuit.name}`);
}
Expand Down
18 changes: 9 additions & 9 deletions circuits/ts/proofs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
type ISnarkJSVerificationKey,
} from "snarkjs";

import { execSync } from "child_process";
import { execFileSync } from "child_process";
import fs from "fs";
import { tmpdir } from "os";
import path from "path";
Expand Down Expand Up @@ -73,21 +73,21 @@ export const genProof = async ({
fs.writeFileSync(inputJsonPath, jsonData);

// Generate the witness
const witnessGenCmd = `${witnessExePath} ${inputJsonPath} ${outputWtnsPath}`;

execSync(witnessGenCmd, { stdio: silent ? "ignore" : "pipe" });
execFileSync(witnessExePath!, [inputJsonPath, outputWtnsPath], { stdio: silent ? "ignore" : "pipe" });

if (!fs.existsSync(outputWtnsPath)) {
throw new Error(`Error executing ${witnessGenCmd}`);
throw new Error(`Error executing ${witnessExePath} ${inputJsonPath} ${outputWtnsPath}`);
}

// Generate the proof
const proofGenCmd = `${rapidsnarkExePath} ${zkeyPath} ${outputWtnsPath} ${proofJsonPath} ${publicJsonPath}`;

execSync(proofGenCmd, { stdio: silent ? "ignore" : "pipe" });
execFileSync(rapidsnarkExePath!, [zkeyPath, outputWtnsPath, proofJsonPath, publicJsonPath], {
stdio: silent ? "ignore" : "pipe",
});

if (!fs.existsSync(proofJsonPath)) {
throw new Error(`Error executing ${proofGenCmd}`);
throw new Error(
`Error executing ${rapidsnarkExePath} ${zkeyPath} ${outputWtnsPath} ${proofJsonPath} ${publicJsonPath}`,
);
}

// Read the proof and public inputs
Expand Down

0 comments on commit 2ba8855

Please sign in to comment.