Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.8k stars 360 forks source link

Using the output of compilation via CLI as input to the computeWitness function of zokrates-js #1336

Closed spencer-coti closed 1 year ago

spencer-coti commented 1 year ago

Abstract

I would like to be able to use the output file generated by running zokrates compile -i ... as the input to the computeWitness function in zokrates-js

Motivation

The CLI is already a powerful tool and very comfortable to work with, so I would prefer to use this output as opposed to finding a way to import the raw code to a NodeJS script, format it as needed and compile it there. This problem is further compounded by the fact that my circuit is very large and imports modules from the standard library as well as from custom modules.

spencer-coti commented 1 year ago

For anyone searching for this in the future, here is how I was able to do it:

const buffer = readFileSync(PATH_TO_OUT_FILE)
const program = Uint8Array.from(buffer)
console.log(program)

You will notice that the output is the same as when you compile with zokrates-js