| 28 | } // namespace |
| 29 | |
| 30 | void avm_prove(const std::filesystem::path& inputs_path, const std::filesystem::path& output_path) |
| 31 | { |
| 32 | avm2::AvmAPI avm; |
| 33 | auto inputs = avm2::AvmAPI::ProvingInputs::from(read_file(inputs_path)); |
| 34 | auto proof = avm.prove(inputs); |
| 35 | |
| 36 | // NOTE: As opposed to other proof systems, the public inputs are NOT part of the proof. |
| 37 | write_file(output_path / "proof", to_buffer(proof)); |
| 38 | |
| 39 | print_avm_stats(); |
| 40 | |
| 41 | // NOTE: Temporarily we also verify after proving. |
| 42 | // The reasoning is that proving will always pass unless it crashes. |
| 43 | // We want to return an exit code != 0 if the proof is invalid so that the prover client saves the inputs. |
| 44 | info("verifying..."); |
| 45 | bool res = avm.verify(proof, inputs.public_inputs); |
| 46 | info("verification: ", res ? "success" : "failure"); |
| 47 | if (!res) { |
| 48 | throw std::runtime_error("Generated proof is invalid!!!!!"); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | void avm_check_circuit(const std::filesystem::path& inputs_path) |
| 53 | { |
no test coverage detected