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