diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 42734bf5cd1..0ca963d4f87 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -105,6 +105,7 @@ set(BARRETENBERG_TARGET_OBJECTS $ $ $ + $ $ $ $ @@ -128,6 +129,7 @@ set(BARRETENBERG_TARGET_OBJECTS $ $ $ + $ $ $ $ diff --git a/barretenberg/cpp/src/barretenberg/barretenberg.hpp b/barretenberg/cpp/src/barretenberg/barretenberg.hpp index eaa55743c88..5bc5639a805 100644 --- a/barretenberg/cpp/src/barretenberg/barretenberg.hpp +++ b/barretenberg/cpp/src/barretenberg/barretenberg.hpp @@ -15,6 +15,7 @@ #include "crypto/keccak/keccak.hpp" #include "crypto/pedersen_commitment/pedersen.hpp" #include "crypto/pedersen_hash/pedersen.hpp" +#include "crypto/poseidon2/poseidon2.hpp" #include "crypto/schnorr/schnorr.hpp" #include "crypto/sha256/sha256.hpp" #include "ecc/curves/bn254/fq.hpp" @@ -41,6 +42,7 @@ #include "stdlib/hash/blake2s/blake2s.hpp" #include "stdlib/hash/blake3s/blake3s.hpp" #include "stdlib/hash/pedersen/pedersen.hpp" +#include "stdlib/hash/poseidon2/poseidon2.hpp" #include "stdlib/merkle_tree/hash.hpp" #include "stdlib/merkle_tree/membership.hpp" #include "stdlib/merkle_tree/memory_store.hpp" diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp index 15a3a8bd555..12f79c040d9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp @@ -40,9 +40,8 @@ template class Poseidon2Permutation { using MatrixDiagonal = std::array; using RoundConstantsContainer = std::array; - static constexpr MatrixDiagonal internal_matrix_diagonal = - Poseidon2Bn254ScalarFieldParams::internal_matrix_diagonal; - static constexpr RoundConstantsContainer round_constants = Poseidon2Bn254ScalarFieldParams::round_constants; + static constexpr MatrixDiagonal internal_matrix_diagonal = Params::internal_matrix_diagonal; + static constexpr RoundConstantsContainer round_constants = Params::round_constants; static constexpr void matrix_multiplication_4x4(State& input) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 18d44941e56..6572e08a6a2 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -59,8 +59,8 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, acir_composer->create_circuit(constraint_system, witness); acir_composer->init_proving_key(); - auto proof_data = acir_composer->create_proof(*is_recursive); - *out = to_heap_buffer(proof_data); + auto proof = acir_composer->create_proof(*is_recursive); + *out = to_heap_buffer(proof); } WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, @@ -73,8 +73,11 @@ WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); acir_composer->create_circuit(constraint_system, witness); - auto proof_data = acir_composer->accumulate(); - *out = to_heap_buffer(proof_data); + auto proof = acir_composer->accumulate(); + auto proof_data_buf = to_buffer( + proof); // template parameter needs to be set so that vector deserialization from + // buffer, which reads the size at the beginning can be done properly + *out = to_heap_buffer(proof_data_buf); } WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, @@ -87,8 +90,11 @@ WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); acir_composer->create_circuit(constraint_system, witness); - auto proof_data = acir_composer->accumulate_and_prove(); - *out = to_heap_buffer(proof_data); + auto proof = acir_composer->accumulate_and_prove(); + auto proof_data_buf = to_buffer( + proof); // template parameter needs to be set so that vector deserialization from + // buffer, which reads the size at the beginning can be done properly + *out = to_heap_buffer(proof_data_buf); } WASM_EXPORT void acir_load_verification_key(in_ptr acir_composer_ptr, uint8_t const* vk_buf) @@ -125,14 +131,16 @@ WASM_EXPORT void acir_get_proving_key(in_ptr acir_composer_ptr, uint8_t const* a WASM_EXPORT void acir_goblin_verify_accumulator(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) { auto acir_composer = reinterpret_cast(*acir_composer_ptr); - auto proof = from_buffer>(proof_buf); + auto proof_data_buf = from_buffer>(proof_buf); + auto proof = from_buffer>(proof_data_buf); *result = acir_composer->verify_accumulator(proof); } WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) { auto acir_composer = reinterpret_cast(*acir_composer_ptr); - auto proof = from_buffer>(proof_buf); + auto proof_data_buf = from_buffer>(proof_buf); + auto proof = from_buffer>(proof_data_buf); *result = acir_composer->verify(proof); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp index 3b0adc0ae5c..f287e5c9105 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp @@ -21,13 +21,13 @@ void GoblinAcirComposer::create_circuit(acir_format::AcirFormat& constraint_syst GoblinMockCircuits::construct_goblin_ecc_op_circuit(builder_); } -std::vector GoblinAcirComposer::accumulate() +std::vector GoblinAcirComposer::accumulate() { // // Construct a GUH proof for the circuit via the accumulate mechanism // return goblin.accumulate_for_acir(builder_); // Construct one final GUH proof via the accumulate mechanism - std::vector ultra_proof = goblin.accumulate_for_acir(builder_); + std::vector ultra_proof = goblin.accumulate_for_acir(builder_); // Construct a Goblin proof (ECCVM, Translator, Merge); result stored internally goblin.prove_for_acir(); @@ -35,15 +35,15 @@ std::vector GoblinAcirComposer::accumulate() return ultra_proof; } -bool GoblinAcirComposer::verify_accumulator(std::vector const& proof) +bool GoblinAcirComposer::verify_accumulator(std::vector const& proof) { return goblin.verify_accumulator_for_acir(proof); } -std::vector GoblinAcirComposer::accumulate_and_prove() +std::vector GoblinAcirComposer::accumulate_and_prove() { // Construct one final GUH proof via the accumulate mechanism - std::vector ultra_proof = goblin.accumulate_for_acir(builder_); + std::vector ultra_proof = goblin.accumulate_for_acir(builder_); // Construct a Goblin proof (ECCVM, Translator, Merge); result stored internally goblin.prove_for_acir(); @@ -51,7 +51,7 @@ std::vector GoblinAcirComposer::accumulate_and_prove() return ultra_proof; } -bool GoblinAcirComposer::verify(std::vector const& proof) +bool GoblinAcirComposer::verify(std::vector const& proof) { // Verify the final GUH proof bool ultra_verified = goblin.verify_accumulator_for_acir(proof); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp index 6556b548045..a533cba1830 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp @@ -28,9 +28,9 @@ class GoblinAcirComposer { * @brief Accumulate a circuit via Goblin * @details For the present circuit, construct a GUH proof and the vkey needed to verify it * - * @return std::vector The GUH proof bytes + * @return std::vector The GUH proof bytes */ - std::vector accumulate(); + std::vector accumulate(); /** * @brief Verify the Goblin accumulator (the GUH proof) using the vkey internal to Goblin @@ -38,7 +38,7 @@ class GoblinAcirComposer { * @param proof * @return bool Whether or not the proof was verified */ - bool verify_accumulator(std::vector const& proof); + bool verify_accumulator(std::vector const& proof); /** * @brief Accumulate a final circuit and construct a full Goblin proof @@ -48,14 +48,14 @@ class GoblinAcirComposer { * accumulation phase. * */ - std::vector accumulate_and_prove(); + std::vector accumulate_and_prove(); /** * @brief Verify the final GUH proof and the full Goblin proof * * @return bool verified */ - bool verify(std::vector const& proof); + bool verify(std::vector const& proof); private: acir_format::GoblinBuilder builder_; diff --git a/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt index 35e543283ee..ce7c008ee65 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt @@ -17,4 +17,4 @@ target_precompile_headers( $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/field_impl_generic.hpp"> $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/field_impl_x64.hpp"> $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/field.hpp"> -) +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp new file mode 100644 index 00000000000..3c34ad7561a --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp @@ -0,0 +1,116 @@ + +#include "barretenberg/ecc/fields/field_conversion.hpp" + +namespace bb::field_conversion { + +static constexpr uint64_t NUM_CONVERSION_LIMB_BITS = 68; // set to be 68 because bigfield has 68 bit limbs +static constexpr uint64_t TOTAL_BITS = 254; + +bb::fr convert_from_bn254_frs(std::span fr_vec, bb::fr* /*unused*/) +{ + ASSERT(fr_vec.size() == 1); + return fr_vec[0]; +} + +bool convert_from_bn254_frs(std::span fr_vec, bool* /*unused*/) +{ + ASSERT(fr_vec.size() == 1); + return fr_vec[0] != 0; +} + +/** + * @brief Converts 2 bb::fr elements to grumpkin::fr + * @details First, this function must take in 2 bb::fr elements because the grumpkin::fr field has a larger modulus than + * the bb::fr field, so we choose to send 1 grumpkin::fr element to 2 bb::fr elements to maintain injectivity. + * For the implementation, we want to minimize the number of constraints created by the circuit form, which happens to + * use 68 bit limbs to represent a grumpkin::fr (as a bigfield). Therefore, our mapping will split a grumpkin::fr into a + * 136 bit chunk for the lower two bigfield limbs and the upper chunk for the upper two limbs. The upper chunk ends up + * being 254 - 2*68 = 118 bits as a result. This is why we check that the bb::frs must be at most 136 and 118 bits + * respectively (to ensure no overflow). Then, we converts the two chunks to a grumpkin::fr using uint256_t conversions. + * @param low_bits_in + * @param high_bits_in + * @return grumpkin::fr + */ +grumpkin::fr convert_from_bn254_frs(std::span fr_vec, grumpkin::fr* /*unused*/) +{ + // Combines the two elements into one uint256_t, and then convert that to a grumpkin::fr + ASSERT(uint256_t(fr_vec[0]) < (uint256_t(1) << (NUM_CONVERSION_LIMB_BITS * 2))); // lower 136 bits + ASSERT(uint256_t(fr_vec[1]) < + (uint256_t(1) << (TOTAL_BITS - NUM_CONVERSION_LIMB_BITS * 2))); // upper 254-136=118 bits + uint256_t value = uint256_t(fr_vec[0]) + (uint256_t(fr_vec[1]) << (NUM_CONVERSION_LIMB_BITS * 2)); + grumpkin::fr result(value); + return result; +} + +curve::BN254::AffineElement convert_from_bn254_frs(std::span fr_vec, + curve::BN254::AffineElement* /*unused*/) +{ + curve::BN254::AffineElement val; + val.x = convert_from_bn254_frs(fr_vec.subspan(0, 2)); + val.y = convert_from_bn254_frs(fr_vec.subspan(2, 2)); + return val; +} + +curve::Grumpkin::AffineElement convert_from_bn254_frs(std::span fr_vec, + curve::Grumpkin::AffineElement* /*unused*/) +{ + ASSERT(fr_vec.size() == 2); + curve::Grumpkin::AffineElement val; + val.x = fr_vec[0]; + val.y = fr_vec[1]; + return val; +} + +/** + * @brief Converts grumpkin::fr to 2 bb::fr elements + * @details First, this function must return 2 bb::fr elements because the grumpkin::fr field has a larger modulus than + * the bb::fr field, so we choose to send 1 grumpkin::fr element to 2 bb::fr elements to maintain injectivity. + * This function the reverse of convert_from_bn254_frs(std::span fr_vec, grumpkin::fr*) by merging the two + * pairs of limbs back into the 2 bb::fr elements. For the implementation, we want to minimize the number of constraints + * created by the circuit form, which happens to use 68 bit limbs to represent a grumpkin::fr (as a bigfield). + * Therefore, our mapping will split a grumpkin::fr into a 136 bit chunk for the lower two bigfield limbs and the upper + * chunk for the upper two limbs. The upper chunk ends up being 254 - 2*68 = 118 bits as a result. We manipulate the + * value using bitwise masks and shifts to obtain our two chunks. + * @param input + * @return std::array + */ +std::vector convert_to_bn254_frs(const grumpkin::fr& val) +{ + // Goal is to slice up the 64 bit limbs of grumpkin::fr/uint256_t to mirror the 68 bit limbs of bigfield + // We accomplish this by dividing the grumpkin::fr's value into two 68*2=136 bit pieces. + constexpr uint64_t LOWER_BITS = 2 * NUM_CONVERSION_LIMB_BITS; + constexpr uint256_t LOWER_MASK = (uint256_t(1) << LOWER_BITS) - 1; + auto value = uint256_t(val); + ASSERT(value < (uint256_t(1) << TOTAL_BITS)); + std::vector result(2); + result[0] = static_cast(value & LOWER_MASK); + result[1] = static_cast(value >> LOWER_BITS); + ASSERT(static_cast(result[1]) < (uint256_t(1) << (TOTAL_BITS - LOWER_BITS))); + return result; +} + +std::vector convert_to_bn254_frs(const bb::fr& val) +{ + std::vector fr_vec{ val }; + return fr_vec; +} + +std::vector convert_to_bn254_frs(const curve::BN254::AffineElement& val) +{ + auto fr_vec_x = convert_to_bn254_frs(val.x); + auto fr_vec_y = convert_to_bn254_frs(val.y); + std::vector fr_vec(fr_vec_x.begin(), fr_vec_x.end()); + fr_vec.insert(fr_vec.end(), fr_vec_y.begin(), fr_vec_y.end()); + return fr_vec; +} + +std::vector convert_to_bn254_frs(const curve::Grumpkin::AffineElement& val) +{ + auto fr_vec_x = convert_to_bn254_frs(val.x); + auto fr_vec_y = convert_to_bn254_frs(val.y); + std::vector fr_vec(fr_vec_x.begin(), fr_vec_x.end()); + fr_vec.insert(fr_vec.end(), fr_vec_y.begin(), fr_vec_y.end()); + return fr_vec; +} + +} // namespace bb::field_conversion \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.hpp new file mode 100644 index 00000000000..c2298236512 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.hpp @@ -0,0 +1,211 @@ +#pragma once + +#include "barretenberg/ecc/curves/bn254/bn254.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" +#include "barretenberg/polynomials/univariate.hpp" + +namespace bb::field_conversion { + +/** + * @brief Calculates number of bb::fr required to represent the input type + * @details We want to support the following types: bool, size_t, uint32_t, uint64_t, bb::fr, grumpkin::fr, + * curve::BN254::AffineElement, curve::Grumpkin::AffineElement, bb::Univariate, std::array, for + * FF = bb::fr/grumpkin::fr, and N is arbitrary + * @tparam T + * @return constexpr size_t + */ +template constexpr size_t calc_num_bn254_frs(); + +constexpr size_t calc_num_bn254_frs(bb::fr* /*unused*/) +{ + return 1; +} + +constexpr size_t calc_num_bn254_frs(grumpkin::fr* /*unused*/) +{ + return 2; +} + +template constexpr size_t calc_num_bn254_frs(T* /*unused*/) +{ + return 1; // meant for integral types that are less than 254 bits +} + +constexpr size_t calc_num_bn254_frs(curve::BN254::AffineElement* /*unused*/) +{ + return 2 * calc_num_bn254_frs(); +} + +constexpr size_t calc_num_bn254_frs(curve::Grumpkin::AffineElement* /*unused*/) +{ + return 2 * calc_num_bn254_frs(); +} + +template constexpr size_t calc_num_bn254_frs(std::array* /*unused*/) +{ + return N * calc_num_bn254_frs(); +} + +template constexpr size_t calc_num_bn254_frs(bb::Univariate* /*unused*/) +{ + return N * calc_num_bn254_frs(); +} + +template constexpr size_t calc_num_bn254_frs() +{ + return calc_num_bn254_frs(static_cast(nullptr)); +} + +/** + * @brief Conversions from vector of bb::fr elements to transcript types. + * @details We want to support the following types: bool, size_t, uint32_t, uint64_t, bb::fr, grumpkin::fr, + * curve::BN254::AffineElement, curve::Grumpkin::AffineElement, bb::Univariate, std::array, for + * FF = bb::fr/grumpkin::fr, and N is arbitrary. + * The only nontrivial implementation is the conversion for grumpkin::fr. More details are given in the function comment + * below. + * @tparam T + * @param fr_vec + * @return T + */ +template T convert_from_bn254_frs(std::span fr_vec); + +bool convert_from_bn254_frs(std::span fr_vec, bool* /*unused*/); + +template inline T convert_from_bn254_frs(std::span fr_vec, T* /*unused*/) +{ + ASSERT(fr_vec.size() == 1); + return static_cast(fr_vec[0]); +} + +bb::fr convert_from_bn254_frs(std::span fr_vec, bb::fr* /*unused*/); + +grumpkin::fr convert_from_bn254_frs(std::span fr_vec, grumpkin::fr* /*unused*/); + +curve::BN254::AffineElement convert_from_bn254_frs(std::span fr_vec, + curve::BN254::AffineElement* /*unused*/); + +curve::Grumpkin::AffineElement convert_from_bn254_frs(std::span fr_vec, + curve::Grumpkin::AffineElement* /*unused*/); + +template +inline std::array convert_from_bn254_frs(std::span fr_vec, std::array* /*unused*/) +{ + std::array val; + for (size_t i = 0; i < N; ++i) { + val[i] = fr_vec[i]; + } + return val; +} + +template +inline std::array convert_from_bn254_frs(std::span fr_vec, + std::array* /*unused*/) +{ + std::array val; + for (size_t i = 0; i < N; ++i) { + std::vector fr_vec_tmp{ fr_vec[2 * i], + fr_vec[2 * i + 1] }; // each pair of consecutive elements is a grumpkin::fr + val[i] = convert_from_bn254_frs(fr_vec_tmp); + } + return val; +} + +template +inline Univariate convert_from_bn254_frs(std::span fr_vec, Univariate* /*unused*/) +{ + Univariate val; + for (size_t i = 0; i < N; ++i) { + val.evaluations[i] = fr_vec[i]; + } + return val; +} + +template +inline Univariate convert_from_bn254_frs(std::span fr_vec, + Univariate* /*unused*/) +{ + Univariate val; + for (size_t i = 0; i < N; ++i) { + std::vector fr_vec_tmp{ fr_vec[2 * i], fr_vec[2 * i + 1] }; + val.evaluations[i] = convert_from_bn254_frs(fr_vec_tmp); + } + return val; +} + +template T convert_from_bn254_frs(std::span fr_vec) +{ + return convert_from_bn254_frs(fr_vec, static_cast(nullptr)); +} + +/** + * @brief Conversion from transcript values to bb::frs + * @details We want to support the following types: bool, size_t, uint32_t, uint64_t, bb::fr, grumpkin::fr, + * curve::BN254::AffineElement, curve::Grumpkin::AffineElement, bb::Univariate, std::array, for + * FF = bb::fr/grumpkin::fr, and N is arbitrary. + * @tparam T + * @param val + * @return std::vector + */ +template std::vector inline convert_to_bn254_frs(const T& val) +{ + std::vector fr_vec{ val }; + return fr_vec; +} + +std::vector convert_to_bn254_frs(const grumpkin::fr& val); + +std::vector convert_to_bn254_frs(const bb::fr& val); + +std::vector convert_to_bn254_frs(const curve::BN254::AffineElement& val); + +std::vector convert_to_bn254_frs(const curve::Grumpkin::AffineElement& val); + +template std::vector inline convert_to_bn254_frs(const std::array& val) +{ + std::vector fr_vec(val.begin(), val.end()); + return fr_vec; +} + +template std::vector inline convert_to_bn254_frs(const std::array& val) +{ + std::vector fr_vec; + for (size_t i = 0; i < N; ++i) { + auto tmp_vec = convert_to_bn254_frs(val[i]); + fr_vec.insert(fr_vec.end(), tmp_vec.begin(), tmp_vec.end()); + } + return fr_vec; +} + +template std::vector inline convert_to_bn254_frs(const bb::Univariate& val) +{ + std::vector fr_vec; + for (size_t i = 0; i < N; ++i) { + auto tmp_vec = convert_to_bn254_frs(val.evaluations[i]); + fr_vec.insert(fr_vec.end(), tmp_vec.begin(), tmp_vec.end()); + } + return fr_vec; +} + +template std::vector inline convert_to_bn254_frs(const bb::Univariate& val) +{ + std::vector fr_vec; + for (size_t i = 0; i < N; ++i) { + auto tmp_vec = convert_to_bn254_frs(val.evaluations[i]); + fr_vec.insert(fr_vec.end(), tmp_vec.begin(), tmp_vec.end()); + } + return fr_vec; +} + +template std::vector inline convert_to_bn254_frs(const AllValues& val) +{ + auto data = val.get_all(); + std::vector fr_vec; + for (auto& item : data) { + auto tmp_vec = convert_to_bn254_frs(item); + fr_vec.insert(fr_vec.end(), tmp_vec.begin(), tmp_vec.end()); + } + return fr_vec; +} + +} // namespace bb::field_conversion \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.test.cpp new file mode 100644 index 00000000000..d54ca02ba4b --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.test.cpp @@ -0,0 +1,143 @@ +#include "barretenberg/ecc/fields/field_conversion.hpp" +#include + +namespace bb::field_conversion_tests { + +class FieldConversionTest : public ::testing::Test { + public: + template void check_conversion(T x) + { + size_t len = bb::field_conversion::calc_num_bn254_frs(); + auto frs = bb::field_conversion::convert_to_bn254_frs(x); + EXPECT_EQ(len, frs.size()); + auto y = bb::field_conversion::convert_from_bn254_frs(frs); + EXPECT_EQ(x, y); + } +}; + +/** + * @brief Field conversion test for size_t + */ +TEST_F(FieldConversionTest, FieldConversionSizeT) +{ + size_t x = 210849; + check_conversion(x); +} + +/** + * @brief Field conversion test for uint32_t + */ +TEST_F(FieldConversionTest, FieldConversionUint32) +{ + auto x = static_cast(1) << 31; + check_conversion(x); +} + +/** + * @brief Field conversion test for bb::fr + */ +TEST_F(FieldConversionTest, FieldConversionFr) +{ + bb::fr x1(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); // 256 bits + check_conversion(x1); + + bb::fr x2(bb::fr::modulus_minus_two); // modulus - 2 + check_conversion(x2); +} + +/** + * @brief Field conversion test for grumpkin::fr + * + */ +TEST_F(FieldConversionTest, FieldConversionGrumpkinFr) +{ + grumpkin::fr x1(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); // 256 bits + check_conversion(x1); +} + +/** + * @brief Field conversion test for curve::BN254::AffineElement + * + */ +TEST_F(FieldConversionTest, FieldConversionBN254AffineElement) +{ + curve::BN254::AffineElement x1(1, 2); + check_conversion(x1); + + curve::BN254::AffineElement x2(grumpkin::fr::modulus_minus_two, grumpkin::fr::modulus_minus_two); + check_conversion(x2); +} + +/** + * @brief Field conversion test for curve::Grumpkin::AffineElement + */ +TEST_F(FieldConversionTest, FieldConversionGrumpkinAffineElement) +{ + curve::Grumpkin::AffineElement x1(1, 2); + check_conversion(x1); + + curve::Grumpkin::AffineElement x2(bb::fr::modulus_minus_two, bb::fr::modulus_minus_two); + check_conversion(x2); +} + +/** + * @brief Field conversion test for std::array + * + */ +TEST_F(FieldConversionTest, FieldConversionArrayBn254Fr) +{ + std::array x1{ 1, 2, 3, 4 }; + check_conversion(x1); + + std::array x2{ bb::fr::modulus_minus_two, + bb::fr::modulus_minus_two - 123, + 215215125, + 102701750, + 367032, + 12985028, + bb::fr::modulus_minus_two - 125015028 }; + check_conversion(x2); +} + +/** + * @brief Field conversion test for std::array + * + */ +TEST_F(FieldConversionTest, FieldConversionArrayGrumpkinFr) +{ + std::array x1{ 1, 2, 3, 4 }; + check_conversion(x1); + + std::array x2{ grumpkin::fr::modulus_minus_two, + grumpkin::fr::modulus_minus_two - 123, + 215215125, + 102701750, + 367032, + 12985028, + grumpkin::fr::modulus_minus_two - 125015028 }; + check_conversion(x2); +} + +/** + * @brief Field conversion test for bb::Univariate + * + */ +TEST_F(FieldConversionTest, FieldConversionUnivariateBn254Fr) +{ + std::array x1_arr{ 1, 2, 3, 4 }; + bb::Univariate x1{ x1_arr }; + check_conversion(x1); +} + +/** + * @brief Field conversion test for bb::Univariate + * + */ +TEST_F(FieldConversionTest, FieldConversionUnivariateGrumpkinFr) +{ + std::array x1_arr{ 1, 2, 3, 4 }; + bb::Univariate x1{ x1_arr }; + check_conversion(x1); +} + +} // namespace bb::field_conversion_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index 3ab2a27fcce..071a63dfb4a 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -274,13 +274,13 @@ template void ECCVMProver_::execute_transcript_cons translation_batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); } -template plonk::proof& ECCVMProver_::export_proof() +template honk::proof& ECCVMProver_::export_proof() { - proof.proof_data = transcript->export_proof(); + proof = transcript->export_proof(); return proof; } -template plonk::proof& ECCVMProver_::construct_proof() +template honk::proof& ECCVMProver_::construct_proof() { execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp index b613a0697ef..96f3e76a309 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp @@ -3,7 +3,7 @@ #include "barretenberg/commitment_schemes/shplonk/shplonk.hpp" #include "barretenberg/flavor/ecc_vm.hpp" #include "barretenberg/goblin/translation_evaluations.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -42,8 +42,8 @@ template class ECCVMProver_ { BBERG_PROFILE void execute_final_pcs_round(); BBERG_PROFILE void execute_transcript_consistency_univariate_opening_round(); - plonk::proof& export_proof(); - plonk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr transcript; @@ -80,7 +80,7 @@ template class ECCVMProver_ { using Shplonk = pcs::shplonk::ShplonkProver_; private: - plonk::proof proof; + honk::proof proof; }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index c513bc991c4..2b4e69d3624 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -39,94 +39,94 @@ template class ECCVMTranscriptTests : public ::testing::Test { auto log_n = numeric::get_msb(circuit_size); size_t MAX_PARTIAL_RELATION_LENGTH = Flavor::BATCHED_RELATION_PARTIAL_LENGTH; - size_t size_FF = sizeof(FF); - size_t size_G = 2 * size_FF; - size_t size_uni = MAX_PARTIAL_RELATION_LENGTH * size_FF; - size_t size_evals = (Flavor::NUM_ALL_ENTITIES)*size_FF; - size_t size_uint32 = 4; - size_t size_uint64 = 8; + // Size of types is number of bb::frs needed to represent the type + size_t frs_per_Fr = bb::field_conversion::calc_num_bn254_frs(); + size_t frs_per_G = bb::field_conversion::calc_num_bn254_frs(); + size_t frs_per_uni = MAX_PARTIAL_RELATION_LENGTH * frs_per_Fr; + size_t frs_per_evals = (Flavor::NUM_ALL_ENTITIES)*frs_per_Fr; + size_t frs_per_uint32 = bb::field_conversion::calc_num_bn254_frs(); size_t round = 0; - manifest_expected.add_entry(round, "circuit_size", size_uint32); - manifest_expected.add_entry(round, "TRANSCRIPT_ADD", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_MUL", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_EQ", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_COLLISION_CHECK", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_MSM_TRANSITION", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_PC", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_MSM_COUNT", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_PX", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_PY", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_Z1", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_Z2", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_Z1ZERO", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_Z2ZERO", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_OP", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_ACCUMULATOR_X", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_ACCUMULATOR_Y", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_MSM_X", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_MSM_Y", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_PC", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_POINT_TRANSITION", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_ROUND", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_SCALAR_SUM", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S1HI", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S1LO", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S2HI", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S2LO", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S3HI", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S3LO", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S4HI", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_S4LO", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_SKEW", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_DX", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_DY", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_TX", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_TY", size_G); - manifest_expected.add_entry(round, "MSM_TRANSITION", size_G); - manifest_expected.add_entry(round, "MSM_ADD", size_G); - manifest_expected.add_entry(round, "MSM_DOUBLE", size_G); - manifest_expected.add_entry(round, "MSM_SKEW", size_G); - manifest_expected.add_entry(round, "MSM_ACCUMULATOR_X", size_G); - manifest_expected.add_entry(round, "MSM_ACCUMULATOR_Y", size_G); - manifest_expected.add_entry(round, "MSM_PC", size_G); - manifest_expected.add_entry(round, "MSM_SIZE_OF_MSM", size_G); - manifest_expected.add_entry(round, "MSM_COUNT", size_G); - manifest_expected.add_entry(round, "MSM_ROUND", size_G); - manifest_expected.add_entry(round, "MSM_ADD1", size_G); - manifest_expected.add_entry(round, "MSM_ADD2", size_G); - manifest_expected.add_entry(round, "MSM_ADD3", size_G); - manifest_expected.add_entry(round, "MSM_ADD4", size_G); - manifest_expected.add_entry(round, "MSM_X1", size_G); - manifest_expected.add_entry(round, "MSM_Y1", size_G); - manifest_expected.add_entry(round, "MSM_X2", size_G); - manifest_expected.add_entry(round, "MSM_Y2", size_G); - manifest_expected.add_entry(round, "MSM_X3", size_G); - manifest_expected.add_entry(round, "MSM_Y3", size_G); - manifest_expected.add_entry(round, "MSM_X4", size_G); - manifest_expected.add_entry(round, "MSM_Y4", size_G); - manifest_expected.add_entry(round, "MSM_COLLISION_X1", size_G); - manifest_expected.add_entry(round, "MSM_COLLISION_X2", size_G); - manifest_expected.add_entry(round, "MSM_COLLISION_X3", size_G); - manifest_expected.add_entry(round, "MSM_COLLISION_X4", size_G); - manifest_expected.add_entry(round, "MSM_LAMBDA1", size_G); - manifest_expected.add_entry(round, "MSM_LAMBDA2", size_G); - manifest_expected.add_entry(round, "MSM_LAMBDA3", size_G); - manifest_expected.add_entry(round, "MSM_LAMBDA4", size_G); - manifest_expected.add_entry(round, "MSM_SLICE1", size_G); - manifest_expected.add_entry(round, "MSM_SLICE2", size_G); - manifest_expected.add_entry(round, "MSM_SLICE3", size_G); - manifest_expected.add_entry(round, "MSM_SLICE4", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_ACCUMULATOR_EMPTY", size_G); - manifest_expected.add_entry(round, "TRANSCRIPT_RESET_ACCUMULATOR", size_G); - manifest_expected.add_entry(round, "PRECOMPUTE_SELECT", size_G); - manifest_expected.add_entry(round, "LOOKUP_READ_COUNTS_0", size_G); - manifest_expected.add_entry(round, "LOOKUP_READ_COUNTS_1", size_G); + manifest_expected.add_entry(round, "circuit_size", frs_per_uint32); + manifest_expected.add_entry(round, "TRANSCRIPT_ADD", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_MUL", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_EQ", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_COLLISION_CHECK", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_MSM_TRANSITION", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_PC", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_MSM_COUNT", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_PX", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_PY", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_Z1", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_Z2", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_Z1ZERO", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_Z2ZERO", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_OP", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_ACCUMULATOR_X", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_ACCUMULATOR_Y", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_MSM_X", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_MSM_Y", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_PC", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_POINT_TRANSITION", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_ROUND", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_SCALAR_SUM", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S1HI", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S1LO", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S2HI", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S2LO", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S3HI", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S3LO", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S4HI", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_S4LO", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_SKEW", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_DX", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_DY", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_TX", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_TY", frs_per_G); + manifest_expected.add_entry(round, "MSM_TRANSITION", frs_per_G); + manifest_expected.add_entry(round, "MSM_ADD", frs_per_G); + manifest_expected.add_entry(round, "MSM_DOUBLE", frs_per_G); + manifest_expected.add_entry(round, "MSM_SKEW", frs_per_G); + manifest_expected.add_entry(round, "MSM_ACCUMULATOR_X", frs_per_G); + manifest_expected.add_entry(round, "MSM_ACCUMULATOR_Y", frs_per_G); + manifest_expected.add_entry(round, "MSM_PC", frs_per_G); + manifest_expected.add_entry(round, "MSM_SIZE_OF_MSM", frs_per_G); + manifest_expected.add_entry(round, "MSM_COUNT", frs_per_G); + manifest_expected.add_entry(round, "MSM_ROUND", frs_per_G); + manifest_expected.add_entry(round, "MSM_ADD1", frs_per_G); + manifest_expected.add_entry(round, "MSM_ADD2", frs_per_G); + manifest_expected.add_entry(round, "MSM_ADD3", frs_per_G); + manifest_expected.add_entry(round, "MSM_ADD4", frs_per_G); + manifest_expected.add_entry(round, "MSM_X1", frs_per_G); + manifest_expected.add_entry(round, "MSM_Y1", frs_per_G); + manifest_expected.add_entry(round, "MSM_X2", frs_per_G); + manifest_expected.add_entry(round, "MSM_Y2", frs_per_G); + manifest_expected.add_entry(round, "MSM_X3", frs_per_G); + manifest_expected.add_entry(round, "MSM_Y3", frs_per_G); + manifest_expected.add_entry(round, "MSM_X4", frs_per_G); + manifest_expected.add_entry(round, "MSM_Y4", frs_per_G); + manifest_expected.add_entry(round, "MSM_COLLISION_X1", frs_per_G); + manifest_expected.add_entry(round, "MSM_COLLISION_X2", frs_per_G); + manifest_expected.add_entry(round, "MSM_COLLISION_X3", frs_per_G); + manifest_expected.add_entry(round, "MSM_COLLISION_X4", frs_per_G); + manifest_expected.add_entry(round, "MSM_LAMBDA1", frs_per_G); + manifest_expected.add_entry(round, "MSM_LAMBDA2", frs_per_G); + manifest_expected.add_entry(round, "MSM_LAMBDA3", frs_per_G); + manifest_expected.add_entry(round, "MSM_LAMBDA4", frs_per_G); + manifest_expected.add_entry(round, "MSM_SLICE1", frs_per_G); + manifest_expected.add_entry(round, "MSM_SLICE2", frs_per_G); + manifest_expected.add_entry(round, "MSM_SLICE3", frs_per_G); + manifest_expected.add_entry(round, "MSM_SLICE4", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_ACCUMULATOR_EMPTY", frs_per_G); + manifest_expected.add_entry(round, "TRANSCRIPT_RESET_ACCUMULATOR", frs_per_G); + manifest_expected.add_entry(round, "PRECOMPUTE_SELECT", frs_per_G); + manifest_expected.add_entry(round, "LOOKUP_READ_COUNTS_0", frs_per_G); + manifest_expected.add_entry(round, "LOOKUP_READ_COUNTS_1", frs_per_G); manifest_expected.add_challenge(round, "beta", "gamma"); round++; - manifest_expected.add_entry(round, "LOOKUP_INVERSES", size_G); - manifest_expected.add_entry(round, "Z_PERM", size_G); + manifest_expected.add_entry(round, "LOOKUP_INVERSES", frs_per_G); + manifest_expected.add_entry(round, "Z_PERM", frs_per_G); manifest_expected.add_challenge(round, "Sumcheck:alpha"); for (size_t i = 0; i < log_n; i++) { @@ -138,49 +138,49 @@ template class ECCVMTranscriptTests : public ::testing::Test { for (size_t i = 0; i < log_n; ++i) { round++; std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "Sumcheck:univariate_" + idx, size_uni); + manifest_expected.add_entry(round, "Sumcheck:univariate_" + idx, frs_per_uni); std::string label = "Sumcheck:u_" + idx; manifest_expected.add_challenge(round, label); } round++; - manifest_expected.add_entry(round, "Sumcheck:evaluations", size_evals); + manifest_expected.add_entry(round, "Sumcheck:evaluations", frs_per_evals); manifest_expected.add_challenge(round, "rho"); round++; for (size_t i = 1; i < log_n; ++i) { std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "Gemini:FOLD_" + idx, size_G); + manifest_expected.add_entry(round, "Gemini:FOLD_" + idx, frs_per_G); } manifest_expected.add_challenge(round, "Gemini:r"); round++; for (size_t i = 0; i < log_n; ++i) { std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "Gemini:a_" + idx, size_FF); + manifest_expected.add_entry(round, "Gemini:a_" + idx, frs_per_Fr); } manifest_expected.add_challenge(round, "Shplonk:nu"); round++; - manifest_expected.add_entry(round, "Shplonk:Q", size_G); + manifest_expected.add_entry(round, "Shplonk:Q", frs_per_G); manifest_expected.add_challenge(round, "Shplonk:z"); round++; - manifest_expected.add_entry(round, "IPA:poly_degree", size_uint64); + manifest_expected.add_entry(round, "IPA:poly_degree", frs_per_uint32); manifest_expected.add_challenge(round, "IPA:generator_challenge"); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); for (size_t i = 0; i < log_poly_degree; ++i) { round++; std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "IPA:L_" + idx, size_G); - manifest_expected.add_entry(round, "IPA:R_" + idx, size_G); + manifest_expected.add_entry(round, "IPA:L_" + idx, frs_per_G); + manifest_expected.add_entry(round, "IPA:R_" + idx, frs_per_G); std::string label = "IPA:round_challenge_" + idx; manifest_expected.add_challenge(round, label); } round++; - manifest_expected.add_entry(round, "IPA:a_0", size_FF); + manifest_expected.add_entry(round, "IPA:a_0", frs_per_Fr); return manifest_expected; } diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 198cd654089..82780b09eb3 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -32,7 +32,7 @@ template ECCVMVerifier_& ECCVMVerifier_::opera * @brief This function verifies an ECCVM Honk proof for given program settings. * */ -template bool ECCVMVerifier_::verify_proof(const plonk::proof& proof) +template bool ECCVMVerifier_::verify_proof(const honk::proof& proof) { using FF = typename Flavor::FF; using GroupElement = typename Flavor::GroupElement; @@ -48,7 +48,7 @@ template bool ECCVMVerifier_::verify_proof(const plonk RelationParameters relation_parameters; - transcript = std::make_shared(proof.proof_data); + transcript = std::make_shared(proof); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp index 44ae6c720d4..998bd5ed034 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp @@ -1,6 +1,6 @@ #pragma once #include "barretenberg/flavor/ecc_vm.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" namespace bb::honk { @@ -30,7 +30,7 @@ template class ECCVMVerifier_ { ECCVMVerifier_& operator=(ECCVMVerifier_&& other) noexcept; ~ECCVMVerifier_() = default; - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 2bf24f727f6..8745101e633 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -613,201 +613,201 @@ template class ECCVMBa Transcript() = default; - Transcript(const std::vector& proof) + Transcript(const honk::proof& proof) : BaseTranscript(proof) {} void deserialize_full_transcript() { // take current proof and put them into the struct - size_t num_bytes_read = 0; + size_t num_frs_read = 0; circuit_size = - BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - transcript_add_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_mul_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_eq_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_collision_check_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_msm_transition_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_pc_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_msm_count_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_Px_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_Py_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_z1_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_z2_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_z1zero_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_z2zero_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_op_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_accumulator_x_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_accumulator_y_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_msm_x_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_msm_y_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_pc_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_point_transition_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_round_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_scalar_sum_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s1hi_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s1lo_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s2hi_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s2lo_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s3hi_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s3lo_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s4hi_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_s4lo_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_skew_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_dx_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_dy_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_tx_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_ty_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_transition_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_add_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_double_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_skew_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_accumulator_x_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_accumulator_y_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_pc_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_size_of_msm_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_count_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_round_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_add1_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_add2_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_add3_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_add4_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_x1_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_y1_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_x2_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_y2_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_x3_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_y3_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_x4_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_y4_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_collision_x1_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_collision_x2_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_collision_x3_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_collision_x4_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - msm_lambda1_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_lambda2_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_lambda3_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_lambda4_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_slice1_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_slice2_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_slice3_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - msm_slice4_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); - transcript_accumulator_empty_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - transcript_reset_accumulator_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - precompute_select_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - lookup_read_counts_0_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - lookup_read_counts_1_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - lookup_inverses_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); - z_perm_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + transcript_add_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_mul_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_eq_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_collision_check_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_msm_transition_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_pc_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_msm_count_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_Px_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_Py_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_z1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_z2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_z1zero_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_z2zero_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_op_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_accumulator_x_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_accumulator_y_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_msm_x_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_msm_y_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_pc_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_point_transition_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_round_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_scalar_sum_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s1hi_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s1lo_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s2hi_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s2lo_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s3hi_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s3lo_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s4hi_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_s4lo_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_skew_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_dx_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_dy_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_tx_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_ty_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_transition_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_add_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_double_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_skew_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_accumulator_x_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_accumulator_y_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_pc_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_size_of_msm_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_count_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_round_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_add1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_add2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_add3_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_add4_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_x1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_y1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_x2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_y2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_x3_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_y3_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_x4_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_y4_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_collision_x1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_collision_x2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_collision_x3_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_collision_x4_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_lambda1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_lambda2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_lambda3_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_lambda4_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_slice1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_slice2_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_slice3_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + msm_slice4_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_accumulator_empty_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + transcript_reset_accumulator_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + precompute_select_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + lookup_read_counts_0_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + lookup_read_counts_1_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + lookup_inverses_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); + z_perm_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { - sumcheck_univariates.emplace_back(BaseTranscript::template deserialize_from_buffer< - bb::Univariate>( - BaseTranscript::proof_data, num_bytes_read)); + sumcheck_univariates.emplace_back( + BaseTranscript::template deserialize_from_buffer< + bb::Univariate>(BaseTranscript::proof_data, num_frs_read)); } sumcheck_evaluations = BaseTranscript::template deserialize_from_buffer>( - BaseTranscript::proof_data, num_bytes_read); + BaseTranscript::proof_data, num_frs_read); for (size_t i = 0; i < log_n - 1; ++i) { gemini_univariate_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read)); + BaseTranscript::proof_data, num_frs_read)); } for (size_t i = 0; i < log_n; ++i) { gemini_a_evals.emplace_back( - BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read)); + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read)); } - shplonk_q_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + shplonk_q_comm = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); if (std::is_same>::value) { kzg_w_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + num_frs_read); } else if (std::is_same>::value) { ipa_poly_degree = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + num_frs_read); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); for (size_t i = 0; i < log_poly_degree; ++i) { ipa_l_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read)); + BaseTranscript::proof_data, num_frs_read)); ipa_r_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read)); + BaseTranscript::proof_data, num_frs_read)); } ipa_a_0_eval = - BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); } else { throw_or_abort("Unsupported PCS"); } diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index c1f672eb177..19b18ec3d79 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -720,93 +720,93 @@ class AvmMiniFlavor { Transcript() = default; - Transcript(const std::vector& proof) + Transcript(const std::vector& proof) : BaseTranscript(proof) {} void deserialize_full_transcript() { - size_t num_bytes_read = 0; - circuit_size = deserialize_from_buffer(proof_data, num_bytes_read); + size_t num_frs_read = 0; + circuit_size = deserialize_from_buffer(proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - memTrace_m_clk = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_sub_clk = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_addr = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_val = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_lastAccess = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_last = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_rw = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_in_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_tag_err = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - memTrace_m_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r2 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r3 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r4 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r5 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r6 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r7 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u64_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_pc = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_internal_return_ptr = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_internal_call = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_internal_return = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_jump = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_halt = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_op_add = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_sel_op_div = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_in_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_op_err = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_tag_err = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_inv = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_ia = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_ib = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_ic = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_mem_op_a = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_mem_op_b = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_mem_op_c = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_rwa = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_rwb = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_rwc = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_mem_idx_a = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_mem_idx_b = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_mem_idx_c = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - avmMini_last = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + memTrace_m_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_sub_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_addr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_val = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_lastAccess = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_rw = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + memTrace_m_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r2 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r3 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r4 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r5 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r6 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u16_r7 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_u64_r0 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + aluChip_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_pc = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_internal_return_ptr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_internal_call = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_internal_return = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_jump = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_halt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_op_add = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_sel_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_op_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_inv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_ia = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_ib = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_ic = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_mem_op_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_mem_op_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_mem_op_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_rwa = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_rwb = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_rwc = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_mem_idx_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_mem_idx_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_mem_idx_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avmMini_last = deserialize_from_buffer(Transcript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back( deserialize_from_buffer>(Transcript::proof_data, - num_bytes_read)); + num_frs_read)); } sumcheck_evaluations = - deserialize_from_buffer>(Transcript::proof_data, num_bytes_read); + deserialize_from_buffer>(Transcript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { - zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_bytes_read)); + zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_frs_read)); } - zm_cq_comm = deserialize_from_buffer(proof_data, num_bytes_read); - zm_pi_comm = deserialize_from_buffer(proof_data, num_bytes_read); + zm_cq_comm = deserialize_from_buffer(proof_data, num_frs_read); + zm_pi_comm = deserialize_from_buffer(proof_data, num_frs_read); } void serialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index faac5550be0..258d4c3d8a0 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -285,45 +285,45 @@ class ToyFlavor { Transcript() = default; - Transcript(const std::vector& proof) + Transcript(const std::vector& proof) : BaseTranscript(proof) {} void deserialize_full_transcript() { - size_t num_bytes_read = 0; - circuit_size = deserialize_from_buffer(proof_data, num_bytes_read); + size_t num_frs_read = 0; + circuit_size = deserialize_from_buffer(proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - toy_q_tuple_set = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_set_1_column_1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_set_1_column_2 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_set_2_column_1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_set_2_column_2 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_xor_a = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_xor_b = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_xor_c = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_table_xor_a = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_table_xor_b = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_table_xor_c = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_q_xor = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - toy_q_xor_table = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - two_column_perm = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - lookup_xor = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - lookup_xor_counts = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + toy_q_tuple_set = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_set_1_column_1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_set_1_column_2 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_set_2_column_1 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_set_2_column_2 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_xor_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_xor_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_xor_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_table_xor_a = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_table_xor_b = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_table_xor_c = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_q_xor = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + toy_q_xor_table = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + two_column_perm = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_xor = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + lookup_xor_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back( deserialize_from_buffer>(Transcript::proof_data, - num_bytes_read)); + num_frs_read)); } sumcheck_evaluations = - deserialize_from_buffer>(Transcript::proof_data, num_bytes_read); + deserialize_from_buffer>(Transcript::proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { - zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_bytes_read)); + zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_frs_read)); } - zm_cq_comm = deserialize_from_buffer(proof_data, num_bytes_read); - zm_pi_comm = deserialize_from_buffer(proof_data, num_bytes_read); + zm_cq_comm = deserialize_from_buffer(proof_data, num_frs_read); + zm_pi_comm = deserialize_from_buffer(proof_data, num_frs_read); } void serialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 5f13c7ac66b..ed247351c52 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -3,6 +3,7 @@ #include "barretenberg/common/ref_vector.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/flavor/flavor_macros.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/relations/auxiliary_relation.hpp" @@ -505,48 +506,47 @@ class GoblinUltra { Transcript_() = default; - Transcript_(const std::vector& proof) + Transcript_(const honk::proof& proof) : BaseTranscript(proof) {} void deserialize_full_transcript() { // take current proof and put them into the struct - size_t num_bytes_read = 0; - circuit_size = deserialize_from_buffer(proof_data, num_bytes_read); + size_t num_frs_read = 0; + circuit_size = deserialize_from_buffer(proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - public_input_size = deserialize_from_buffer(proof_data, num_bytes_read); - pub_inputs_offset = deserialize_from_buffer(proof_data, num_bytes_read); + public_input_size = deserialize_from_buffer(proof_data, num_frs_read); + pub_inputs_offset = deserialize_from_buffer(proof_data, num_frs_read); for (size_t i = 0; i < public_input_size; ++i) { - public_inputs.push_back(deserialize_from_buffer(proof_data, num_bytes_read)); + public_inputs.push_back(deserialize_from_buffer(proof_data, num_frs_read)); } - w_l_comm = deserialize_from_buffer(proof_data, num_bytes_read); - w_r_comm = deserialize_from_buffer(proof_data, num_bytes_read); - w_o_comm = deserialize_from_buffer(proof_data, num_bytes_read); - ecc_op_wire_1_comm = deserialize_from_buffer(proof_data, num_bytes_read); - ecc_op_wire_2_comm = deserialize_from_buffer(proof_data, num_bytes_read); - ecc_op_wire_3_comm = deserialize_from_buffer(proof_data, num_bytes_read); - ecc_op_wire_4_comm = deserialize_from_buffer(proof_data, num_bytes_read); - calldata_comm = deserialize_from_buffer(proof_data, num_bytes_read); - calldata_read_counts_comm = deserialize_from_buffer(proof_data, num_bytes_read); - lookup_inverses_comm = deserialize_from_buffer(proof_data, num_bytes_read); - sorted_accum_comm = deserialize_from_buffer(proof_data, num_bytes_read); - w_4_comm = deserialize_from_buffer(proof_data, num_bytes_read); - z_perm_comm = deserialize_from_buffer(proof_data, num_bytes_read); - z_lookup_comm = deserialize_from_buffer(proof_data, num_bytes_read); + w_l_comm = deserialize_from_buffer(proof_data, num_frs_read); + w_r_comm = deserialize_from_buffer(proof_data, num_frs_read); + w_o_comm = deserialize_from_buffer(proof_data, num_frs_read); + ecc_op_wire_1_comm = deserialize_from_buffer(proof_data, num_frs_read); + ecc_op_wire_2_comm = deserialize_from_buffer(proof_data, num_frs_read); + ecc_op_wire_3_comm = deserialize_from_buffer(proof_data, num_frs_read); + ecc_op_wire_4_comm = deserialize_from_buffer(proof_data, num_frs_read); + calldata_comm = deserialize_from_buffer(proof_data, num_frs_read); + calldata_read_counts_comm = deserialize_from_buffer(proof_data, num_frs_read); + lookup_inverses_comm = deserialize_from_buffer(proof_data, num_frs_read); + sorted_accum_comm = deserialize_from_buffer(proof_data, num_frs_read); + w_4_comm = deserialize_from_buffer(proof_data, num_frs_read); + z_perm_comm = deserialize_from_buffer(proof_data, num_frs_read); + z_lookup_comm = deserialize_from_buffer(proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.push_back( deserialize_from_buffer>(proof_data, - num_bytes_read)); + num_frs_read)); } - sumcheck_evaluations = - deserialize_from_buffer>(proof_data, num_bytes_read); + sumcheck_evaluations = deserialize_from_buffer>(proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { - zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_bytes_read)); + zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_frs_read)); } - zm_cq_comm = deserialize_from_buffer(proof_data, num_bytes_read); - zm_pi_comm = deserialize_from_buffer(proof_data, num_bytes_read); + zm_cq_comm = deserialize_from_buffer(proof_data, num_frs_read); + zm_pi_comm = deserialize_from_buffer(proof_data, num_frs_read); } void serialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 2fd21fab351..466cac1c869 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -481,7 +481,7 @@ class Ultra { Transcript() = default; // Used by verifier to initialize the transcript - Transcript(const std::vector& proof) + Transcript(const std::vector& proof) : BaseTranscript(proof) {} @@ -508,34 +508,33 @@ class Ultra { void deserialize_full_transcript() { // take current proof and put them into the struct - size_t num_bytes_read = 0; - circuit_size = deserialize_from_buffer(proof_data, num_bytes_read); + size_t num_frs_read = 0; + circuit_size = deserialize_from_buffer(proof_data, num_frs_read); size_t log_n = numeric::get_msb(circuit_size); - public_input_size = deserialize_from_buffer(proof_data, num_bytes_read); - pub_inputs_offset = deserialize_from_buffer(proof_data, num_bytes_read); + public_input_size = deserialize_from_buffer(proof_data, num_frs_read); + pub_inputs_offset = deserialize_from_buffer(proof_data, num_frs_read); for (size_t i = 0; i < public_input_size; ++i) { - public_inputs.push_back(deserialize_from_buffer(proof_data, num_bytes_read)); + public_inputs.push_back(deserialize_from_buffer(proof_data, num_frs_read)); } - w_l_comm = deserialize_from_buffer(proof_data, num_bytes_read); - w_r_comm = deserialize_from_buffer(proof_data, num_bytes_read); - w_o_comm = deserialize_from_buffer(proof_data, num_bytes_read); - sorted_accum_comm = deserialize_from_buffer(proof_data, num_bytes_read); - w_4_comm = deserialize_from_buffer(proof_data, num_bytes_read); - z_perm_comm = deserialize_from_buffer(proof_data, num_bytes_read); - z_lookup_comm = deserialize_from_buffer(proof_data, num_bytes_read); + w_l_comm = deserialize_from_buffer(proof_data, num_frs_read); + w_r_comm = deserialize_from_buffer(proof_data, num_frs_read); + w_o_comm = deserialize_from_buffer(proof_data, num_frs_read); + sorted_accum_comm = deserialize_from_buffer(proof_data, num_frs_read); + w_4_comm = deserialize_from_buffer(proof_data, num_frs_read); + z_perm_comm = deserialize_from_buffer(proof_data, num_frs_read); + z_lookup_comm = deserialize_from_buffer(proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.push_back( deserialize_from_buffer>(proof_data, - num_bytes_read)); + num_frs_read)); } - sumcheck_evaluations = - deserialize_from_buffer>(proof_data, num_bytes_read); + sumcheck_evaluations = deserialize_from_buffer>(proof_data, num_frs_read); for (size_t i = 0; i < log_n; ++i) { - zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_bytes_read)); + zm_cq_comms.push_back(deserialize_from_buffer(proof_data, num_frs_read)); } - zm_cq_comm = deserialize_from_buffer(proof_data, num_bytes_read); - zm_pi_comm = deserialize_from_buffer(proof_data, num_bytes_read); + zm_cq_comm = deserialize_from_buffer(proof_data, num_frs_read); + zm_pi_comm = deserialize_from_buffer(proof_data, num_frs_read); } /** * @brief Serializes the structure variables into a FULL Ultra proof. Should be called only if diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index aac0ef305ca..4913695c918 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -12,8 +12,7 @@ namespace bb { class Goblin { - using HonkProof = bb::plonk::proof; - + using HonkProof = bb::honk::proof; using GUHFlavor = bb::honk::flavor::GoblinUltra; using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; @@ -22,6 +21,21 @@ class Goblin { using FF = GUHFlavor::FF; public: + using Builder = GoblinUltraCircuitBuilder; + using Fr = bb::fr; + using Transcript = bb::honk::BaseTranscript; + + using GoblinUltraComposer = bb::honk::UltraComposer_; + using GoblinUltraVerifier = bb::honk::UltraVerifier_; + using OpQueue = bb::ECCOpQueue; + using ECCVMFlavor = bb::honk::flavor::ECCVM; + using ECCVMBuilder = bb::ECCVMCircuitBuilder; + using ECCVMComposer = bb::honk::ECCVMComposer; + using ECCVMProver = bb::honk::ECCVMProver_; + using TranslatorBuilder = bb::GoblinTranslatorCircuitBuilder; + using TranslatorComposer = bb::honk::GoblinTranslatorComposer; + using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_; + using MergeVerifier = bb::honk::MergeVerifier_; /** * @brief Output of goblin::accumulate; an Ultra proof and the corresponding verification key * @@ -36,38 +50,25 @@ class Goblin { HonkProof eccvm_proof; HonkProof translator_proof; TranslationEvaluations translation_evaluations; - std::vector to_buffer() + std::vector to_buffer() { // ACIRHACK: so much copying and duplication added here and elsewhere - std::vector translation_evaluations_buf = translation_evaluations.to_buffer(); - size_t proof_size = merge_proof.proof_data.size() + eccvm_proof.proof_data.size() + - translator_proof.proof_data.size() + translation_evaluations_buf.size(); + std::vector translation_evaluations_buf; // = translation_evaluations.to_buffer(); + size_t proof_size = + merge_proof.size() + eccvm_proof.size() + translator_proof.size() + translation_evaluations_buf.size(); - std::vector result(proof_size); - const auto insert = [&result](const std::vector& buf) { + std::vector result(proof_size); + const auto insert = [&result](const std::vector& buf) { result.insert(result.end(), buf.begin(), buf.end()); }; - insert(merge_proof.proof_data); - insert(eccvm_proof.proof_data); - insert(translator_proof.proof_data); + insert(merge_proof); + insert(eccvm_proof); + insert(translator_proof); insert(translation_evaluations_buf); return result; } }; - using GoblinUltraComposer = bb::honk::UltraComposer_; - using GoblinUltraVerifier = bb::honk::UltraVerifier_; - using Builder = GoblinUltraCircuitBuilder; - using OpQueue = bb::ECCOpQueue; - using ECCVMFlavor = bb::honk::flavor::ECCVM; - using ECCVMBuilder = bb::ECCVMCircuitBuilder; - using ECCVMComposer = bb::honk::ECCVMComposer; - using ECCVMProver = bb::honk::ECCVMProver_; - using TranslatorBuilder = bb::GoblinTranslatorCircuitBuilder; - using TranslatorComposer = bb::honk::GoblinTranslatorComposer; - using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_; - using MergeVerifier = bb::honk::MergeVerifier_; - std::shared_ptr op_queue = std::make_shared(); HonkProof merge_proof; @@ -190,9 +191,9 @@ class Goblin { * @brief Construct a GUH proof for the given circuit. (No merge proof for now) * * @param circuit_builder - * @return std::vector + * @return std::vector */ - std::vector accumulate_for_acir(GoblinUltraCircuitBuilder& circuit_builder) + std::vector accumulate_for_acir(GoblinUltraCircuitBuilder& circuit_builder) { // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): no merge prover for now // // Complete the circuit logic by recursively verifying previous merge proof if it exists @@ -219,7 +220,7 @@ class Goblin { // merge_proof_exists = true; // } - return ultra_proof.proof_data; + return ultra_proof; }; /** @@ -229,7 +230,7 @@ class Goblin { * @return true * @return false */ - bool verify_accumulator_for_acir(const std::vector& proof_buf) const + bool verify_accumulator_for_acir(const std::vector& proof_buf) const { GoblinUltraVerifier verifier{ accumulator.verification_key }; HonkProof proof{ proof_buf }; diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp new file mode 100644 index 00000000000..1e40a20d95d --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp @@ -0,0 +1,9 @@ +#pragma once +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include + +namespace bb::honk { + +using proof = std::vector; + +} // namespace bb::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/protogalaxy/CMakeLists.txt index f1467c96f4c..da9bde256e7 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(protogalaxy honk flavor relations) \ No newline at end of file +barretenberg_module(protogalaxy honk flavor relations sumcheck) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp index d1e835e2a29..f8f5e651e37 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp @@ -94,13 +94,13 @@ template void DeciderProver_::execute_zeromorph_rou transcript); } -template plonk::proof& DeciderProver_::export_proof() +template honk::proof& DeciderProver_::export_proof() { - proof.proof_data = transcript->proof_data; + proof = transcript->proof_data; return proof; } -template plonk::proof& DeciderProver_::construct_proof() +template honk::proof& DeciderProver_::construct_proof() { // Add ϕ, \vec{β*}, e* to transcript execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp index 5d962a6b71c..3114446b9c6 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp @@ -2,7 +2,7 @@ #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/instance/prover_instance.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" @@ -32,8 +32,8 @@ template class DeciderProver_ { BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - plonk::proof& export_proof(); - plonk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr accumulator; @@ -52,7 +52,7 @@ template class DeciderProver_ { using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; private: - plonk::proof proof; + honk::proof proof; }; using DeciderProver = DeciderProver_; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 8ab1eb8c06e..ef86acfcb2e 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -26,7 +26,7 @@ DeciderVerifier_::DeciderVerifier_() * e*). * */ -template bool DeciderVerifier_::verify_proof(const plonk::proof& proof) +template bool DeciderVerifier_::verify_proof(const honk::proof& proof) { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; @@ -36,7 +36,7 @@ template bool DeciderVerifier_::verify_proof(const plo using VerifierCommitments = typename Flavor::VerifierCommitments; static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; - transcript = std::make_shared(proof.proof_data); + transcript = std::make_shared(proof); auto inst = std::make_unique(); inst->instance_size = transcript->template receive_from_prover("instance_size"); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp index d3637372d3d..3e9b5607673 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" @@ -18,7 +18,7 @@ template class DeciderVerifier_ { explicit DeciderVerifier_(const std::shared_ptr& transcript, const std::shared_ptr& verifier_key = nullptr); - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp index d3a4dbf8e65..55bbbd826ac 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp @@ -13,6 +13,6 @@ template struct FoldingResult { public: std::shared_ptr> accumulator; // TODO(https://github.com/AztecProtocol/barretenberg/issues/656): turn folding data into a struct - std::vector folding_data; + std::vector folding_data; }; } // namespace bb::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index bf7d4c50117..5c8331e0aaf 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -124,7 +124,7 @@ void ProtoGalaxyVerifier_::receive_and_finalise_instance(cons // TODO(https://github.com/AztecProtocol/barretenberg/issues/795): The rounds prior to actual verifying are common // between decider and folding verifier and could be somehow shared so we do not duplicate code so much. template -void ProtoGalaxyVerifier_::prepare_for_folding(const std::vector& fold_data) +void ProtoGalaxyVerifier_::prepare_for_folding(const std::vector& fold_data) { transcript = std::make_shared(fold_data); auto index = 0; @@ -157,7 +157,7 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec } template -bool ProtoGalaxyVerifier_::verify_folding_proof(std::vector fold_data) +bool ProtoGalaxyVerifier_::verify_folding_proof(const std::vector& fold_data) { prepare_for_folding(fold_data); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp index 6a3f62889c8..cbb23d6cc72 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp @@ -64,7 +64,7 @@ template class ProtoGalaxyVerifier_ { * * @param fold_data The data transmitted via the transcript by the prover. */ - void prepare_for_folding(const std::vector&); + void prepare_for_folding(const std::vector&); /** * @brief Instantiatied the accumulator (i.e. the relaxed instance) from the transcript. @@ -83,7 +83,7 @@ template class ProtoGalaxyVerifier_ { * accumulator, received from the prover is the same as that produced by the verifier. * */ - bool verify_folding_proof(std::vector); + bool verify_folding_proof(const std::vector&); }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt index 3b7a634c740..09dd4c932a3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(stdlib_recursion ecc proof_system stdlib_primitives stdlib_pedersen_commitment stdlib_blake3s ultra_honk eccvm translator_vm) \ No newline at end of file +barretenberg_module(stdlib_recursion ecc proof_system stdlib_primitives stdlib_pedersen_commitment stdlib_blake3s ultra_honk eccvm translator_vm stdlib_poseidon2) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp index 4bf08cc99c0..723ad1f7cf0 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp @@ -3,6 +3,7 @@ #include "barretenberg/ecc/curves/bn254/fq.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/ecc/curves/bn254/g1.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -17,17 +18,17 @@ template class Transcript { public: using field_ct = field_t; using FF = bb::fr; - using BaseTranscript = bb::honk::BaseTranscript; + using NativeTranscript = bb::honk::BaseTranscript; using StdlibTypes = utility::StdlibTypesUtility; - static constexpr size_t HASH_OUTPUT_SIZE = BaseTranscript::HASH_OUTPUT_SIZE; + static constexpr size_t HASH_OUTPUT_SIZE = NativeTranscript::HASH_OUTPUT_SIZE; - BaseTranscript native_transcript; + NativeTranscript native_transcript; Builder* builder; Transcript() = default; - Transcript(Builder* builder, auto proof_data) + Transcript(Builder* builder, const bb::honk::proof& proof_data) : native_transcript(proof_data) , builder(builder){}; @@ -59,7 +60,7 @@ template class Transcript { */ std::array challenges; for (size_t i = 0; i < num_challenges; ++i) { - challenges[i] = field_ct::from_witness(builder, static_cast(native_challenges[i])); + challenges[i] = field_ct::from_witness(builder, native_challenges[i]); } return challenges; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp index 6578f48cc99..101615f51e9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -18,7 +18,7 @@ DeciderRecursiveVerifier_::DeciderRecursiveVerifier_(Builder* builder) */ template std::array DeciderRecursiveVerifier_::verify_proof( - const bb::plonk::proof& proof) + const bb::honk::proof& proof) { using Sumcheck = ::bb::honk::sumcheck::SumcheckVerifier; using Curve = typename Flavor::Curve; @@ -28,7 +28,7 @@ std::array DeciderRecursiveVerifier_:: using Instance = typename ::bb::honk::VerifierInstance_; static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; - transcript = std::make_shared(builder, proof.proof_data); + transcript = std::make_shared(builder, proof); auto inst = std::make_unique(); const auto instance_size = transcript->template receive_from_prover("instance_size"); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp index 18e6b75fa0b..ba6dc021bed 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/flavor/goblin_ultra_recursive.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" @@ -19,7 +19,7 @@ template class DeciderRecursiveVerifier_ { public: explicit DeciderRecursiveVerifier_(Builder* builder); - PairingPoints verify_proof(const bb::plonk::proof& proof); + PairingPoints verify_proof(const bb::honk::proof& proof); std::map commitments; std::shared_ptr pcs_verification_key; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp index eaa93a42d3a..6d809e7ad5a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp @@ -16,9 +16,9 @@ MergeRecursiveVerifier_::MergeRecursiveVerifier_(CircuitBuilder* */ template std::array::Element, 2> MergeRecursiveVerifier_::verify_proof( - const plonk::proof& proof) + const bb::honk::proof& proof) { - transcript = std::make_shared(builder, proof.proof_data); + transcript = std::make_shared(builder, proof); // Receive commitments [t_i^{shift}], [T_{i-1}], and [T_i] std::array C_T_prev; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp index 76815921f4b..411b44fd472 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp @@ -1,6 +1,6 @@ #pragma once #include "barretenberg/commitment_schemes/kzg/kzg.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" @@ -23,7 +23,7 @@ template class MergeRecursiveVerifier_ { explicit MergeRecursiveVerifier_(CircuitBuilder* builder); - PairingPoints verify_proof(const plonk::proof& proof); + PairingPoints verify_proof(const bb::honk::proof& proof); }; } // namespace bb::stdlib::recursion::goblin diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 68c366de5b9..d1fdaeee01b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -164,7 +164,7 @@ template void ProtoGalaxyRecursiveVerifier_ -void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std::vector proof) +void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(const bb::honk::proof& proof) { using Transcript = typename Flavor::Transcript; using ElementNative = typename Flavor::Curve::ElementNative; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp index 64b75719542..7d4305a7ff5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/flavor/goblin_ultra_recursive.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/protogalaxy/folding_result.hpp" #include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" @@ -91,7 +91,7 @@ template class ProtoGalaxyRecursiveVerifier_ { * by the prover, are expressed as constraints. */ - void verify_folding_proof(std::vector proof); + void verify_folding_proof(const bb::honk::proof& proof); /** * @brief Evaluates the perturbator at a given scalar, in a sequential manner for the recursive setting. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp index 4a147608e44..8e86410d3d0 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp @@ -18,7 +18,7 @@ UltraRecursiveVerifier_::UltraRecursiveVerifier_( * */ template -std::array UltraRecursiveVerifier_::verify_proof(const plonk::proof& proof) +std::array UltraRecursiveVerifier_::verify_proof(const bb::honk::proof& proof) { using Sumcheck = ::bb::honk::sumcheck::SumcheckVerifier; using Curve = typename Flavor::Curve; @@ -30,7 +30,7 @@ std::array UltraRecursiveVerifier_::ve RelationParams relation_parameters; - transcript = std::make_shared(builder, proof.proof_data); + transcript = std::make_shared(builder, proof); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp index 5712966f001..00bb9a9c780 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/flavor/goblin_ultra_recursive.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" @@ -23,7 +23,7 @@ template class UltraRecursiveVerifier_ { // TODO(luke): Eventually this will return something like aggregation_state but I'm simplifying for now until we // determine the exact interface. Simply returns the two pairing points. - PairingPoints verify_proof(const plonk::proof& proof); + PairingPoints verify_proof(const bb::honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/transcript/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/transcript/CMakeLists.txt index 5f44c7b2463..ff33c7197e5 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/transcript/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(transcript crypto_blake3s crypto_pedersen_hash) \ No newline at end of file +barretenberg_module(transcript crypto_poseidon2) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index cf791175c98..aaa3b193d98 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -1,8 +1,11 @@ #pragma once #include "barretenberg/common/serialize.hpp" -#include "barretenberg/crypto/blake3s/blake3s.hpp" -#include "barretenberg/crypto/pedersen_hash/pedersen.hpp" +#include "barretenberg/crypto/poseidon2/poseidon2.hpp" +#include "barretenberg/ecc/curves/bn254/g1.hpp" +#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" +#include "barretenberg/ecc/fields/field_conversion.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" // #define LOG_CHALLENGES // #define LOG_INTERACTIONS @@ -61,7 +64,9 @@ class TranscriptManifest { */ class BaseTranscript { public: - using Proof = std::vector; + using Fr = bb::fr; + using Poseidon2Params = crypto::Poseidon2Bn254ScalarFieldParams; + using Proof = honk::proof; BaseTranscript() = default; @@ -76,15 +81,14 @@ class BaseTranscript { static constexpr size_t HASH_OUTPUT_SIZE = 32; std::ptrdiff_t proof_start = 0; - size_t num_bytes_written = 0; // the number of bytes written to proof_data by the prover or the verifier - size_t num_bytes_read = 0; // the number of bytes read from proof_data by the verifier - size_t round_number = 0; // current round for manifest + size_t num_frs_written = 0; // the number of bb::frs written to proof_data by the prover or the verifier + size_t num_frs_read = 0; // the number of bb::frs read from proof_data by the verifier + size_t round_number = 0; // current round for manifest private: - static constexpr size_t MIN_BYTES_PER_CHALLENGE = 128 / 8; // 128 bit challenges bool is_first_challenge = true; // indicates if this is the first challenge this transcript is generating - std::array previous_challenge_buffer{}; // default-initialized to zeros - std::vector current_round_data; + Fr previous_challenge{}; // default-initialized to zeros + std::vector current_round_data; // "Manifest" object that records a summary of the transcript interactions TranscriptManifest manifest; @@ -93,11 +97,11 @@ class BaseTranscript { * @brief Compute next challenge c_next = H( Compress(c_prev || round_buffer) ) * @details This function computes a new challenge for the current round using the previous challenge * and the current round data, if they are exist. It clears the current_round_data if nonempty after - * computing the challenge to minimize how much we compress. It also sets previous_challenge_buffer + * computing the challenge to minimize how much we compress. It also sets previous_challenge * to the current challenge buffer to set up next function call. - * @return std::array + * @return std::array */ - [[nodiscard]] std::array get_next_challenge_buffer() + [[nodiscard]] Fr get_next_challenge_buffer() { // Prevent challenge generation if this is the first challenge we're generating, // AND nothing was sent by the prover. @@ -109,33 +113,31 @@ class BaseTranscript { // TODO(Adrian): Do we want to use a domain separator as the initial challenge buffer? // We could be cheeky and use the hash of the manifest as domain separator, which would prevent us from having // to domain separate all the data. (See https://safe-hash.dev) - std::vector full_buffer; + std::vector full_buffer; if (!is_first_challenge) { - // if not the first challenge, we can use the previous_challenge_buffer - full_buffer.insert(full_buffer.end(), previous_challenge_buffer.begin(), previous_challenge_buffer.end()); + // if not the first challenge, we can use the previous_challenge + full_buffer.emplace_back(previous_challenge); } else { // Update is_first_challenge for the future is_first_challenge = false; } if (!current_round_data.empty()) { - full_buffer.insert(full_buffer.end(), current_round_data.begin(), current_round_data.end()); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/832): investigate why + // full_buffer.insert(full_buffer.end(), current_round_data.begin(), current_round_data.end()); fails to + // compile with gcc + std::copy(current_round_data.begin(), current_round_data.end(), std::back_inserter(full_buffer)); current_round_data.clear(); // clear the round data buffer since it has been used } - // Pre-hash the full buffer to minimize the amount of data passed to the cryptographic hash function. - // Only a collision-resistant hash-function like Pedersen is required for this step. - // Note: this pre-hashing is an efficiency trick that may be discareded if using a SNARK-friendly or in contexts - // (eg smart contract verification) where the cost of elliptic curve operations is high. - std::vector compressed_buffer = to_buffer(crypto::pedersen_hash::hash_buffer(full_buffer)); + // Hash the full buffer with poseidon2, which is believed to be a collision resistant hash function and a random + // oracle, removing the need to pre-hash to compress and then hash with a random oracle, as we previously did + // with Pedersen and Blake3s. + Fr base_hash = crypto::Poseidon2::hash(full_buffer); - // Use a strong hash function to derive the new challenge_buffer. - auto base_hash = blake3::blake3s(compressed_buffer); - - std::array new_challenge_buffer; - std::copy_n(base_hash.begin(), HASH_OUTPUT_SIZE, new_challenge_buffer.begin()); + Fr new_challenge = base_hash; // update previous challenge buffer for next time we call this function - previous_challenge_buffer = new_challenge_buffer; - return new_challenge_buffer; + previous_challenge = new_challenge; + return new_challenge; }; protected: @@ -143,35 +145,35 @@ class BaseTranscript { * @brief Adds challenge elements to the current_round_buffer and updates the manifest. * * @param label of the element sent - * @param element_bytes serialized + * @param element_frs serialized */ - void consume_prover_element_bytes(const std::string& label, std::span element_bytes) + void consume_prover_element_frs(const std::string& label, std::span element_frs) { // Add an entry to the current round of the manifest - manifest.add_entry(round_number, label, element_bytes.size()); + manifest.add_entry(round_number, label, element_frs.size()); - current_round_data.insert(current_round_data.end(), element_bytes.begin(), element_bytes.end()); + current_round_data.insert(current_round_data.end(), element_frs.begin(), element_frs.end()); - num_bytes_written += element_bytes.size(); + num_frs_written += element_frs.size(); } /** * @brief Serializes object and appends it to proof_data * @details Calls to_buffer on element to serialize, and modifies proof_data object by appending the serialized - * bytes to it. + * frs to it. * @tparam T * @param element * @param proof_data */ template void serialize_to_buffer(const T& element, Proof& proof_data) { - auto element_bytes = to_buffer(element); - proof_data.insert(proof_data.end(), element_bytes.begin(), element_bytes.end()); + auto element_frs = bb::field_conversion::convert_to_bn254_frs(element); + proof_data.insert(proof_data.end(), element_frs.begin(), element_frs.end()); } /** - * @brief Deserializes the bytes starting at offset into the typed element and returns that element. - * @details Using the template parameter and the offset argument, this function deserializes the bytes with - * from_buffer and then increments the offset appropriately based on the number of bytes that were deserialized. + * @brief Deserializes the frs starting at offset into the typed element and returns that element. + * @details Using the template parameter and the offset argument, this function deserializes the frs with + * from_buffer and then increments the offset appropriately based on the number of frs that were deserialized. * @tparam T * @param proof_data * @param offset @@ -179,13 +181,13 @@ class BaseTranscript { */ template T deserialize_from_buffer(const Proof& proof_data, size_t& offset) const { - constexpr size_t element_size = sizeof(T); - ASSERT(offset + element_size <= proof_data.size()); + constexpr size_t element_fr_size = bb::field_conversion::calc_num_bn254_frs(); + ASSERT(offset + element_fr_size <= proof_data.size()); - auto element_bytes = std::span{ proof_data }.subspan(offset, element_size); - offset += element_size; + auto element_frs = std::span{ proof_data }.subspan(offset, element_fr_size); + offset += element_fr_size; - T element = from_buffer(element_bytes); + auto element = bb::field_conversion::convert_from_bn254_frs(element_frs); return element; } @@ -198,16 +200,16 @@ class BaseTranscript { * @brief Return the proof data starting at proof_start * @details This is useful for when two different provers share a transcript. */ - std::vector export_proof() + std::vector export_proof() { - std::vector result(num_bytes_written); - std::copy_n(proof_data.begin() + proof_start, num_bytes_written, result.begin()); - proof_start += static_cast(num_bytes_written); - num_bytes_written = 0; + std::vector result(num_frs_written); + std::copy_n(proof_data.begin() + proof_start, num_frs_written, result.begin()); + proof_start += static_cast(num_frs_written); + num_frs_written = 0; return result; }; - void load_proof(const std::vector& proof) + void load_proof(const std::vector& proof) { std::copy(proof.begin(), proof.end(), std::back_inserter(proof_data)); } @@ -221,7 +223,7 @@ class BaseTranscript { * multiple challenges. * * @param labels human-readable names for the challenges for the manifest - * @return std::array challenges for this round. + * @return std::array challenges for this round. */ template std::array get_challenges(const Strings&... labels) { @@ -232,20 +234,23 @@ class BaseTranscript { // Compute the new challenge buffer from which we derive the challenges. - // Create challenges from bytes. + // Create challenges from Frs. std::array challenges{}; // Generate the challenges by iteratively hashing over the previous challenge. for (size_t i = 0; i < num_challenges; i++) { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/741): Optimize this by truncating hash to 128 + // bits or by splitting hash into 2 challenges. + /* auto next_challenge_buffer = get_next_challenge_buffer(); // get next challenge buffer - std::array field_element_buffer{}; - // copy half of the hash to lower 128 bits of challenge - // Note: because of how read() from buffers to fields works (in field_declarations.hpp), - // we use the later half of the buffer - std::copy_n(next_challenge_buffer.begin(), + Fr field_element_buffer = next_challenge_buffer; + // copy half of the hash to lower 128 bits of challenge Note: because of how read() from buffers to fields + works (in field_declarations.hpp), we use the later half of the buffer + // std::copy_n(next_challenge_buffer.begin(), HASH_OUTPUT_SIZE / 2, field_element_buffer.begin() + HASH_OUTPUT_SIZE / 2); - challenges[i] = from_buffer(field_element_buffer); + */ + challenges[i] = static_cast(get_next_challenge_buffer()); } // Prepare for next round. @@ -258,7 +263,7 @@ class BaseTranscript { * @brief Adds a prover message to the transcript, only intended to be used by the prover. * * @details Serializes the provided object into `proof_data`, and updates the current round state in - * consume_prover_element_bytes. + * consume_prover_element_frs. * * @param label Description/name of the object being added. * @param element Serializable object that will be added to the transcript @@ -269,19 +274,19 @@ class BaseTranscript { */ template void send_to_verifier(const std::string& label, const T& element) { - using serialize::write; // TODO(Adrian): Ensure that serialization of affine elements (including point at infinity) is consistent. // TODO(Adrian): Consider restricting serialization (via concepts) to types T for which sizeof(T) reliably - // returns the size of T in bytes. (E.g. this is true for std::array but not for std::vector). - auto element_bytes = to_buffer(element); - proof_data.insert(proof_data.end(), element_bytes.begin(), element_bytes.end()); + // returns the size of T in frs. (E.g. this is true for std::array but not for std::vector). + // convert element to field elements + auto element_frs = bb::field_conversion::convert_to_bn254_frs(element); + proof_data.insert(proof_data.end(), element_frs.begin(), element_frs.end()); #ifdef LOG_INTERACTIONS if constexpr (Loggable) { info("sent: ", label, ": ", element); } #endif - BaseTranscript::consume_prover_element_bytes(label, element_bytes); + BaseTranscript::consume_prover_element_frs(label, element_frs); } /** @@ -292,15 +297,15 @@ class BaseTranscript { */ template T receive_from_prover(const std::string& label) { - constexpr size_t element_size = sizeof(T); - ASSERT(num_bytes_read + element_size <= proof_data.size()); + constexpr size_t element_size = bb::field_conversion::calc_num_bn254_frs(); + ASSERT(num_frs_read + element_size <= proof_data.size()); - auto element_bytes = std::span{ proof_data }.subspan(num_bytes_read, element_size); - num_bytes_read += element_size; + auto element_frs = std::span{ proof_data }.subspan(num_frs_read, element_size); + num_frs_read += element_size; - BaseTranscript::consume_prover_element_bytes(label, element_bytes); + BaseTranscript::consume_prover_element_frs(label, element_frs); - T element = from_buffer(element_bytes); + auto element = bb::field_conversion::convert_from_bn254_frs(element_frs); #ifdef LOG_INTERACTIONS if constexpr (Loggable) { @@ -354,12 +359,12 @@ class BaseTranscript { /** * @brief Convert an array of uint256_t's to an array of field elements - * @details The syntax `std::array [a, b] = transcript.get_challenges("a", "b")` is unfortunately not allowed + * @details The syntax `std::array [a, b] = transcript.get_challenges("a", "b")` is unfortunately not allowed * (structured bindings must be defined with auto return type), so we need a workaround. */ -template std::array challenges_to_field_elements(std::array&& arr) +template std::array challenges_to_field_elements(std::array&& arr) { - std::array result; + std::array result; std::move(arr.begin(), arr.end(), result.begin()); return result; } diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index f9698f1a6c8..05ff79c73e5 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -16,8 +16,8 @@ TEST(BaseTranscript, TwoProversTwoFields) { const auto EXPECT_STATE = [](const Transcript& transcript, size_t start, size_t written, size_t read) { EXPECT_EQ(transcript.proof_start, static_cast(start)); - EXPECT_EQ(transcript.num_bytes_written, written); - EXPECT_EQ(transcript.num_bytes_read, read); + EXPECT_EQ(transcript.num_frs_written, written); + EXPECT_EQ(transcript.num_frs_read, read); }; Transcript prover_transcript; @@ -25,25 +25,87 @@ TEST(BaseTranscript, TwoProversTwoFields) EXPECT_STATE(prover_transcript, /*start*/ 0, /*written*/ 0, /*read*/ 0); Fr elt_a = 1377; prover_transcript.send_to_verifier("a", elt_a); - EXPECT_STATE(prover_transcript, /*start*/ 0, /*written*/ 32, /*read*/ 0); + EXPECT_STATE(prover_transcript, /*start*/ 0, /*written*/ 1, /*read*/ 0); Transcript verifier_transcript{ prover_transcript.export_proof() }; // export resets read/write state and sets start in prep for next export - EXPECT_STATE(prover_transcript, /*start*/ 32, /*written*/ 0, /*read*/ 0); + EXPECT_STATE(prover_transcript, /*start*/ 1, /*written*/ 0, /*read*/ 0); // state initializes to zero EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 0, /*read*/ 0); Fr received_a = verifier_transcript.receive_from_prover("a"); - // receiving is reading bytes input and writing them to an internal proof_data buffer - EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 32, /*read*/ 32); + // receiving is reading frs input and writing them to an internal proof_data buffer + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 1, /*read*/ 1); EXPECT_EQ(received_a, elt_a); + // send grumpkin::fr Fq elt_b = 773; prover_transcript.send_to_verifier("b", elt_b); - EXPECT_STATE(prover_transcript, /*start*/ 32, /*written*/ 32, /*read*/ 0); + EXPECT_STATE(prover_transcript, /*start*/ 1, /*written*/ 2, /*read*/ 0); verifier_transcript.load_proof(prover_transcript.export_proof()); - EXPECT_STATE(prover_transcript, /*start*/ 64, /*written*/ 0, /*read*/ 0); - // load proof is not an action by a prover or verifeir, so it does not change read/write counts - EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 32, /*read*/ 32); + EXPECT_STATE(prover_transcript, /*start*/ 3, /*written*/ 0, /*read*/ 0); + // load proof is not an action by a prover or verifier, so it does not change read/write counts + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 1, /*read*/ 1); Fq received_b = verifier_transcript.receive_from_prover("b"); - EXPECT_STATE(verifier_transcript, 0, 64, 64); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 3, /*read*/ 3); EXPECT_EQ(received_b, elt_b); + + // send uint32_t + uint32_t elt_c = 43; + prover_transcript.send_to_verifier("c", elt_c); + EXPECT_STATE(prover_transcript, /*start*/ 3, /*written*/ 1, /*read*/ 0); + verifier_transcript.load_proof(prover_transcript.export_proof()); + EXPECT_STATE(prover_transcript, /*start*/ 4, /*written*/ 0, /*read*/ 0); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 3, /*read*/ 3); + auto received_c = verifier_transcript.receive_from_prover("c"); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 4, /*read*/ 4); + EXPECT_EQ(received_c, elt_c); + + // send curve::BN254::AffineElement + curve::BN254::AffineElement elt_d = bb::g1::affine_one; + prover_transcript.send_to_verifier("d", elt_d); + EXPECT_STATE(prover_transcript, /*start*/ 4, /*written*/ 4, /*read*/ 0); + verifier_transcript.load_proof(prover_transcript.export_proof()); + EXPECT_STATE(prover_transcript, /*start*/ 8, /*written*/ 0, /*read*/ 0); + auto received_d = verifier_transcript.receive_from_prover("d"); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 8, /*read*/ 8); + EXPECT_EQ(received_d, elt_d); + + // send std::array + std::array elt_e = { 1, 2, 3, 4, 5 }; + prover_transcript.send_to_verifier("e", elt_e); + EXPECT_STATE(prover_transcript, /*start*/ 8, /*written*/ 5, /*read*/ 0); + verifier_transcript.load_proof(prover_transcript.export_proof()); + EXPECT_STATE(prover_transcript, /*start*/ 13, /*written*/ 0, /*read*/ 0); + auto received_e = verifier_transcript.receive_from_prover>("e"); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 13, /*read*/ 13); + EXPECT_EQ(received_e, elt_e); + + // send std::array + std::array elt_f = { 9, 12515, 1231, 745, 124, 6231, 957 }; + prover_transcript.send_to_verifier("f", elt_f); + EXPECT_STATE(prover_transcript, /*start*/ 13, /*written*/ 14, /*read*/ 0); + verifier_transcript.load_proof(prover_transcript.export_proof()); + EXPECT_STATE(prover_transcript, /*start*/ 27, /*written*/ 0, /*read*/ 0); + auto received_f = verifier_transcript.receive_from_prover>("f"); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 27, /*read*/ 27); + EXPECT_EQ(received_f, elt_f); + + // send Univariate + bb::Univariate elt_g{ std::array({ 5, 6, 7, 8 }) }; + prover_transcript.send_to_verifier("g", elt_g); + EXPECT_STATE(prover_transcript, /*start*/ 27, /*written*/ 4, /*read*/ 0); + verifier_transcript.load_proof(prover_transcript.export_proof()); + EXPECT_STATE(prover_transcript, /*start*/ 31, /*written*/ 0, /*read*/ 0); + auto received_g = verifier_transcript.receive_from_prover>("g"); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 31, /*read*/ 31); + EXPECT_EQ(received_g, elt_g); + + // send Univariate + bb::Univariate elt_h{ std::array({ 9, 10, 11 }) }; + prover_transcript.send_to_verifier("h", elt_h); + EXPECT_STATE(prover_transcript, /*start*/ 31, /*written*/ 6, /*read*/ 0); + verifier_transcript.load_proof(prover_transcript.export_proof()); + EXPECT_STATE(prover_transcript, /*start*/ 37, /*written*/ 0, /*read*/ 0); + auto received_h = verifier_transcript.receive_from_prover>("h"); + EXPECT_STATE(verifier_transcript, /*start*/ 0, /*written*/ 37, /*read*/ 37); + EXPECT_EQ(received_h, elt_h); } diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp index b25a3cb5059..da407ae15bd 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp @@ -168,13 +168,13 @@ void GoblinTranslatorProver::execute_zeromorph_rounds() prover_polynomials.get_concatenation_groups()); } -plonk::proof& GoblinTranslatorProver::export_proof() +honk::proof& GoblinTranslatorProver::export_proof() { - proof.proof_data = transcript->export_proof(); + proof = transcript->export_proof(); return proof; } -plonk::proof& GoblinTranslatorProver::construct_proof() +honk::proof& GoblinTranslatorProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp index beeb72e3646..5709f504e9d 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp @@ -1,6 +1,6 @@ #pragma once #include "barretenberg/flavor/goblin_translator.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" @@ -32,8 +32,8 @@ class GoblinTranslatorProver { BBERG_PROFILE void execute_grand_product_computation_round(); BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - plonk::proof& export_proof(); - plonk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -51,7 +51,7 @@ class GoblinTranslatorProver { sumcheck::SumcheckOutput sumcheck_output; private: - plonk::proof proof; + honk::proof proof; }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 0cced54df80..b83f0b449a8 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -65,10 +65,10 @@ void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters(const /** * @brief This function verifies an GoblinTranslator Honk proof for given program settings. */ -bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) +bool GoblinTranslatorVerifier::verify_proof(const honk::proof& proof) { batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); - transcript->load_proof(proof.proof_data); + transcript->load_proof(proof); Flavor::VerifierCommitments commitments{ key }; Flavor::CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp index 3418501fcc4..977dc9ed8a8 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/flavor/goblin_translator.hpp" #include "barretenberg/goblin/translation_evaluations.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" namespace bb::honk { class GoblinTranslatorVerifier { @@ -35,7 +35,7 @@ class GoblinTranslatorVerifier { void put_translation_data_in_relation_parameters(const uint256_t& evaluation_input_x, const BF& batching_challenge_v, const uint256_t& accumulated_result); - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); bool verify_translation(const TranslationEvaluations& translation_evaluations); }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 0865eff99bb..70247e48a0d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -36,37 +36,37 @@ class GoblinUltraTranscriptTests : public ::testing::Test { size_t MAX_PARTIAL_RELATION_LENGTH = Flavor::BATCHED_RELATION_PARTIAL_LENGTH; size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; - size_t size_FF = sizeof(FF); - size_t size_G = 2 * size_FF; - size_t size_uni = MAX_PARTIAL_RELATION_LENGTH * size_FF; - size_t size_evals = (Flavor::NUM_ALL_ENTITIES)*size_FF; - size_t size_uint32 = 4; + size_t frs_per_Fr = bb::field_conversion::calc_num_bn254_frs(); + size_t frs_per_G = bb::field_conversion::calc_num_bn254_frs(); + size_t frs_per_uni = MAX_PARTIAL_RELATION_LENGTH * frs_per_Fr; + size_t frs_per_evals = (Flavor::NUM_ALL_ENTITIES)*frs_per_Fr; + size_t frs_per_uint32 = bb::field_conversion::calc_num_bn254_frs(); size_t round = 0; - manifest_expected.add_entry(round, "circuit_size", size_uint32); - manifest_expected.add_entry(round, "public_input_size", size_uint32); - manifest_expected.add_entry(round, "pub_inputs_offset", size_uint32); - manifest_expected.add_entry(round, "public_input_0", size_FF); - manifest_expected.add_entry(round, "W_L", size_G); - manifest_expected.add_entry(round, "W_R", size_G); - manifest_expected.add_entry(round, "W_O", size_G); - manifest_expected.add_entry(round, "ECC_OP_WIRE_1", size_G); - manifest_expected.add_entry(round, "ECC_OP_WIRE_2", size_G); - manifest_expected.add_entry(round, "ECC_OP_WIRE_3", size_G); - manifest_expected.add_entry(round, "ECC_OP_WIRE_4", size_G); - manifest_expected.add_entry(round, "CALLDATA", size_G); - manifest_expected.add_entry(round, "CALLDATA_READ_COUNTS", size_G); + manifest_expected.add_entry(round, "circuit_size", frs_per_uint32); + manifest_expected.add_entry(round, "public_input_size", frs_per_uint32); + manifest_expected.add_entry(round, "pub_inputs_offset", frs_per_uint32); + manifest_expected.add_entry(round, "public_input_0", frs_per_Fr); + manifest_expected.add_entry(round, "W_L", frs_per_G); + manifest_expected.add_entry(round, "W_R", frs_per_G); + manifest_expected.add_entry(round, "W_O", frs_per_G); + manifest_expected.add_entry(round, "ECC_OP_WIRE_1", frs_per_G); + manifest_expected.add_entry(round, "ECC_OP_WIRE_2", frs_per_G); + manifest_expected.add_entry(round, "ECC_OP_WIRE_3", frs_per_G); + manifest_expected.add_entry(round, "ECC_OP_WIRE_4", frs_per_G); + manifest_expected.add_entry(round, "CALLDATA", frs_per_G); + manifest_expected.add_entry(round, "CALLDATA_READ_COUNTS", frs_per_G); manifest_expected.add_challenge(round, "eta"); round++; - manifest_expected.add_entry(round, "SORTED_ACCUM", size_G); - manifest_expected.add_entry(round, "W_4", size_G); + manifest_expected.add_entry(round, "SORTED_ACCUM", frs_per_G); + manifest_expected.add_entry(round, "W_4", frs_per_G); manifest_expected.add_challenge(round, "beta", "gamma"); round++; - manifest_expected.add_entry(round, "LOOKUP_INVERSES", size_G); - manifest_expected.add_entry(round, "Z_PERM", size_G); - manifest_expected.add_entry(round, "Z_LOOKUP", size_G); + manifest_expected.add_entry(round, "LOOKUP_INVERSES", frs_per_G); + manifest_expected.add_entry(round, "Z_PERM", frs_per_G); + manifest_expected.add_entry(round, "Z_LOOKUP", frs_per_G); for (size_t i = 0; i < NUM_SUBRELATIONS - 1; i++) { std::string label = "Sumcheck:alpha_" + std::to_string(i); @@ -82,29 +82,29 @@ class GoblinUltraTranscriptTests : public ::testing::Test { for (size_t i = 0; i < log_n; ++i) { std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "Sumcheck:univariate_" + idx, size_uni); + manifest_expected.add_entry(round, "Sumcheck:univariate_" + idx, frs_per_uni); std::string label = "Sumcheck:u_" + idx; manifest_expected.add_challenge(round, label); round++; } - manifest_expected.add_entry(round, "Sumcheck:evaluations", size_evals); + manifest_expected.add_entry(round, "Sumcheck:evaluations", frs_per_evals); manifest_expected.add_challenge(round, "rho"); round++; for (size_t i = 0; i < log_n; ++i) { std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "ZM:C_q_" + idx, size_G); + manifest_expected.add_entry(round, "ZM:C_q_" + idx, frs_per_G); } manifest_expected.add_challenge(round, "ZM:y"); round++; - manifest_expected.add_entry(round, "ZM:C_q", size_G); + manifest_expected.add_entry(round, "ZM:C_q", frs_per_G); manifest_expected.add_challenge(round, "ZM:x", "ZM:z"); round++; // TODO(Mara): Make testing more flavor agnostic so we can test this with all flavors - manifest_expected.add_entry(round, "ZM:PI", size_G); + manifest_expected.add_entry(round, "ZM:PI", frs_per_G); manifest_expected.add_challenge(round); // no challenge return manifest_expected; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index f0f603f276a..c79fe9a8689 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp @@ -27,9 +27,9 @@ MergeProver_::MergeProver_(const std::shared_ptr& commitm * for details (https://github.com/AztecProtocol/barretenberg/issues/746). * * @tparam Flavor - * @return plonk::proof& + * @return honk::proof& */ -template plonk::proof& MergeProver_::construct_proof() +template honk::proof& MergeProver_::construct_proof() { size_t N = op_queue->get_current_size(); @@ -112,7 +112,7 @@ template plonk::proof& MergeProver_::construct_proof() auto quotient_commitment = pcs_commitment_key->commit(quotient); transcript->send_to_verifier("KZG:W", quotient_commitment); - proof.proof_data = transcript->proof_data; + proof = transcript->proof_data; return proof; } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp index ab16e7fcc2b..8693f77ed8c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp @@ -3,7 +3,7 @@ #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/proof_system/op_queue/ecc_op_queue.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -33,10 +33,10 @@ template class MergeProver_ { explicit MergeProver_(const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); - BBERG_PROFILE plonk::proof& construct_proof(); + BBERG_PROFILE honk::proof& construct_proof(); private: - plonk::proof proof; + honk::proof proof; }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index 33ec28e80b6..a50c25a0d57 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -16,11 +16,11 @@ MergeVerifier_::MergeVerifier_() * queue has been constructed correctly via a simple Schwartz-Zippel check. Evaluations are checked via batched KZG. * * @tparam Flavor - * @return plonk::proof& + * @return honk::proof& */ -template bool MergeVerifier_::verify_proof(const plonk::proof& proof) +template bool MergeVerifier_::verify_proof(const honk::proof& proof) { - transcript = std::make_shared(proof.proof_data); + transcript = std::make_shared(proof); // Receive commitments [t_i^{shift}], [T_{i-1}], and [T_i] std::array C_T_prev; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp index 87abe72d49e..a32d071eb9b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp @@ -3,7 +3,7 @@ #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/proof_system/op_queue/ecc_op_queue.hpp" #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -33,7 +33,7 @@ template class MergeVerifier_ { std::shared_ptr pcs_verification_key; explicit MergeVerifier_(); - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 2622a247fc4..40fc15a3369 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -178,13 +178,13 @@ template void UltraProver_::execute_zeromorph_round transcript); } -template plonk::proof& UltraProver_::export_proof() +template honk::proof& UltraProver_::export_proof() { - proof.proof_data = transcript->proof_data; + proof = transcript->proof_data; return proof; } -template plonk::proof& UltraProver_::construct_proof() +template honk::proof& UltraProver_::construct_proof() { // Add circuit size public input size and public inputs to transcript-> execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp index ba73af94125..13d3a1cc1b8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -2,7 +2,7 @@ #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/instance/prover_instance.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" @@ -35,8 +35,8 @@ template class UltraProver_ { BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - plonk::proof& export_proof(); - plonk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr instance; @@ -55,7 +55,7 @@ template class UltraProver_ { using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; private: - plonk::proof proof; + honk::proof proof; }; using UltraProver = UltraProver_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 9fe521be717..3dc2e8f1d3b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -35,30 +35,31 @@ class UltraTranscriptTests : public ::testing::Test { size_t MAX_PARTIAL_RELATION_LENGTH = Flavor::BATCHED_RELATION_PARTIAL_LENGTH; size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; - size_t size_FF = sizeof(FF); - size_t size_G = 2 * size_FF; - size_t size_uni = MAX_PARTIAL_RELATION_LENGTH * size_FF; - size_t size_evals = (Flavor::NUM_ALL_ENTITIES)*size_FF; - size_t size_uint32 = 4; + // Size of types is number of bb::frs needed to represent the types + size_t frs_per_Fr = bb::field_conversion::calc_num_bn254_frs(); + size_t frs_per_G = bb::field_conversion::calc_num_bn254_frs(); + size_t frs_per_uni = MAX_PARTIAL_RELATION_LENGTH * frs_per_Fr; + size_t frs_per_evals = (Flavor::NUM_ALL_ENTITIES)*frs_per_Fr; + size_t frs_per_uint32 = bb::field_conversion::calc_num_bn254_frs(); size_t round = 0; - manifest_expected.add_entry(round, "circuit_size", size_uint32); - manifest_expected.add_entry(round, "public_input_size", size_uint32); - manifest_expected.add_entry(round, "pub_inputs_offset", size_uint32); - manifest_expected.add_entry(round, "public_input_0", size_FF); - manifest_expected.add_entry(round, "W_L", size_G); - manifest_expected.add_entry(round, "W_R", size_G); - manifest_expected.add_entry(round, "W_O", size_G); + manifest_expected.add_entry(round, "circuit_size", frs_per_uint32); + manifest_expected.add_entry(round, "public_input_size", frs_per_uint32); + manifest_expected.add_entry(round, "pub_inputs_offset", frs_per_uint32); + manifest_expected.add_entry(round, "public_input_0", frs_per_Fr); + manifest_expected.add_entry(round, "W_L", frs_per_G); + manifest_expected.add_entry(round, "W_R", frs_per_G); + manifest_expected.add_entry(round, "W_O", frs_per_G); manifest_expected.add_challenge(round, "eta"); round++; - manifest_expected.add_entry(round, "SORTED_ACCUM", size_G); - manifest_expected.add_entry(round, "W_4", size_G); + manifest_expected.add_entry(round, "SORTED_ACCUM", frs_per_G); + manifest_expected.add_entry(round, "W_4", frs_per_G); manifest_expected.add_challenge(round, "beta", "gamma"); round++; - manifest_expected.add_entry(round, "Z_PERM", size_G); - manifest_expected.add_entry(round, "Z_LOOKUP", size_G); + manifest_expected.add_entry(round, "Z_PERM", frs_per_G); + manifest_expected.add_entry(round, "Z_LOOKUP", frs_per_G); for (size_t i = 0; i < NUM_SUBRELATIONS - 1; i++) { std::string label = "Sumcheck:alpha_" + std::to_string(i); @@ -74,29 +75,29 @@ class UltraTranscriptTests : public ::testing::Test { for (size_t i = 0; i < log_n; ++i) { std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "Sumcheck:univariate_" + idx, size_uni); + manifest_expected.add_entry(round, "Sumcheck:univariate_" + idx, frs_per_uni); std::string label = "Sumcheck:u_" + idx; manifest_expected.add_challenge(round, label); round++; } - manifest_expected.add_entry(round, "Sumcheck:evaluations", size_evals); + manifest_expected.add_entry(round, "Sumcheck:evaluations", frs_per_evals); manifest_expected.add_challenge(round, "rho"); round++; for (size_t i = 0; i < log_n; ++i) { std::string idx = std::to_string(i); - manifest_expected.add_entry(round, "ZM:C_q_" + idx, size_G); + manifest_expected.add_entry(round, "ZM:C_q_" + idx, frs_per_G); } manifest_expected.add_challenge(round, "ZM:y"); round++; - manifest_expected.add_entry(round, "ZM:C_q", size_G); + manifest_expected.add_entry(round, "ZM:C_q", frs_per_G); manifest_expected.add_challenge(round, "ZM:x", "ZM:z"); round++; // TODO(Mara): Make testing more flavor agnostic so we can test this with all flavors - manifest_expected.add_entry(round, "ZM:PI", size_G); + manifest_expected.add_entry(round, "ZM:PI", frs_per_G); manifest_expected.add_challenge(round); // no challenge return manifest_expected; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 36c25477e4c..b0ee1339dd1 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -45,7 +45,7 @@ template UltraVerifier_& UltraVerifier_::opera * @brief This function verifies an Ultra Honk proof for a given Flavor. * */ -template bool UltraVerifier_::verify_proof(const plonk::proof& proof) +template bool UltraVerifier_::verify_proof(const honk::proof& proof) { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; @@ -56,7 +56,7 @@ template bool UltraVerifier_::verify_proof(const plonk bb::RelationParameters relation_parameters; - transcript = std::make_shared(proof.proof_data); + transcript = std::make_shared(proof); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index 77a770a8f93..0c5dd4a9f1d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" @@ -24,7 +24,7 @@ template class UltraVerifier_ { UltraVerifier_& operator=(const UltraVerifier_& other) = delete; UltraVerifier_& operator=(UltraVerifier_&& other); - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp index 1cbf7b5e353..22703836848 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp @@ -22,7 +22,7 @@ namespace avm_trace { * @throws runtime_error exception when the bytecode is invalid. * @return A zk proof of the execution. */ -plonk::proof Execution::run_and_prove(std::vector const& bytecode, std::vector const& calldata) +honk::proof Execution::run_and_prove(std::vector const& bytecode, std::vector const& calldata) { auto instructions = parse(bytecode); auto trace = gen_trace(instructions, calldata); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp index 42baa71f5c0..db6ffce56b0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp @@ -1,6 +1,6 @@ #pragma once -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/vm/avm_trace/AvmMini_common.hpp" #include "barretenberg/vm/avm_trace/AvmMini_instructions.hpp" #include "barretenberg/vm/avm_trace/AvmMini_trace.hpp" @@ -22,7 +22,7 @@ class Execution { static std::vector parse(std::vector const& bytecode); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata); - static plonk::proof run_and_prove(std::vector const& bytecode, std::vector const& calldata); + static honk::proof run_and_prove(std::vector const& bytecode, std::vector const& calldata); }; } // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index 552582558c4..5dc17405239 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp @@ -14,6 +14,7 @@ namespace bb::honk { using Flavor = honk::flavor::AvmMiniFlavor; +using FF = Flavor::FF; /** * Create AvmMiniProver from proving key, witness and manifest. @@ -98,13 +99,13 @@ void AvmMiniProver::execute_zeromorph_rounds() transcript); } -plonk::proof& AvmMiniProver::export_proof() +honk::proof& AvmMiniProver::export_proof() { - proof.proof_data = transcript->proof_data; + proof = transcript->proof_data; return proof; } -plonk::proof& AvmMiniProver::construct_proof() +bb::honk::proof& AvmMiniProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp index 42b89a228f2..7c88d3b455e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp @@ -3,7 +3,7 @@ #pragma once #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/flavor/generated/AvmMini_flavor.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -31,8 +31,8 @@ class AvmMiniProver { void execute_relation_check_rounds(); void execute_zeromorph_rounds(); - plonk::proof& export_proof(); - plonk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -56,7 +56,7 @@ class AvmMiniProver { using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; private: - plonk::proof proof; + honk::proof proof; }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 09beb8a866e..5d18e651ac7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -30,7 +30,7 @@ AvmMiniVerifier& AvmMiniVerifier::operator=(AvmMiniVerifier&& other) noexcept * @brief This function verifies an AvmMini Honk proof for given program settings. * */ -bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) +bool AvmMiniVerifier::verify_proof(const honk::proof& proof) { using Flavor = honk::flavor::AvmMiniFlavor; using FF = Flavor::FF; @@ -42,7 +42,7 @@ bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) RelationParameters relation_parameters; - transcript = std::make_shared(proof.proof_data); + transcript = std::make_shared(proof); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp index 31b04749640..81aa4eea673 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp @@ -2,7 +2,7 @@ #pragma once #include "barretenberg/flavor/generated/AvmMini_flavor.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" namespace bb::honk { @@ -22,7 +22,7 @@ class AvmMiniVerifier { AvmMiniVerifier& operator=(const AvmMiniVerifier& other) = delete; AvmMiniVerifier& operator=(AvmMiniVerifier&& other) noexcept; - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp index df3c1148216..482261dda9f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp @@ -94,13 +94,13 @@ void ToyProver::execute_zeromorph_rounds() transcript); } -plonk::proof& ToyProver::export_proof() +honk::proof& ToyProver::export_proof() { - proof.proof_data = transcript->proof_data; + proof = transcript->proof_data; return proof; } -plonk::proof& ToyProver::construct_proof() +honk::proof& ToyProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp index 292c29f5d50..a0b0ec62cfa 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp @@ -31,8 +31,8 @@ class ToyProver { void execute_relation_check_rounds(); void execute_zeromorph_rounds(); - plonk::proof& export_proof(); - plonk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -56,7 +56,7 @@ class ToyProver { using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; private: - plonk::proof proof; + honk::proof proof; }; } // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp index f2711e8316e..f153991ed90 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp @@ -30,7 +30,7 @@ ToyVerifier& ToyVerifier::operator=(ToyVerifier&& other) noexcept * @brief This function verifies an Toy Honk proof for given program settings. * */ -bool ToyVerifier::verify_proof(const plonk::proof& proof) +bool ToyVerifier::verify_proof(const honk::proof& proof) { using Flavor = honk::flavor::ToyFlavor; using FF = Flavor::FF; @@ -42,7 +42,7 @@ bool ToyVerifier::verify_proof(const plonk::proof& proof) RelationParameters relation_parameters; - transcript = std::make_shared(proof.proof_data); + transcript = std::make_shared(proof); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp index f69e6996f70..ce84ed8ab6b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp @@ -2,7 +2,7 @@ #pragma once #include "barretenberg/flavor/generated/Toy_flavor.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" namespace bb::honk { @@ -22,7 +22,7 @@ class ToyVerifier { ToyVerifier& operator=(const ToyVerifier& other) = delete; ToyVerifier& operator=(ToyVerifier&& other) noexcept; - bool verify_proof(const plonk::proof& proof); + bool verify_proof(const honk::proof& proof); std::shared_ptr key; std::map commitments;