I've asked that question on some places, got a few answers but I'm still missing the bigger piece. I'd like to experiment with zk-snarks. In particular, I'd like to be able to do something similar to this tutorial, i.e., write a program to prove some computation based on a pair of public and secret values, such as:

function senderFunction(x, w) {
  return (
    w.senderBalanceBefore > w.value &&
    sha256(w.value) == x.hashValue &&
    sha256(w.senderBalanceBefore) == x.hashSenderBalanceBefore &&
    sha256(w.senderBalanceBefore - w.value) == x.hashSenderBalanceAfter
var proof = zksnarkprove(
    [hashSenderBalanceBefore, hashSenderBalanceAfter, hashValue],
    [senderBalanceBefore, senderBalanceAfter, hashValue]);

And then be able to verify the correctness of this computation without knowing w from inside an Ethereum contract, for example:

    [hashSenderBalanceBefore, hashSenderBalanceAfter, hashValue],

Is there anything already implemented that allows me to experiment with this usage?

2 Answers 2


Please find the zksnarks solidity code:


The transaction can be seen on Etherscan and was made on the testnet.


My answer is a fairly dumb one, as I've only had a look around in the code, and I haven't looked into zk-SNARKs properly yet, so apologies in advance if it's no help.

The cpp-ethereum implementation contains the libdevcrypto library, which itself contains LibSnark.cpp. This seems to be built into a separate project with its own cmake file, and there's a set of associated unit test files. There doesn't seem to be anything in any of the other clients (including Parity).

The test file I linked to contains this comment, which would imply something is working at least...

// This verifies a full zkSNARK proof. Let's see if this hocus-pocus actually works...

  • 1
    It's in the development pipeline, and will likely be there through 2017.
    – Todd Baur
    Commented Jul 15, 2017 at 8:29
  • @Richard please can you advise, how to use in my smart contact? Do I need any extra setup for this?
    – Parwej
    Commented Jul 4, 2018 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.