2

I am looking to implement the zk-SNARK capabilities of Ethereum to allow a user to prove that they have all the components required ('a', 'b', 'c', 'd') to create a publicly known hash 'x'. My general problem can be defined as:

def main(x):
    sha3(a, b, c, d) == x
    return 1

I understand that there are two options to use when it comes to converting this general form program into a QAP and subsequent verification: ZoKrates (https://github.com/JacobEberhardt/ZoKrates) and libsnark (https://github.com/scipr-lab/libsnark).

Would anyone be able to help in guiding me through the steps to convert this into a workable piece of code:

  1. Constructing the circuit either using ZoKrates or libsnark
  2. Generating the proving and verifying key
  3. Generating proofs
  4. Verify the proof in Solidity

The documentation / practical examples are fairly limited so will appreciate any help that can be given.

4
  • Just FYI, libsnark has a built in SHA256 gadget, but no SHA3 gadget so you may want to consider sha256 as the hash. Commented Jul 17, 2018 at 18:22
  • I see, very helpful! Have you used this before?
    – MSM
    Commented Jul 18, 2018 at 10:53
  • Yes, but I don't have any public code to demonstrate it, unfortunately. I can say that it is very helpful to walk through the ZoKrates code to see how libsnark is translated to Solidity, then duplicate that yourself Commented Jul 18, 2018 at 14:01
  • This should be reopened, since there are concrete tutorials & solutions to this now (at least with SHA256)
    – ivicaa
    Commented Jan 12, 2019 at 17:33

0