Just noticed today that ZoKrates has finally support for SHA256! I wanted to see it in action, so I followed the tutorial at https://zokrates.github.io/sha256example.html with a slight modification of the form

def main(private field a, private field b, private field c, private field d, field h0Pub, field h1Pub) -> (field):
    h0, h1 = sha256packed(a, b, c, d)
    h0 == h0Pub
    h1 == h1Pub
    return 1

./zokrates compute-witness -a 0 0 0 5 263561599766550617289250058199814760685 65303172752238645975888084098459749904

Witness, proof, and solidity verification contract can be created. However, if I try to send the proof with public inputs to the verification contract (verifyTx function) the function returns false.

Contracts are deployed and called with truffle 4.1.3 and tested on ganache-cli 6.1.0

Any idea/hint?

1 Answer 1


The problem was that input from proof.json was not in string hex representation like the rest of the fields.

"input" : [263561599766550617289250058199814760685,65303172752238645975888084098459749904,1] 

I passed this 1:1 as argument in truffle for verifyTx, which led to some precision loss.

After converting this to string hex representation everything worked fine!


The call in truffle:

var p = require("./proof.json").proof;
var i = require("./proof.json").input;

verifier.verifyTx(p.A, p.A_p, p.B, p.B_p, p.C, p.C_p, p.H, p.K, i);

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.