Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum

Home Page:https://zokrates.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generates wrong proof

ray837 opened this issue · comments

commented

Description

Generates wrong proof for given zokrates code ,which generates false as ouput every time when verified.Below code is implemented in reactjs app.
const runZokrates = async () => {
const zokratesProvider = await initialize();
const code = def main(private field a) -> field { return true; };
const artifacts = await zokratesProvider.compile(code);

  const {witness,output} =  await zokratesProvider.computeWitness(artifacts,["2"]);
  
  console.log(witness); // Resulting witness which can be used to generate a proof
  console.log(output); // Computation output: "4"
  
  setWitness(witness);
  setOutput(output);

  const keypair = await zokratesProvider.setup(artifacts.program);
  setkeypair(keypair)

  const proof = await zokratesProvider.generateProof(artifacts.program,witness,keypair);
  setproof(proof)

//  console.log([proof.proof.a, proof.proof.b, proof.proof.c], proof.inputs);

  const { ethereum } = window;
  const provider = new ethers.providers.Web3Provider(ethereum);
  const signer = provider.getSigner();
  const contract = "0x2e48698055571a60cA9Fb9F052254d4e7A097092";

  const con = new ethers.Contract(contract,Verifier.abi,signer);
  console.log(con)
  const res = await con.verifyTx([proof.proof.a,proof.proof.b,proof.proof.c],proof.inputs);

  const isVerified = zokratesProvider.verify(keypair.vk, proof);
  //console.log(isVerified)
  console.log('Proof:', proof);
  console.log('Is Verified:', isVerified);
  console.log("Res"+res)

};

runZokrates();

const code = def main(private field a) -> field { return true; };

This code is semantically invalid and should not compile?