async function generateZokratesFiles(directoryPath, suppress) {
  const files = await readdirAsync(directoryPath);

  console.group(`Setup for directory ${directoryPath}`);

  const directoryWithSlash = directoryPath.endsWith('/') ? directoryPath : `${directoryPath}/`;

  let codeFile;
  // Look for a .code file that's not out.code. That's the file we're compiling.
  for (let j = 0; j < files.length; j += 1) {
    if (files[j].endsWith('.code') && files[j] !== 'out.code') {
      codeFile = files[j];
      break;
    }
  }

  console.log('Compiling at', `${directoryWithSlash}${codeFile}`);

  // Generate out.code and out in the same directory.
  const compileOutput = await compile(
    `${directoryWithSlash}${codeFile}`,
    directoryWithSlash,
    'out',
    {
      verbose: !suppress,
    },
  );
  if (!suppress) console.log('Compile output:', compileOutput);
  console.log('Finished compiling at', directoryPath);

  console.log('Running setup on', directoryPath);
  // Generate verification.key and proving.key
  const setupOutput = await setup(
    `${directoryWithSlash}out`,
    directoryWithSlash,
    'gm17',
    'verification.key',
    'proving.key',
    { verbose: !suppress },
  );
  if (!suppress) console.log('Setup output:', setupOutput);
  console.log('Finished setup at', directoryPath);

  console.log('Running export-verifier at', directoryPath);
  const exportVerifierOutput = await exportVerifier(
    `${directoryWithSlash}/verification.key`,
    directoryWithSlash,
    'verifier.sol',
    'gm17',
    { verbose: !suppress },
  );
  if (!suppress) console.log('Export-verifier output:', exportVerifierOutput);
  console.log('Finished export-verifier at', directoryPath);

  console.log(`Extracting key from ${directoryWithSlash}verifier.sol`);
  const vkJson = await keyExtractor(`${directoryWithSlash}verifier.sol`, true);

  console.log(`Writing ${directoryWithSlash}${codeFile.split('.')[0]}-vk.json`);
  // Create a JSON with the file name but without .code
  fs.writeFileSync(`${directoryWithSlash}${codeFile.split('.')[0]}-vk.json`, vkJson, err => {
    if (err) {
      console.error(err);
    }
  });
  console.log(directoryPath, 'is done setting up.');
  console.groupEnd();
}
/**
 * Given a directory that contains a .code file, calls Zokrates compile, setup and export verifier
 * @param {String} directoryPath
 * @param {Boolean} suppress - Flag for logging out zokrates output or not.
 */
Given a directory that contains a .code file, calls Zokrates compile, setup and export verifier
@param {String} directoryPath
@param {Boolean} suppress - Flag for logging out zokrates output or not.
Given a directory that contains a . code file calls Zokrates compile setup and export verifier @param { String } directoryPath @param { Boolean } suppress - Flag for logging out zokrates output or not .
async function generateZokratesFiles(directoryPath, suppress) {
  const files = await readdirAsync(directoryPath);
  console.group(`Setup for directory ${directoryPath}`);
  const directoryWithSlash = directoryPath.endsWith('/') ? directoryPath : `${directoryPath}/`;
  let codeFile;
  for (let j = 0; j < files.length; j += 1) {
    if (files[j].endsWith('.code') && files[j] !== 'out.code') {
      codeFile = files[j];
      break;
    }
  }
  console.log('Compiling at', `${directoryWithSlash}${codeFile}`);
  const compileOutput = await compile(
    `${directoryWithSlash}${codeFile}`,
    directoryWithSlash,
    'out',
    {
      verbose: !suppress,
    },
  );
  if (!suppress) console.log('Compile output:', compileOutput);
  console.log('Finished compiling at', directoryPath);
  console.log('Running setup on', directoryPath);
  const setupOutput = await setup(
    `${directoryWithSlash}out`,
    directoryWithSlash,
    'gm17',
    'verification.key',
    'proving.key',
    { verbose: !suppress },
  );
  if (!suppress) console.log('Setup output:', setupOutput);
  console.log('Finished setup at', directoryPath);
  console.log('Running export-verifier at', directoryPath);
  const exportVerifierOutput = await exportVerifier(
    `${directoryWithSlash}/verification.key`,
    directoryWithSlash,
    'verifier.sol',
    'gm17',
    { verbose: !suppress },
  );
  if (!suppress) console.log('Export-verifier output:', exportVerifierOutput);
  console.log('Finished export-verifier at', directoryPath);
  console.log(`Extracting key from ${directoryWithSlash}verifier.sol`);
  const vkJson = await keyExtractor(`${directoryWithSlash}verifier.sol`, true);
  console.log(`Writing ${directoryWithSlash}${codeFile.split('.')[0]}-vk.json`);
  fs.writeFileSync(`${directoryWithSlash}${codeFile.split('.')[0]}-vk.json`, vkJson, err => {
    if (err) {
      console.error(err);
    }
  });
  console.log(directoryPath, 'is done setting up.');
  console.groupEnd();
}
async function generateZokratesFiles ( directoryPath , suppress ) { const files = await readdirAsync ( directoryPath ) ; console . group ( ` ${ directoryPath } ` ) ; const directoryWithSlash = directoryPath . endsWith ( '/' ) ? directoryPath : ` ${ directoryPath } ` ; let codeFile ; for ( let j = 0 ; j < files . length ; j += 1 ) { if ( files [ j ] . endsWith ( '.code' ) && files [ j ] !== 'out.code' ) { codeFile = files [ j ] ; break ; } } console . log ( 'Compiling at' , ` ${ directoryWithSlash } ${ codeFile } ` ) ; const compileOutput = await compile ( ` ${ directoryWithSlash } ${ codeFile } ` , directoryWithSlash , 'out' , { verbose : ! suppress , } , ) ; if ( ! suppress ) console . log ( 'Compile output:' , compileOutput ) ; console . log ( 'Finished compiling at' , directoryPath ) ; console . log ( 'Running setup on' , directoryPath ) ; const setupOutput = await setup ( ` ${ directoryWithSlash } ` , directoryWithSlash , 'gm17' , 'verification.key' , 'proving.key' , { verbose : ! suppress } , ) ; if ( ! suppress ) console . log ( 'Setup output:' , setupOutput ) ; console . log ( 'Finished setup at' , directoryPath ) ; console . log ( 'Running export-verifier at' , directoryPath ) ; const exportVerifierOutput = await exportVerifier ( ` ${ directoryWithSlash } ` , directoryWithSlash , 'verifier.sol' , 'gm17' , { verbose : ! suppress } , ) ; if ( ! suppress ) console . log ( 'Export-verifier output:' , exportVerifierOutput ) ; console . log ( 'Finished export-verifier at' , directoryPath ) ; console . log ( ` ${ directoryWithSlash } ` ) ; const vkJson = await keyExtractor ( ` ${ directoryWithSlash } ` , true ) ; console . log ( ` ${ directoryWithSlash } ${ codeFile . split ( '.' ) [ 0 ] } ` ) ; fs . writeFileSync ( ` ${ directoryWithSlash } ${ codeFile . split ( '.' ) [ 0 ] } ` , vkJson , err => { if ( err ) { console . error ( err ) ; } } ) ; console . log ( directoryPath , 'is done setting up.' ) ; console . groupEnd ( ) ; }
Given a directory that contains a .code file, calls Zokrates compile, setup and export verifier
 @param {String} directoryPath
 @param {Boolean} suppress - Flag for logging out zokrates output or not.
Given a directory that contains a . code file calls Zokrates compile setup and export verifier @param { String } directoryPath @param { Boolean } suppress - Flag for logging out zokrates output or not .
// Look for a .code file that's not out.code. That's the file we're compiling. // Generate out.code and out in the same directory. // Generate verification.key and proving.key // Create a JSON with the file name but without .code