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
9
14
15using namespace bb;
16
19
20template <typename Circuit> void generate_keys_honk(const std::string& output_path, std::string circuit_name)
21{
22 uint256_t public_inputs[6] = { 0, 0, 0, 0, 0, 0 };
23 UltraCircuitBuilder builder = Circuit::generate(public_inputs);
24
25 auto prover_instance = std::make_shared<ProverInstance>(builder);
26 auto verification_key = std::make_shared<VerificationKey>(prover_instance->get_precomputed());
27 UltraKeccakProver prover(prover_instance, verification_key);
28
29 // Make verification key file upper case
30 circuit_name.at(0) = static_cast<char>(std::toupper(static_cast<unsigned char>(circuit_name.at(0))));
31 std::string flavor_prefix = "Honk";
32
33 std::string vk_class_name = circuit_name + flavor_prefix + "VerificationKey";
34 std::string base_class_name = "Base" + flavor_prefix + "Verifier";
35 std::string instance_class_name = circuit_name + flavor_prefix + "Verifier";
36
37 {
38 auto vk_filename = output_path + "/keys/" + vk_class_name + ".sol";
39 std::ofstream os(vk_filename);
40 output_vk_sol_ultra_honk(os, verification_key, vk_class_name, true);
41 info("VK contract written to: ", vk_filename);
42 }
43}
44
45/*
46 * @brief Main entry point for the honk verification key generator
47 *
48 * 1. project_root_path: path to the solidity project root
49 * 2. srs_path: path to the srs db
50 */
51int main(int argc, char** argv)
52{
53 std::vector<std::string> args(argv, argv + argc);
54
55 if (args.size() < 4) {
56 info("usage: ", args[0], " [circuit type] [output path] [srs path]");
57 return 1;
58 }
59
60 const std::string circuit_flavor = args[1];
61 const std::string output_path = args[2];
62 const std::string srs_path = args[3];
63
65
66 info("Generating keys for ", circuit_flavor, " circuit");
67
68 if (circuit_flavor == "add2") {
69 generate_keys_honk<Add2Circuit>(output_path, circuit_flavor);
70 } else if (circuit_flavor == "blake") {
71 generate_keys_honk<BlakeCircuit>(output_path, circuit_flavor);
72 } else if (circuit_flavor == "ecdsa") {
73 generate_keys_honk<bb::EcdsaCircuit>(output_path, circuit_flavor);
74 } else if (circuit_flavor == "recursive") {
75 generate_keys_honk<bb::RecursiveCircuit>(output_path, circuit_flavor);
76 } else {
77 info("Unsupported circuit");
78 return 1;
79 }
80 return 0;
81} // namespace bb
Base Native verification key class.
Definition flavor.hpp:135
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
NativeVerificationKey_< PrecomputedEntities< Commitment >, Codec, HashFunction, CommitmentKey > VerificationKey
#define info(...)
Definition log.hpp:93
AluTraceBuilder builder
Definition alu.test.cpp:124
int main(int argc, char **argv)
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