From b6813ff9fd9c83cadf0f60e2fb340456b56321e1 Mon Sep 17 00:00:00 2001 From: Will Kim Date: Wed, 25 Sep 2019 14:27:18 -0400 Subject: [PATCH] fix: corrected input to computeWitness --- lib/compute-witness.js | 12 +++++++++++- lib/generate-proof.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/compute-witness.js b/lib/compute-witness.js index 7d37566..02a9c18 100644 --- a/lib/compute-witness.js +++ b/lib/compute-witness.js @@ -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'); } @@ -30,6 +31,7 @@ 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 => { @@ -37,13 +39,21 @@ async function computeWitness(codePath, outputDirectory = './', outputName = 'wi '/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(); }); diff --git a/lib/generate-proof.js b/lib/generate-proof.js index 764a3af..9054dc2 100644 --- a/lib/generate-proof.js +++ b/lib/generate-proof.js @@ -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');