|
|
|
@ -47,30 +47,24 @@ export const runSetupAndExport = async (plugin: CircomPluginClient, appState: Ap |
|
|
|
|
const zkey_final = { type: "mem" } |
|
|
|
|
|
|
|
|
|
if (appState.provingScheme === 'groth16') { |
|
|
|
|
console.log('running groth16 setup') |
|
|
|
|
await snarkjs.zKey.newZKey(r1cs, ptau_final, zkey_final) |
|
|
|
|
if (appState.exportVerificationKey) { |
|
|
|
|
console.log('exportVerificationKey') |
|
|
|
|
const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) |
|
|
|
|
await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/groth16/zk/keys/verification_key.json`, JSON.stringify(vKey, null, 2)) |
|
|
|
|
} |
|
|
|
|
if (appState.exportVerificationContract) { |
|
|
|
|
console.log('exportVerificationContract') |
|
|
|
|
const templates = { groth16: GROTH16_VERIFIER } |
|
|
|
|
const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) |
|
|
|
|
|
|
|
|
|
await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/groth16/zk/build/zk_verifier.sol`, solidityContract) |
|
|
|
|
} |
|
|
|
|
} else if (appState.provingScheme === 'plonk') { |
|
|
|
|
console.log('running plonk setup') |
|
|
|
|
await snarkjs.plonk.setup(r1cs, ptau_final, zkey_final) |
|
|
|
|
if (appState.exportVerificationKey) { |
|
|
|
|
console.log('exportVerificationKey') |
|
|
|
|
const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) |
|
|
|
|
await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/plonk/zk/keys/verification_key.json`, JSON.stringify(vKey, null, 2)) |
|
|
|
|
} |
|
|
|
|
if (appState.exportVerificationContract) { |
|
|
|
|
console.log('exportVerificationContract') |
|
|
|
|
const templates = { plonk: PLONK_VERIFIER } |
|
|
|
|
const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) |
|
|
|
|
|
|
|
|
|