async function checkCorrectness(value, publicKey, salt, commitment, commitmentIndex, fTokenShield) {
  console.log('Checking h(A|pk|S) = z...');
  const commitmentCheck = utils.concatenateThenHash(value, publicKey, salt);
  const zCorrect = commitmentCheck === commitment;
  console.log('commitment:', commitment);
  console.log('commitmentCheck:', commitmentCheck);

  console.log(
    'Checking the commitment exists in the merkle-tree db (and therefore was emitted as an event on-chain)...',
  );
  console.log('commitment:', commitment);
  console.log('commitmentIndex:', commitmentIndex);
  const { contractName } = fTokenShield.constructor._json; // eslint-disable-line no-underscore-dangle
  const leaf = await merkleTree.getLeafByLeafIndex(contractName, commitmentIndex);
  console.log('leaf found:', leaf);
  if (leaf.value !== commitment)
    throw new Error(
      `Could not find commitment ${commitment} at the given commitmentIndex ${commitmentIndex} in  the merkle-tree microservice. Found ${leaf.value} instead.`,
    );

  const zOnchainCorrect = leaf.value === commitment;
  console.log('commitment:', commitment);
  console.log('commitment emmitted by blockchain:', leaf.value);

  return {
    zCorrect,
    zOnchainCorrect,
  };
}
/**
checks the details of an incoming (newly transferred token), to ensure the data we have received is correct and legitimate!!
*/
checks the details of an incoming (newly transferred token), to ensure the data we have received is correct and legitimate
checks the details of an incoming ( newly transferred token ) to ensure the data we have received is correct and legitimate
async function checkCorrectness(value, publicKey, salt, commitment, commitmentIndex, fTokenShield) {
  console.log('Checking h(A|pk|S) = z...');
  const commitmentCheck = utils.concatenateThenHash(value, publicKey, salt);
  const zCorrect = commitmentCheck === commitment;
  console.log('commitment:', commitment);
  console.log('commitmentCheck:', commitmentCheck);
  console.log(
    'Checking the commitment exists in the merkle-tree db (and therefore was emitted as an event on-chain)...',
  );
  console.log('commitment:', commitment);
  console.log('commitmentIndex:', commitmentIndex);
  const { contractName } = fTokenShield.constructor._json; 
  const leaf = await merkleTree.getLeafByLeafIndex(contractName, commitmentIndex);
  console.log('leaf found:', leaf);
  if (leaf.value !== commitment)
    throw new Error(
      `Could not find commitment ${commitment} at the given commitmentIndex ${commitmentIndex} in  the merkle-tree microservice. Found ${leaf.value} instead.`,
    );
  const zOnchainCorrect = leaf.value === commitment;
  console.log('commitment:', commitment);
  console.log('commitment emmitted by blockchain:', leaf.value);
  return {
    zCorrect,
    zOnchainCorrect,
  };
}
async function checkCorrectness ( value , publicKey , salt , commitment , commitmentIndex , fTokenShield ) { console . log ( 'Checking h(A|pk|S) = z...' ) ; const commitmentCheck = utils . concatenateThenHash ( value , publicKey , salt ) ; const zCorrect = commitmentCheck === commitment ; console . log ( 'commitment:' , commitment ) ; console . log ( 'commitmentCheck:' , commitmentCheck ) ; console . log ( 'Checking the commitment exists in the merkle-tree db (and therefore was emitted as an event on-chain)...' , ) ; console . log ( 'commitment:' , commitment ) ; console . log ( 'commitmentIndex:' , commitmentIndex ) ; const { contractName } = fTokenShield . constructor . _json ; const leaf = await merkleTree . getLeafByLeafIndex ( contractName , commitmentIndex ) ; console . log ( 'leaf found:' , leaf ) ; if ( leaf . value !== commitment ) throw new Error ( ` ${ commitment } ${ commitmentIndex } ${ leaf . value } ` , ) ; const zOnchainCorrect = leaf . value === commitment ; console . log ( 'commitment:' , commitment ) ; console . log ( 'commitment emmitted by blockchain:' , leaf . value ) ; return { zCorrect , zOnchainCorrect , } ; }
checks the details of an incoming (newly transferred token), to ensure the data we have received is correct and legitimate!
checks the details of an incoming ( newly transferred token ) to ensure the data we have received is correct and legitimate!
// eslint-disable-line no-underscore-dangle