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('Reusing', SETUP_FILEPATH)
// The override flag isn't present and the setup exists, so read it
setup = unstringifyBigInts(
JSON.parse(
readFileSync(
SETUP_FILEPATH,
'utf8'
)
)
)
provingKey = setup.provingKey
verifyingKey = setup.verifyingKey
} else {
// The override flag is present, so generate the setup
console.log('Generating setup', SETUP_FILEPATH)
setup = snarkjs.setup(circuit);
provingKey = setup.vk_proof
verifyingKey = setup.vk_verifier
writeFileSync(
SETUP_FILEPATH,
JSON.stringify(
stringifyBigInts({
provingKey,
verifyingKey
})
),
'utf8'
)
}
} catch (err) {
console.log('Error with the trusted setup')