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

Add a sindri proof create command #90

Merged
merged 13 commits into from
Mar 15, 2024
Merged

Conversation

sangaline
Copy link
Contributor

@sangaline sangaline commented Mar 14, 2024

This adds a basic sindri proof create command for generating a proof for the circuit. This currently just prints out the relevant subset of the API response, we don't attempt to save the outputs to disk or integrate with local tools. There's a --verify flag which optionally performs a remote verification of a proof, and a --tag flag which allows proving against a specific tag.

Usage: sindri proof create [options]

Create a proof for the circuit.

Options:
  -i, --input <input>  Input file for the proof (defaults to stdin in on-TTY; `input.json`, `example-input.json`, or `Prover.toml` otherwise).
  -t, --tag <tag>      Tag to generate the proof from. (default: "latest")
  -v, --verify         Perform verification of the proof after creating it.
  -h, --help           display help for command

This update also required a regeneration of the internal API client and the test fixtures, so there's a fair bit of noise in the diffs. The main files to pay attention to are src/lib/client.ts, src/cli/index.ts, and src/cli/proof.ts.

Closes #35

Copy link
Contributor

@katiemckeon katiemckeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great feature. I can foresee a lot of internal and external use cases for this one. Just one question at the bottom here.

Testing Performed

  • tested all the scaffold circuits deployed and proved in one self-contained flow
  • I tested sindri create proof against circuits that we're compiled via different access points (frontend rather than the CLI) and proof create is stable.
  • I tested the verify flag with all frameworks for proof inputs that should and should not verify. At first I was a little worried that halo2 was passing back proofs no matter what the verification result is, but then I recalled that the circuit outputs the equal status as a public output (similar to what you encountered with circom)

An observation

There are different levels of error handling going on. For instance, when I create the Noir "not equal" circuit scaffold, and I edit the prover.toml to be something that isn't proper TOML at all (e.g. erasing an equals sign), the CLI will pass back an error:

"error": "ProofInputInvalid",

But when I revise the Prover.toml to just have X not equal to Y, the result of proof create result is just blank

  "proofId": "d6a9922f-3d99-4d5c-922e-ccc1890f2ce1",
  "proof": null,
  "public": null,
  "verification_key": null
}

I have to go to the frontend to retrieve the error. Can you try to recreate this and see why? I was imagining that if the proof failed for any reason, I'd get back the error

@sangaline
Copy link
Contributor Author

Good catch, I was thinking that a proof status of Failed would raise an error but that isn't the case. We might want to change that, but it is consistent with how the circuit compilation works. I added better error handling around that and logging about the elapsed time as well to make it more consistent with sindri deploy:

$ sindri proof create
[23:32:36.377] ERROR: Proof generation failed after 6.5 seconds: cmd: nargo-v0.23.0 prove stdout:  stderr: error: Failed constraint
  ┌─ /workspace/proofs/2e96c4f5-7a6a-476c-a36b-f2a98b639695_1710459150565051/code/src/main.nr:5:12
  │
5 │     assert(X == Y);
  │            ------
  │
  = Call stack:
    1. /workspace/proofs/2e96c4f5-7a6a-476c-a36b-f2a98b639695_1710459150565051/code/src/main.nr:5:12

Cannot satisfy constraint

Copy link
Contributor

@katiemckeon katiemckeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sangaline sangaline merged commit 1bfc70d into main Mar 15, 2024
5 checks passed
@sangaline sangaline deleted the ews-add-proof-create-command-v2 branch March 15, 2024 13:55
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.

Add a sindri prove command
2 participants