-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile-circuit.js
More file actions
35 lines (30 loc) · 981 Bytes
/
compile-circuit.js
File metadata and controls
35 lines (30 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { execSync } from 'child_process';
import * as snarkjs from 'snarkjs';
import fs from 'fs';
async function main() {
try {
// Compile the circuit
console.log('Compiling circuit...');
execSync('circom circuits/object_properties.circom --r1cs --wasm --sym');
// Generate zKey
console.log('Generating zKey...');
const entropy = await snarkjs.zKey.newZKey(
"object_properties.r1cs",
"pot12_final.ptau",
"object_properties.zkey",
console.log
);
// Export verification key
console.log('Exporting verification key...');
const vKey = await snarkjs.zKey.exportVerificationKey("object_properties.zkey");
fs.writeFileSync(
"public/circuits/verification_key.json",
JSON.stringify(vKey, null, 2)
);
console.log('Circuit compilation and setup complete!');
} catch (error) {
console.error('Error during circuit compilation:', error);
process.exit(1);
}
}
main().catch(console.error);