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
10
15
16using namespace bb;
17
20
21template <typename Circuit> void generate_keys_honk(const std::string& output_path, std::string circuit_name)
22{
23 uint256_t public_inputs[6] = { 0, 0, 0, 0, 0, 0 };
24 UltraCircuitBuilder builder = Circuit::generate(public_inputs);
25
28 }
29
31 auto verification_key = std::make_shared<VerificationKey>(proving_key->get_precomputed());
32 UltraKeccakProver prover(proving_key, verification_key);
33
34 // Make verification key file upper case
35 circuit_name.at(0) = static_cast<char>(std::toupper(static_cast<unsigned char>(circuit_name.at(0))));
36 std::string flavor_prefix = "Honk";
37
38 std::string vk_class_name = circuit_name + flavor_prefix + "VerificationKey";
39 std::string base_class_name = "Base" + flavor_prefix + "Verifier";
40 std::string instance_class_name = circuit_name + flavor_prefix + "Verifier";
41
42 {
43 auto vk_filename = output_path + "/keys/" + vk_class_name + ".sol";
44 std::ofstream os(vk_filename);
45 output_vk_sol_ultra_honk(os, verification_key, vk_class_name, true);
46 info("VK contract written to: ", vk_filename);
47 }
48}
49
50/*
51 * @brief Main entry point for the honk verification key generator
52 *
53 * 1. project_root_path: path to the solidity project root
54 * 2. srs_path: path to the srs db
55 */
56int main(int argc, char** argv)
57{
58 std::vector<std::string> args(argv, argv + argc);
59
60 if (args.size() < 4) {
61 info("usage: ", args[0], " [circuit type] [output path] [srs path]");
62 return 1;
63 }
64
65 const std::string circuit_flavor = args[1];
66 const std::string output_path = args[2];
67 const std::string srs_path = args[3];
68
70
71 info("Generating keys for ", circuit_flavor, " circuit");
72
73 if (circuit_flavor == "add2") {
74 generate_keys_honk<Add2Circuit>(output_path, circuit_flavor);
75 } else if (circuit_flavor == "blake") {
76 generate_keys_honk<BlakeCircuit>(output_path, circuit_flavor);
77 } else if (circuit_flavor == "ecdsa") {
78 generate_keys_honk<bb::EcdsaCircuit>(output_path, circuit_flavor);
79 } else if (circuit_flavor == "recursive") {
80 generate_keys_honk<bb::RecursiveCircuit>(output_path, circuit_flavor);
81 } else {
82 info("Unsupported circuit");
83 return 1;
84 }
85 return 0;
86} // namespace bb
A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the informat...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
void info(Args... args)
Definition log.hpp:70
AluTraceBuilder builder
Definition alu.test.cpp:123
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.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static void add_default_to_public_inputs(Builder &builder)
Adds default public inputs to the builder.