Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto return #360

Merged
merged 5 commits into from
Oct 14, 2022
Merged

Auto return #360

merged 5 commits into from
Oct 14, 2022

Conversation

guipublic
Copy link
Contributor

With this PR, prover does not need to provide the main return value and can instead write in the prover.toml:
return = ""

Note that the return parameter must still be present in prover.toml, but we can give an empty value instead using an empty string.
Generating the proof will also create the verifier.toml (it overwrites if already existing) with the public inputs (including the return value if there is one) corresponding to the provided prover.toml.

Here is a bit of context:
The main() function of a noir program can return a public value, which is computed by this noir program.
However, this public value is also a public input for the ZK proof so this requires the prover to compute by itself the value and put it in the provel.toml in order to generate the proof.
But the computation itself can be delicate if the noir program is doing a lof of (e.g. cryptographic) stuff. On the other hand, generating a proof of execution is also executing the program so noir should have already computed this value and it should not be necessary for the prover to provide the main return value.
This follows the concerns expressed in issue 355 [https://github.com//issues/355]

@jfecher
Copy link
Contributor

jfecher commented Oct 5, 2022

So when we have return = "" in the prover.toml it is now expected to write the actual return value into the Verifier.toml and create the file if it doesn't currently exist, correct? Does it rewrite the prover.toml with the correct return value as well?

@guipublic
Copy link
Contributor Author

In all cases (i.e with a return="" , or with return="5", or with no return at all), it now generates the verifier.toml, and overwrites existing file.
The correct value will be in the verifier.toml, if there is a return value, whether or not it is specified in the prover.toml

  • The prover.toml is never changed.
  • The verifier.toml is always generated during prove
  • The verifier.toml is never modified during verify

crates/nargo/src/cli/prove_cmd.rs Outdated Show resolved Hide resolved
crates/nargo/src/cli/prove_cmd.rs Outdated Show resolved Hide resolved
crates/nargo/src/cli/prove_cmd.rs Outdated Show resolved Hide resolved
@guipublic
Copy link
Contributor Author

Undefined arrays returned from main does not work, so I return an error in that case.
I will fix this issue in a separate PR.

@guipublic guipublic merged commit ba9a034 into master Oct 14, 2022
@guipublic guipublic deleted the gd/auto_return2 branch October 14, 2022 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants