3

What do the values provided with the -a option in ZoKrates witness computation represent? Are these values typically private to each user or public, similar to verification keys?

Also how are they generated?

The picture below shows a screenshot from the ZoKrates CMD on windows 10

enter image description here

2 Answers 2

2

I'm not familiar with Zokrates, so let provide a partially generic answer.

I assume this is related to proof generation. When generating proofs, depending on the used ZK proving system, your program (circuit?) can have public and private inputs.

For example, if you have a ZK program which is used to prove that you know a such that a ^ b = c, then a is private and b and c are public.

Since a should stay private, you need to generate the proof on your machine. If everything was public, you could just send the values somewhere and another entity could generate the proof for you. Witness generation is a part of the proof generation process.

1

The arguments given to -a are the arguments that will be passed to your main function. These can be public or private depending on the main functions type signature. If you look at the final proof.json that is generated, you'll see the public arguments are included while the private ones are not.

Note that they need to be flattened and passed as a space-separated list. For example, if your main function takes two fields, i.e. main(field a, field b), you should pass two arguments, e.g. -a 1 2. If your main function is main(field[5] a, field b), you should pass an argument list like -a 1 2 3 4 5 6, so a = [1, 2, 3, 4, 5] and b = 6. You can find some more examples in the documentation of ZoKrates.

Note that you can also pass the arguments as JSON, by using the --abi flag. This will be more convenient if your arguments are arrays or structs. This is explained in more detail in the official documentation. When using ABI format, take care to encode types correctly. For example, a field is passed a JSON string (e.g. "42") while an integer type like u32 is passed as a JSON string containing its hexadecimal representation (e.g. "0x2a" for 42).

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.