1
$\begingroup$

I am using zkSNARK to prove knowledge of preimage for SHA256. However, the library used only supports field operations (such as add and multiply), and it compiles down to arithmetic circuits. Thus, bitwise operations prevalent in SHA256 have to be simulated using field operations. How can they be simulated, say, left shift?

This link contains a circuit for SHA256, but it is a boolean circuit.

To make things easy, we can assume the input is fixed-length, say, 255 bits (i.e., a field in the library).

$\endgroup$
2
  • $\begingroup$ Performance aside, a binary field is also a field, add and multiply become xor and and gates. Is it not possible to set the field to a binary field in snarkyjs? Shifting is simply rearranging wires. $\endgroup$
    – lamba
    Aug 3, 2022 at 21:43
  • $\begingroup$ Alas, the field is fixed as a 255 bit prime. $\endgroup$ Aug 3, 2022 at 22:36

1 Answer 1

1
$\begingroup$

What format of arithmetic circuits are you looking for? If you are needing some insight, this github repo contains python code for generating a SHA256 arithmetic circuit that is used for benchmarking Hyrax & Virgo.

$\endgroup$

Your Answer

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

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