Zkproof CLI Guide
Prerequisites
The snarkjs CLI tool is required. You can install it from this repository.
To install, use the following command:
npm install -g snarkjs@latest
.
After installation, you can test it by typing snarkjs --help
.
Preprocessing Text
To generate a proof two files are needed.
The original text and the subtext of the original text that you want to prove.
Both text files must have a length of 15872
symbols. If your original text is smaller, you must add zero byte symbols (\0x00
) to fill it up to 15872
.
For the subtext, you must fill it with \0x00
up to 15872
like the original text, except you must change symbols that you want to hide with zero byte symbols (\0x00
).
After that, you need to process the text to pass it to snarkjs
. Convert the text and subtext into arrays containing BigInt
(JavaScript) representation of text chunks (each chunk has a size of 31 bytes). After these transformations, create an input.json
file with the following format:
Here is example code that generates processed text
Generating Proof
To generate proof generation you need to call the snarkjs groth16 fullprove
CLI command with the following files that you can download from our repository:
input.json
: your input file (preprocessed text and subtext in JSON file format)circuit.wasm
: file containing circuits compiled in WASM format (you can find this file in our repository)circuit_final.zkey
: file containing verification keys (you can find this file in our repository)
This command creates two files: proof.json and public.json.
proof.json
contains the actual proofpublic.json
contains the values of the public inputs and output
Please save proof.json and public.json, because without these files, you cannot verify the proof!
Verifying Proof
For verification three files are needed - verification_key.json
(located in our repository), public.json
and proof.json
that you get from Generating Proof.
To verify proof you must write the following command:
snarkjs groth16 verify verification_key.json public.json proof.json
If all is well, you should see that OK has been outputted to your console. This signifies the proof is valid.
Last updated