TritonVM / triton-vm

Triton is a virtual machine that comes with Algebraic Execution Tables (AET) and Arithmetic Intermediate Representations (AIR) for use in combination with a STARK proof system.
https://triton-vm.org
Apache License 2.0
241 stars 36 forks source link

Add prove verify command #299

Closed cyberbono3 closed 2 months ago

cyberbono3 commented 3 months ago

Resolves #238

cargo run --example cmd prove --dst ./triton-vm/examples/proof.txt
Proof generated in: 43s
Proof size: 1820KB
Stark, claim and proof written to ./triton-vm/examples/proof.txt
cargo run --example cmd verify ./triton-vm/examples/proof.txt     
stark length: 103
claim length: 148
Proof verified in: 175.564791ms
cyberbono3 commented 3 months ago

Thanks for the PR!

I think this is a decent example showcasing how proofs can be stored on disk, read from disk, and subsequently verified. For a full resolution of #238, I think the main shortcomings are:

  • The program to be proven & verified is hardcoded. For a full-fledged CLI, the program (as well as input and non-determinism) should be given by the user at runtime.
  • Being an example, invocation of the CLI is a bit awkward. To me, it feels more natural to write triton-cli prove my_program.tasm than cargo run --example cmd prove my_program.tasm. If the PR added a crate (for example in the same workspace), that crate could be a standalone binary. This binary could then even be installed.

An additional note: As structopt is not actively developed anymore and superseded by clap, I think it is preferrable to use clap as the command line argument parser.

Should you have questions regarding some of these steps, feel free to ask. Also, please don't feel obligated by any of this; adding an example as a starting point for a full-fledged CLI is fine addition by itself.

Would you want to keep working on this?

yes!