Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
honk_key_gen.cpp
Go to the documentation of this file.
1
2#include <iostream>
3#include <memory>
4
11
16
17using namespace bb;
18
21
22template <typename Circuit> void generate_keys_honk(const std::string& output_path, std::string circuit_name)
23{
24 uint256_t public_inputs[6] = { 0, 0, 0, 0, 0, 0 };
25 UltraCircuitBuilder builder = Circuit::generate(public_inputs);
26
29 }
30
31 auto prover_instance = std::make_shared<ProverInstance>(builder);
32 auto verification_key = std::make_shared<VerificationKey>(prover_instance->get_precomputed());
33 UltraKeccakProver prover(prover_instance, verification_key);
34
35 // Make verification key file upper case
36 circuit_name.at(0) = static_cast<char>(std::toupper(static_cast<unsigned char>(circuit_name.at(0))));
37 std::string flavor_prefix = "Honk";
38
39 std::string vk_class_name = circuit_name + flavor_prefix + "VerificationKey";
40 std::string base_class_name = "Base" + flavor_prefix + "Verifier";
41 std::string instance_class_name = circuit_name + flavor_prefix + "Verifier";
42
43 {
44 auto vk_filename = output_path + "/keys/" + vk_class_name + ".sol";
45 std::ofstream os(vk_filename);
46 output_vk_sol_ultra_honk(os, verification_key, vk_class_name, true);
47 info("VK contract written to: ", vk_filename);
48 }
49}
50
51/*
52 * @brief Main entry point for the honk verification key generator
53 *
54 * 1. project_root_path: path to the solidity project root
55 * 2. srs_path: path to the srs db
56 */
57int main(int argc, char** argv)
58{
59 std::vector<std::string> args(argv, argv + argc);
60
61 if (args.size() < 4) {
62 info("usage: ", args[0], " [circuit type] [output path] [srs path]");
63 return 1;
64 }
65
66 const std::string circuit_flavor = args[1];
67 const std::string output_path = args[2];
68 const std::string srs_path = args[3];
69
71
72 info("Generating keys for ", circuit_flavor, " circuit");
73
74 if (circuit_flavor == "add2") {
75 generate_keys_honk<Add2Circuit>(output_path, circuit_flavor);
76 } else if (circuit_flavor == "blake") {
77 generate_keys_honk<BlakeCircuit>(output_path, circuit_flavor);
78 } else if (circuit_flavor == "ecdsa") {
79 generate_keys_honk<bb::EcdsaCircuit>(output_path, circuit_flavor);
80 } else if (circuit_flavor == "recursive") {
81 generate_keys_honk<bb::RecursiveCircuit>(output_path, circuit_flavor);
82 } else {
83 info("Unsupported circuit");
84 return 1;
85 }
86 return 0;
87} // namespace bb
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
static void add_default(Builder &builder)
Add default public inputs when they are not present.
void info(Args... args)
Definition log.hpp:75
AluTraceBuilder builder
Definition alu.test.cpp:124
int main(int argc, char **argv)
UltraKeccakFlavor::VerificationKey VerificationKey
void generate_keys_honk(const std::string &output_path, std::string circuit_name)
void output_vk_sol_ultra_honk(std::ostream &os, auto const &key, std::string const &class_name, bool include_types_import=false)
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13