29 std::string
const& class_name,
30 bool include_types_import =
false)
32 const auto print_u256_const = [&](
const auto& element,
const std::string&
name) {
33 os <<
"uint256 constant " <<
name <<
" = " << element <<
";" <<
std::endl;
36 const auto print_u256 = [&](
const auto& element,
const std::string&
name) {
37 os <<
" " <<
name <<
": uint256(" << element <<
")," <<
std::endl;
40 const auto print_g1 = [&](
const auto& element,
const std::string&
name,
const bool last =
false) {
45 bb::U256Codec::template serialize_to_fields<
std::remove_cvref_t<
decltype(element)>>(element);
46 os <<
" " <<
name <<
": Honk.G1Point({ \n"
47 <<
" x: uint256(" << coords[0] <<
"),\n"
48 <<
" y: uint256(" << coords[1] <<
")\n"
60 const auto print_types_import = [&]() {
61 if (include_types_import) {
62 os <<
"import { Honk } from \"../HonkTypes.sol\";\n";
68"// SPDX-License-Identifier: Apache-2.0\n"
69 "// Copyright 2022 Aztec\n"
70 "pragma solidity >=0.8.21;\n"
74 print_u256_const(1 <<
key->log_circuit_size,
"N");
75 print_u256_const(
key->log_circuit_size,
"LOG_N");
76 print_u256_const(
key->num_public_inputs,
"NUMBER_OF_PUBLIC_INPUTS");
77 print_u256_const(
key->hash(),
"VK_HASH");
79 "library " << class_name <<
" {\n"
80 " function loadVerificationKey() internal pure returns (Honk.VerificationKey memory) {\n"
81 " Honk.VerificationKey memory vk = Honk.VerificationKey({\n";
82 print_u256(1 <<
key->log_circuit_size,
"circuitSize");
83 print_u256(
key->log_circuit_size,
"logCircuitSize");
84 print_u256(
key->num_public_inputs,
"publicInputsSize");
98 {
key->q_lookup(),
"qLookup" },
99 {
key->q_arith(),
"qArith" },
100 {
key->q_delta_range(),
"qDeltaRange" },
101 {
key->q_elliptic(),
"qElliptic" },
102 {
key->q_memory(),
"qMemory" },
103 {
key->q_nnf(),
"qNnf" },
104 {
key->q_poseidon2_external(),
"qPoseidon2External" },
105 {
key->q_poseidon2_internal(),
"qPoseidon2Internal" },
106 {
key->sigma_1(),
"s1" },
107 {
key->sigma_2(),
"s2" },
108 {
key->sigma_3(),
"s3" },
109 {
key->sigma_4(),
"s4" },
110 {
key->table_1(),
"t1" },
111 {
key->table_2(),
"t2" },
112 {
key->table_3(),
"t3" },
113 {
key->table_4(),
"t4" },
114 {
key->id_1(),
"id1" },
115 {
key->id_2(),
"id2" },
116 {
key->id_3(),
"id3" },
117 {
key->id_4(),
"id4" },
118 {
key->lagrange_first(),
"lagrangeFirst" },
119 {
key->lagrange_last(),
"lagrangeLast" },
126 "honk_key_gen G1 emission list is out of sync with the flavor's precomputed entity count");
129 for (
size_t i = 0; i < precomputed_commitments.size(); ++i) {
130 const auto& [commitment,
name] = precomputed_commitments[i];
131 print_g1(commitment, std::string(
name), i + 1 == precomputed_commitments.size());