Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('The codemaster generates a proof', new Date())
// Codemaster generates the proof and public signals
const { proof, publicSignals } = snarkjs.genProof(provingKey, witness);
// Save to file
writeFileSync(
PROOF_AND_SIGNALS_DIR + '/' + i.toString() + '.json',
JSON.stringify(
stringifyBigInts({ proof, publicSignals }),
),
'utf8'
)
console.log('Verifying proof', new Date())
const isValid: boolean = snarkjs.isValid(verifyingKey, proof, publicSignals)
if (!isValid) {
throw new Error('Invalid proof')
} else {
console.log('Valid proof')
}
console.log('correctNumBlacks calculated by circuit:', witness[circuit.getSignalIdx('main.correctNumBlacks')])
console.log('correctNumWhites calculated by circuit:', witness[circuit.getSignalIdx('main.correctNumWhites')])
console.log('Hash calculated by JS :', testInput.pubSolnHash)
console.log('Hash calculated by circuit:', witness[circuit.getSignalIdx('main.solnHashOut')])
} catch (e) {
console.log(e)
}
i++