Alice wants to prove a statement (let's say, she has a secret value x such that x * 2 = 10) to Bob without revealing x).
Alice generates a proof using the ZK-Snark protocol.
const { proof, publicSignals } = await snarkjs.groth16.fullProve(
sampleInput,
"circuits/quadratic.wasm",
"circuits/quadratic.zkey"
);
// Construct the raw calldata to be sent to the verifier contract
const rawcalldata = await snarkjs.groth16.exportSolidityCallData(
proof,
publicSignals
);
let jsonCalldata = JSON.parse("[" + rawcalldata + "]");
The verifier contract exposes a public function, let's call it "verifyProof," which takes the calldata (proof) provided by the prover. How can one prevent others from calling the verifier contract with the same calldata as the prover?
it("proves the proof", async () => {
assert.isTrue(
await verifier.verifyProof(
jsonCalldata[0],
jsonCalldata[1],
jsonCalldata[2],
jsonCalldata[3]
)
);
});