-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbundle-test.js
28 lines (22 loc) · 976 Bytes
/
bundle-test.js
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
const { genProof, verifyProof } = require("./dist/bundle");
const SNARK_FIELD_SIZE = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617")
const ZqField = require("ffjavascript").ZqField
const Fq = new ZqField(SNARK_FIELD_SIZE)
const fs = require("fs");
const path = require("path");
const { poseidon } = require("circomlibjs");
const preimage = Fq.random();
const hash = poseidon([preimage]);
const wasmFilePath = path.join("./zkFiles", "circuit.wasm")
const finalZkeyPath = path.join("./zkFiles", "circuit_final.zkey")
const vkeyPath = path.join("./zkFiles", "verification_key.json")
const grothInput = {
preimage
};
(async () => {
const fullProof = await genProof(grothInput, wasmFilePath, finalZkeyPath);
const vKey = JSON.parse(fs.readFileSync(vkeyPath, "utf-8"))
const res = await verifyProof(vKey, { proof: fullProof.proof, publicSignals: [hash] });
console.log('verified: ', res);
process.exit(0);
})();