Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generates wrong proof #1323

Open
ray837 opened this issue Jun 5, 2023 · 1 comment
Open

Generates wrong proof #1323

ray837 opened this issue Jun 5, 2023 · 1 comment

Comments

@ray837
Copy link

ray837 commented Jun 5, 2023

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();
@dark64
Copy link
Member

dark64 commented Jun 13, 2023

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

This code is semantically invalid and should not compile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants