Skip to content

Commit

Permalink
fix: corrected input to computeWitness
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Kim committed Sep 25, 2019
1 parent 9d98837 commit b6813ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/compute-witness.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { spawn } = childProcess;
* @param {Array} arguments to pass to compute witness (flag -a)
*/
async function computeWitness(codePath, outputDirectory = './', outputName = 'witness', args) {
console.log('hiya');
if (!fs.existsSync(codePath)) {
throw new Error('compute-witness codePath input file(s) not found');
}
Expand All @@ -30,20 +31,29 @@ async function computeWitness(codePath, outputDirectory = './', outputName = 'wi
// Ensure path ends with '/'
const parsedOutputPath = outputDirectory.endsWith('/') ? outputDirectory : `${outputDirectory}/`;

console.log('hello there');
// TODO: I haven't been able to test if the args actually pass properly,
// if you run into issues with this function that is probably it.
return new Promise(resolve => {
const zokrates = spawn(
'/app/zokrates',
['compute-witness', '-i', codePath, '-o', `${parsedOutputPath}${outputName}`, '-a', args],
{
stdio: 'ignore',
stdio: ['pipe', 'pipe', 'pipe'],
env: {
ZOKRATES_HOME: '/app/stdlib',
},
},
);

zokrates.stdout.on('data', data => {
console.log(data);
});

zokrates.stderr.on('data', data => {
console.log(data);
});

zokrates.on('close', () => {
resolve();
});
Expand Down
2 changes: 1 addition & 1 deletion lib/generate-proof.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function generateProof(provingKeyPath, codePath, provingScheme, options) {
const { directory } = options;
const parsedOutputPath = directory.endsWith('/') ? directory : `${directory}/`;

const { fileName } = options;
const fileName = options.fileName ? options.fileName : 'proof.json';
const parsedFileName = fileName.endsWith('.json') ? fileName : `${fileName}.json`;

args.push('-o');
Expand Down

0 comments on commit b6813ff

Please sign in to comment.