From 29a0d2838de4bf7aa1ea566506f4a0f97a0fb1a5 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 14 Dec 2023 20:12:27 +0000 Subject: [PATCH 01/64] added poseidon2 to native transcript --- .../src/barretenberg/transcript/transcript.hpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index e734829460c..5c40a9f8139 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -1,8 +1,9 @@ #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" // #define LOG_CHALLENGES // #define LOG_INTERACTIONS @@ -122,14 +123,11 @@ class BaseTranscript { 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)); - - // Use a strong hash function to derive the new challenge_buffer. - auto base_hash = blake3::blake3s(compressed_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. + std::vector base_hash = + to_buffer(crypto::Poseidon2::hash_buffer(full_buffer)); std::array new_challenge_buffer; std::copy_n(base_hash.begin(), HASH_OUTPUT_SIZE, new_challenge_buffer.begin()); From 61c9eca5c3b5217b61a0e9d8e80ee7976dba7d1b Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 4 Jan 2024 22:51:38 +0000 Subject: [PATCH 02/64] wip --- barretenberg/build-system | 1 + .../commitment_schemes/gemini/gemini.test.cpp | 4 +- .../commitment_schemes/ipa/ipa.hpp | 4 +- .../commitment_schemes/ipa/ipa.test.cpp | 8 +- .../commitment_schemes/kzg/kzg.hpp | 4 +- .../commitment_schemes/kzg/kzg.test.cpp | 8 +- .../shplonk/shplonk.test.cpp | 4 +- .../zeromorph/zeromorph.test.cpp | 8 +- .../crypto/poseidon2/poseidon2_params.hpp | 444 ++++++++++++++ .../poseidon2/poseidon2_permutation.hpp | 5 +- .../src/barretenberg/eccvm/eccvm_prover.cpp | 6 +- .../src/barretenberg/eccvm/eccvm_prover.hpp | 8 +- .../src/barretenberg/eccvm/eccvm_verifier.cpp | 4 +- .../src/barretenberg/eccvm/eccvm_verifier.hpp | 4 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 545 +++++++++--------- .../flavor/generated/AvmMini_flavor.hpp | 6 +- .../barretenberg/flavor/goblin_translator.hpp | 2 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 7 +- .../flavor/goblin_ultra_recursive.hpp | 1 + .../cpp/src/barretenberg/flavor/ultra.hpp | 6 +- .../barretenberg/flavor/ultra_recursive.hpp | 1 + .../cpp/src/barretenberg/goblin/goblin.hpp | 5 +- .../honk/proof_system/types/proof.hpp | 8 + .../protogalaxy/folding_result.hpp | 2 +- .../protogalaxy/protogalaxy_verifier.cpp | 4 +- .../protogalaxy/protogalaxy_verifier.hpp | 4 +- .../recursion/honk/transcript/transcript.hpp | 13 +- .../honk/transcript/transcript.test.cpp | 2 +- .../verifier/merge_recursive_verifier.cpp | 4 +- .../verifier/merge_recursive_verifier.hpp | 5 +- .../verifier/ultra_recursive_verifier.cpp | 5 +- .../verifier/ultra_recursive_verifier.hpp | 5 +- .../barretenberg/transcript/transcript.hpp | 74 +-- .../transcript/transcript.test.cpp | 2 +- .../goblin_translator_composer.hpp | 2 +- .../goblin_translator_composer.test.cpp | 60 +- .../goblin_translator_prover.cpp | 6 +- .../goblin_translator_prover.hpp | 8 +- .../goblin_translator_verifier.cpp | 7 +- .../goblin_translator_verifier.hpp | 4 +- .../barretenberg/ultra_honk/merge_prover.cpp | 6 +- .../barretenberg/ultra_honk/merge_prover.hpp | 8 +- .../ultra_honk/merge_verifier.cpp | 6 +- .../ultra_honk/merge_verifier.hpp | 4 +- .../barretenberg/ultra_honk/ultra_prover.cpp | 6 +- .../barretenberg/ultra_honk/ultra_prover.hpp | 8 +- .../ultra_honk/ultra_verifier.cpp | 4 +- .../ultra_honk/ultra_verifier.hpp | 4 +- .../vm/generated/AvmMini_prover.cpp | 7 +- .../vm/generated/AvmMini_prover.hpp | 8 +- .../vm/generated/AvmMini_verifier.cpp | 4 +- .../vm/generated/AvmMini_verifier.hpp | 4 +- 52 files changed, 925 insertions(+), 444 deletions(-) create mode 160000 barretenberg/build-system create mode 100644 barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp diff --git a/barretenberg/build-system b/barretenberg/build-system new file mode 160000 index 00000000000..a109f3aef28 --- /dev/null +++ b/barretenberg/build-system @@ -0,0 +1 @@ +Subproject commit a109f3aef28cea4a50481cdf2d74fc3909212c0b diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 1d91fe7a4e5..9ec548a773f 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -25,7 +25,7 @@ template class GeminiTest : public CommitmentTest { std::vector multilinear_commitments, std::vector multilinear_commitments_to_be_shifted) { - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); const Fr rho = Fr::random_element(); @@ -79,7 +79,7 @@ template class GeminiTest : public CommitmentTest { // Check that the Fold polynomials have been evaluated correctly in the prover this->verify_batch_opening_pair(prover_output.opening_pairs, prover_output.witnesses); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Compute: // - Single opening pair: {r, \hat{a}_0} diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp index 460f5d6dc49..1ee4bd66ca8 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp @@ -36,7 +36,7 @@ template class IPA { static void compute_opening_proof(const std::shared_ptr& ck, const OpeningPair& opening_pair, const Polynomial& polynomial, - const std::shared_ptr& transcript) + const std::shared_ptr>& transcript) { ASSERT(opening_pair.challenge != 0 && "The challenge point should not be zero"); auto poly_degree = static_cast(polynomial.size()); @@ -167,7 +167,7 @@ template class IPA { */ static bool verify(const std::shared_ptr& vk, const OpeningClaim& opening_claim, - const std::shared_ptr& transcript) + const std::shared_ptr>& transcript) { auto poly_degree = static_cast(transcript->template receive_from_prover("IPA:poly_degree")); const Fr generator_challenge = transcript->get_challenge("IPA:generator_challenge"); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index a19a7ce7aed..aa251a78aa8 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -70,11 +70,11 @@ TEST_F(IPATest, Open) const OpeningClaim opening_claim{ opening_pair, commitment }; // initialize empty prover transcript - auto prover_transcript = std::make_shared(); + auto prover_transcript = std::make_shared>(); IPA::compute_opening_proof(this->ck(), opening_pair, poly, prover_transcript); // initialize verifier transcript from proof data - auto verifier_transcript = std::make_shared(prover_transcript->proof_data); + auto verifier_transcript = std::make_shared>(prover_transcript->proof_data); auto result = IPA::verify(this->vk(), opening_claim, verifier_transcript); EXPECT_TRUE(result); @@ -129,7 +129,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) batched_commitment_unshifted = commitment1 * rhos[0] + commitment2 * rhos[1]; batched_commitment_to_be_shifted = commitment2 * rhos[2]; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); auto gemini_polynomials = GeminiProver::compute_gemini_polynomials( mle_opening_point, std::move(batched_unshifted), std::move(batched_to_be_shifted)); @@ -162,7 +162,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) IPA::compute_opening_proof(this->ck(), shplonk_opening_pair, shplonk_witness, prover_transcript); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); auto gemini_verifier_claim = GeminiVerifier::reduce_verification(mle_opening_point, batched_evaluation, diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp index 3c34333f45e..2691a361070 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp @@ -31,7 +31,7 @@ template class KZG { static void compute_opening_proof(std::shared_ptr ck, const OpeningPair& opening_pair, const Polynomial& polynomial, - const std::shared_ptr& prover_trancript) + const std::shared_ptr>& prover_trancript) { Polynomial quotient = polynomial; quotient[0] -= opening_pair.evaluation; @@ -55,7 +55,7 @@ template class KZG { */ static bool verify(const std::shared_ptr& vk, const OpeningClaim& claim, - const std::shared_ptr& verifier_transcript) + const std::shared_ptr>& verifier_transcript) { auto quotient_commitment = verifier_transcript->template receive_from_prover("KZG:W"); auto lhs = claim.commitment - (GroupElement::one() * claim.opening_pair.evaluation) + diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index c06beb07283..3b624236148 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -39,11 +39,11 @@ TYPED_TEST(KZGTest, single) auto opening_pair = OpeningPair{ challenge, evaluation }; auto opening_claim = OpeningClaim{ opening_pair, commitment }; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); KZG::compute_opening_proof(this->ck(), opening_pair, witness, prover_transcript); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); bool verified = KZG::verify(this->vk(), opening_claim, verifier_transcript); EXPECT_EQ(verified, true); @@ -109,7 +109,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) batched_commitment_unshifted = commitment1 * rhos[0] + commitment2 * rhos[1]; batched_commitment_to_be_shifted = commitment2 * rhos[2]; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Run the full prover PCS protocol: @@ -154,7 +154,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) // Run the full verifier PCS protocol with genuine opening claims (genuine commitment, genuine evaluation) - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Gemini verifier output: // - claim: d+1 commitments to Fold_{r}^(0), Fold_{-r}^(0), Fold^(l), d+1 evaluations a_0_pos, a_l, l = 0:d-1 diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp index 12232f946a8..07d8d74b2a9 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp @@ -28,7 +28,7 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) const size_t n = 16; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Generate two random (unrelated) polynomials of two different sizes, as well as their evaluations at a (single but // different) random point and their commitments. @@ -64,7 +64,7 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) opening_claims.emplace_back(OpeningClaim{ opening_pairs[0], commitment1 }); opening_claims.emplace_back(OpeningClaim{ opening_pairs[1], commitment2 }); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Execute the shplonk verifier functionality const auto verifier_claim = ShplonkVerifier::reduce_verification(this->vk(), opening_claims, verifier_transcript); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp index 11b13d9c43a..06440ea2f05 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp @@ -75,7 +75,7 @@ template class ZeroMorphTest : public CommitmentTest { } // Initialize an empty BaseTranscript - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Execute Prover protocol ZeroMorphProver::prove(f_polynomials, @@ -86,7 +86,7 @@ template class ZeroMorphTest : public CommitmentTest { this->commitment_key, prover_transcript); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Execute Verifier protocol auto pairing_points = ZeroMorphVerifier::verify( @@ -221,7 +221,7 @@ template class ZeroMorphWithConcatenationTest : public CommitmentT } // Initialize an empty BaseTranscript - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Execute Prover protocol ZeroMorphProver::prove(f_polynomials, // unshifted @@ -235,7 +235,7 @@ template class ZeroMorphWithConcatenationTest : public CommitmentT c_evaluations, to_vector_of_ref_vectors(concatenation_groups)); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Execute Verifier protocol auto pairing_points = ZeroMorphVerifier::verify(f_commitments, // unshifted diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp index 430d75f1fb6..08f8af6e8dd 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp @@ -3,6 +3,7 @@ // original source: https://github.com/HorizenLabs/poseidon2/blob/main/poseidon2_rust_params.sage #pragma once +#include "barretenberg/ecc/curves/bn254/fq.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" namespace crypto { @@ -449,4 +450,447 @@ struct Poseidon2Bn254ScalarFieldParams { FF(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")), }; }; + +struct Poseidon2GrumpkinScalarFieldParams { + + using FF = barretenberg::fq; + static constexpr size_t t = 4; + static constexpr size_t d = 5; + static constexpr size_t rounds_f = 8; + static constexpr size_t rounds_p = 56; + static constexpr size_t sbox_size = 254; + static constexpr std::array internal_matrix_diagonal = { + FF(std::string("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7")), + FF(std::string("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b")), + FF(std::string("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15")), + FF(std::string("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")), + }; + + static constexpr std::array, t> internal_matrix = { + std::array{ + FF(std::string("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e8")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + }, + std::array{ + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740c")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + }, + std::array{ + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac16")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + }, + std::array{ + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428c")), + }, + }; + + static constexpr std::array, rounds_f + rounds_p> round_constants{ + std::array{ + FF(std::string("0x19b849f69450b06848da1d39bd5e4a4302bb86744edc26238b0878e269ed23e5")), + FF(std::string("0x265ddfe127dd51bd7239347b758f0a1320eb2cc7450acc1dad47f80c8dcf34d6")), + FF(std::string("0x199750ec472f1809e0f66a545e1e51624108ac845015c2aa3dfc36bab497d8aa")), + FF(std::string("0x157ff3fe65ac7208110f06a5f74302b14d743ea25067f0ffd032f787c7f1cdf8")), + }, + std::array{ + FF(std::string("0x2e49c43c4569dd9c5fd35ac45fca33f10b15c590692f8beefe18f4896ac94902")), + FF(std::string("0x0e35fb89981890520d4aef2b6d6506c3cb2f0b6973c24fa82731345ffa2d1f1e")), + FF(std::string("0x251ad47cb15c4f1105f109ae5e944f1ba9d9e7806d667ffec6fe723002e0b996")), + FF(std::string("0x13da07dc64d428369873e97160234641f8beb56fdd05e5f3563fa39d9c22df4e")), + }, + std::array{ + FF(std::string("0x0c009b84e650e6d23dc00c7dccef7483a553939689d350cd46e7b89055fd4738")), + FF(std::string("0x011f16b1c63a854f01992e3956f42d8b04eb650c6d535eb0203dec74befdca06")), + FF(std::string("0x0ed69e5e383a688f209d9a561daa79612f3f78d0467ad45485df07093f367549")), + FF(std::string("0x04dba94a7b0ce9e221acad41472b6bbe3aec507f5eb3d33f463672264c9f789b")), + }, + std::array{ + FF(std::string("0x0a3f2637d840f3a16eb094271c9d237b6036757d4bb50bf7ce732ff1d4fa28e8")), + FF(std::string("0x259a666f129eea198f8a1c502fdb38fa39b1f075569564b6e54a485d1182323f")), + FF(std::string("0x28bf7459c9b2f4c6d8e7d06a4ee3a47f7745d4271038e5157a32fdf7ede0d6a1")), + FF(std::string("0x0a1ca941f057037526ea200f489be8d4c37c85bbcce6a2aeec91bd6941432447")), + }, + std::array{ + FF(std::string("0x0c6f8f958be0e93053d7fd4fc54512855535ed1539f051dcb43a26fd926361cf")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x123106a93cd17578d426e8128ac9d90aa9e8a00708e296e084dd57e69caaf811")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x26e1ba52ad9285d97dd3ab52f8e840085e8fa83ff1e8f1877b074867cd2dee75")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1cb55cad7bd133de18a64c5c47b9c97cbe4d8b7bf9e095864471537e6a4ae2c5")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1dcd73e46acd8f8e0e2c7ce04bde7f6d2a53043d5060a41c7143f08e6e9055d0")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x011003e32f6d9c66f5852f05474a4def0cda294a0eb4e9b9b12b9bb4512e5574")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2b1e809ac1d10ab29ad5f20d03a57dfebadfe5903f58bafed7c508dd2287ae8c")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2539de1785b735999fb4dac35ee17ed0ef995d05ab2fc5faeaa69ae87bcec0a5")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0c246c5a2ef8ee0126497f222b3e0a0ef4e1c3d41c86d46e43982cb11d77951d")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x192089c4974f68e95408148f7c0632edbb09e6a6ad1a1c2f3f0305f5d03b527b")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1eae0ad8ab68b2f06a0ee36eeb0d0c058529097d91096b756d8fdc2fb5a60d85")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x179190e5d0e22179e46f8282872abc88db6e2fdc0dee99e69768bd98c5d06bfb")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x29bb9e2c9076732576e9a81c7ac4b83214528f7db00f31bf6cafe794a9b3cd1c")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x225d394e42207599403efd0c2464a90d52652645882aac35b10e590e6e691e08")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x064760623c25c8cf753d238055b444532be13557451c087de09efd454b23fd59")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x10ba3a0e01df92e87f301c4b716d8a394d67f4bf42a75c10922910a78f6b5b87")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0e070bf53f8451b24f9c6e96b0c2a801cb511bc0c242eb9d361b77693f21471c")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1b94cd61b051b04dd39755ff93821a73ccd6cb11d2491d8aa7f921014de252fb")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1d7cb39bafb8c744e148787a2e70230f9d4e917d5713bb050487b5aa7d74070b")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2ec93189bd1ab4f69117d0fe980c80ff8785c2961829f701bb74ac1f303b17db")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2db366bfdd36d277a692bb825b86275beac404a19ae07a9082ea46bd83517926")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x062100eb485db06269655cf186a68532985275428450359adc99cec6960711b8")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0761d33c66614aaa570e7f1e8244ca1120243f92fa59e4f900c567bf41f5a59b")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x20fc411a114d13992c2705aa034e3f315d78608a0f7de4ccf7a72e494855ad0d")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x25b5c004a4bdfcb5add9ec4e9ab219ba102c67e8b3effb5fc3a30f317250bc5a")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x23b1822d278ed632a494e58f6df6f5ed038b186d8474155ad87e7dff62b37f4b")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x22734b4c5c3f9493606c4ba9012499bf0f14d13bfcfcccaa16102a29cc2f69e0")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x26c0c8fe09eb30b7e27a74dc33492347e5bdff409aa3610254413d3fad795ce5")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x070dd0ccb6bd7bbae88eac03fa1fbb26196be3083a809829bbd626df348ccad9")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x12b6595bdb329b6fb043ba78bb28c3bec2c0a6de46d8c5ad6067c4ebfd4250da")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x248d97d7f76283d63bec30e7a5876c11c06fca9b275c671c5e33d95bb7e8d729")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1a306d439d463b0816fc6fd64cc939318b45eb759ddde4aa106d15d9bd9baaaa")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x28a8f8372e3c38daced7c00421cb4621f4f1b54ddc27821b0d62d3d6ec7c56cf")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0094975717f9a8a8bb35152f24d43294071ce320c829f388bc852183e1e2ce7e")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x04d5ee4c3aa78f7d80fde60d716480d3593f74d4f653ae83f4103246db2e8d65")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2a6cf5e9aa03d4336349ad6fb8ed2269c7bef54b8822cc76d08495c12efde187")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2304d31eaab960ba9274da43e19ddeb7f792180808fd6e43baae48d7efcba3f3")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x03fd9ac865a4b2a6d5e7009785817249bff08a7e0726fcb4e1c11d39d199f0b0")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x00b7258ded52bbda2248404d55ee5044798afc3a209193073f7954d4d63b0b64")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x159f81ada0771799ec38fca2d4bf65ebb13d3a74f3298db36272c5ca65e92d9a")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1ef90e67437fbc8550237a75bc28e3bb9000130ea25f0c5471e144cf4264431f")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1e65f838515e5ff0196b49aa41a2d2568df739bc176b08ec95a79ed82932e30d")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2b1b045def3a166cec6ce768d079ba74b18c844e570e1f826575c1068c94c33f")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0832e5753ceb0ff6402543b1109229c165dc2d73bef715e3f1c6e07c168bb173")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x02f614e9cedfb3dc6b762ae0a37d41bab1b841c2e8b6451bc5a8e3c390b6ad16")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0e2427d38bd46a60dd640b8e362cad967370ebb777bedff40f6a0be27e7ed705")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0493630b7c670b6deb7c84d414e7ce79049f0ec098c3c7c50768bbe29214a53a")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x22ead100e8e482674decdab17066c5a26bb1515355d5461a3dc06cc85327cea9")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x25b3e56e655b42cdaae2626ed2554d48583f1ae35626d04de5084e0b6d2a6f16")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1e32752ada8836ef5837a6cde8ff13dbb599c336349e4c584b4fdc0a0cf6f9d0")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2fa2a871c15a387cc50f68f6f3c3455b23c00995f05078f672a9864074d412e5")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x2f569b8a9a4424c9278e1db7311e889f54ccbf10661bab7fcd18e7c7a7d83505")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x044cb455110a8fdd531ade530234c518a7df93f7332ffd2144165374b246b43d")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x227808de93906d5d420246157f2e42b191fe8c90adfe118178ddc723a5319025")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x02fcca2934e046bc623adead873579865d03781ae090ad4a8579d2e7a6800355")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x0ef915f0ac120b876abccceb344a1d36bad3f3c5ab91a8ddcbec2e060d8befac")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + }, + std::array{ + FF(std::string("0x1797130f4b7a3e1777eb757bc6f287f6ab0fb85f6be63b09f3b16ef2b1405d38")), + FF(std::string("0x0a76225dc04170ae3306c85abab59e608c7f497c20156d4d36c668555decc6e5")), + FF(std::string("0x1fffb9ec1992d66ba1e77a7b93209af6f8fa76d48acb664796174b5326a31a5c")), + FF(std::string("0x25721c4fc15a3f2853b57c338fa538d85f8fbba6c6b9c6090611889b797b9c5f")), + }, + std::array{ + FF(std::string("0x0c817fd42d5f7a41215e3d07ba197216adb4c3790705da95eb63b982bfcaf75a")), + FF(std::string("0x13abe3f5239915d39f7e13c2c24970b6df8cf86ce00a22002bc15866e52b5a96")), + FF(std::string("0x2106feea546224ea12ef7f39987a46c85c1bc3dc29bdbd7a92cd60acb4d391ce")), + FF(std::string("0x21ca859468a746b6aaa79474a37dab49f1ca5a28c748bc7157e1b3345bb0f959")), + }, + std::array{ + FF(std::string("0x05ccd6255c1e6f0c5cf1f0df934194c62911d14d0321662a8f1a48999e34185b")), + FF(std::string("0x0f0e34a64b70a626e464d846674c4c8816c4fb267fe44fe6ea28678cb09490a4")), + FF(std::string("0x0558531a4e25470c6157794ca36d0e9647dbfcfe350d64838f5b1a8a2de0d4bf")), + FF(std::string("0x09d3dca9173ed2faceea125157683d18924cadad3f655a60b72f5864961f1455")), + }, + std::array{ + FF(std::string("0x0328cbd54e8c0913493f866ed03d218bf23f92d68aaec48617d4c722e5bd4335")), + FF(std::string("0x2bf07216e2aff0a223a487b1a7094e07e79e7bcc9798c648ee3347dd5329d34b")), + FF(std::string("0x1daf345a58006b736499c583cb76c316d6f78ed6a6dffc82111e11a63fe412df")), + FF(std::string("0x176563472456aaa746b694c60e1823611ef39039b2edc7ff391e6f2293d2c404")), + }, + }; + + static constexpr std::array TEST_VECTOR_INPUT{ + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000002")), + FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000003")), + }; + static constexpr std::array TEST_VECTOR_OUTPUT{ + FF(std::string("0x01bd538c2ee014ed5141b29e9ae240bf8db3fe5b9a38629a9647cf8d76c01737")), + FF(std::string("0x239b62e7db98aa3a2a8f6a0d2fa1709e7a35959aa6c7034814d9daa90cbac662")), + FF(std::string("0x04cbb44c61d928ed06808456bf758cbf0c18d1e15a7b6dbc8245fa7515d5e3cb")), + FF(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")), + }; +}; } // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp index 4f0794b893c..734df022a24 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/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index f58b9524805..64ad309dda2 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 cc278c72daa..469ff99201b 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; }; extern template class ECCVMProver_; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 6e23963e617..f3083b3e4a8 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 3733069e2c7..5fa1ad966be 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 proof_system::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 ede2d100ce8..59d4fdcaa06 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -521,7 +521,7 @@ template class ECCVMBa * @brief Derived class that defines proof structure for ECCVM proofs, as well as supporting functions. * */ - class Transcript : public BaseTranscript { + class Transcript : public BaseTranscript { public: uint32_t circuit_size; Commitment transcript_add_comm; @@ -614,201 +614,202 @@ template class ECCVMBa Transcript() = default; - Transcript(const std::vector& proof) - : BaseTranscript(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 = - BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); + circuit_size = BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_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_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); for (size_t i = 0; i < log_n; ++i) { - sumcheck_univariates.emplace_back(BaseTranscript::template deserialize_from_buffer< + sumcheck_univariates.emplace_back(BaseTranscript::template deserialize_from_buffer< barretenberg::Univariate>( - BaseTranscript::proof_data, num_bytes_read)); + BaseTranscript::proof_data, num_bytes_read)); } - sumcheck_evaluations = BaseTranscript::template deserialize_from_buffer>( - BaseTranscript::proof_data, num_bytes_read); + sumcheck_evaluations = + BaseTranscript::template deserialize_from_buffer>( + BaseTranscript::proof_data, num_bytes_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)); + gemini_univariate_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_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)); + gemini_a_evals.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_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_bytes_read); if (std::is_same>::value) { - kzg_w_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + kzg_w_comm = BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_read); } else if (std::is_same>::value) { - ipa_poly_degree = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + ipa_poly_degree = BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_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)); - ipa_r_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read)); + ipa_l_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_read)); + ipa_r_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_read)); } - ipa_a_0_eval = - BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); + ipa_a_0_eval = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, + num_bytes_read); } else { throw_or_abort("Unsupported PCS"); } @@ -816,111 +817,121 @@ template class ECCVMBa void serialize_full_transcript() { - size_t old_proof_length = BaseTranscript::proof_data.size(); - BaseTranscript::proof_data.clear(); + size_t old_proof_length = BaseTranscript::proof_data.size(); + BaseTranscript::proof_data.clear(); size_t log_n = numeric::get_msb(circuit_size); - BaseTranscript::template serialize_to_buffer(circuit_size, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_add_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_mul_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_eq_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_collision_check_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_transition_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_pc_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_count_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_Px_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_Py_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z1zero_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z2zero_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_op_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_accumulator_x_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_accumulator_y_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_x_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_y_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_pc_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_point_transition_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_round_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_scalar_sum_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s1hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s1lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s2hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s2lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s3hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s3lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s4hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s4lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_skew_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_dx_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_dy_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_tx_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_ty_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_transition_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_double_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_skew_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_accumulator_x_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_accumulator_y_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_pc_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_size_of_msm_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_count_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_round_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_accumulator_empty_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_reset_accumulator_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_select_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(lookup_read_counts_0_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(lookup_read_counts_1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(lookup_inverses_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(z_perm_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(circuit_size, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_add_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_mul_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_eq_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_collision_check_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_transition_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_pc_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_count_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_Px_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_Py_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z1zero_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z2zero_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_op_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_accumulator_x_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_accumulator_y_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_x_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_y_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_pc_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_point_transition_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_round_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_scalar_sum_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s1hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s1lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s2hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s2lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s3hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s3lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s4hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s4lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_skew_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_dx_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_dy_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_tx_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_ty_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_transition_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_double_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_skew_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_accumulator_x_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_accumulator_y_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_pc_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_size_of_msm_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_count_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_round_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_accumulator_empty_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_reset_accumulator_comm, + BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_select_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(lookup_read_counts_0_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(lookup_read_counts_1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(lookup_inverses_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(z_perm_comm, BaseTranscript::proof_data); for (size_t i = 0; i < log_n; ++i) { - BaseTranscript::template serialize_to_buffer(sumcheck_univariates[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(sumcheck_univariates[i], + BaseTranscript::proof_data); } - BaseTranscript::template serialize_to_buffer(sumcheck_evaluations, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(sumcheck_evaluations, BaseTranscript::proof_data); for (size_t i = 0; i < log_n - 1; ++i) { - BaseTranscript::template serialize_to_buffer(gemini_univariate_comms[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(gemini_univariate_comms[i], + BaseTranscript::proof_data); } for (size_t i = 0; i < log_n; ++i) { - BaseTranscript::template serialize_to_buffer(gemini_a_evals[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(gemini_a_evals[i], BaseTranscript::proof_data); } - BaseTranscript::template serialize_to_buffer(shplonk_q_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(shplonk_q_comm, BaseTranscript::proof_data); if (std::is_same>::value) { - BaseTranscript::template serialize_to_buffer(kzg_w_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(kzg_w_comm, BaseTranscript::proof_data); } else if (std::is_same>::value) { - BaseTranscript::template serialize_to_buffer(ipa_poly_degree, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_poly_degree, BaseTranscript::proof_data); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); for (size_t i = 0; i < log_poly_degree; ++i) { - BaseTranscript::template serialize_to_buffer(ipa_l_comms[i], BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(ipa_r_comms[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_l_comms[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_r_comms[i], BaseTranscript::proof_data); } - BaseTranscript::template serialize_to_buffer(ipa_a_0_eval, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_a_0_eval, BaseTranscript::proof_data); } - ASSERT(BaseTranscript::proof_data.size() == old_proof_length); + ASSERT(BaseTranscript::proof_data.size() == old_proof_length); } }; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index e9355c1f3f9..f899393fab8 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -459,7 +459,7 @@ class AvmMiniFlavor { } }; - class Transcript : public BaseTranscript { + class Transcript : public BaseTranscript { public: uint32_t circuit_size; @@ -510,8 +510,8 @@ class AvmMiniFlavor { Transcript() = default; - Transcript(const std::vector& proof) - : BaseTranscript(proof) + Transcript(const std::vector& proof) + : BaseTranscript(proof) {} void deserialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 8d70d97653b..9b93ce6a7a5 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1136,7 +1136,7 @@ class GoblinTranslator { } }; - using Transcript = BaseTranscript; + using Transcript = BaseTranscript; }; } // namespace proof_system::honk::flavor diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 240f8f7552e..9faea29161e 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" @@ -509,7 +510,7 @@ class GoblinUltra { * @brief Derived class that defines proof structure for GoblinUltra proofs, as well as supporting functions. * Note: Made generic for use in GoblinUltraRecursive. */ - template class Transcript_ : public BaseTranscript { + template class Transcript_ : public BaseTranscript { public: uint32_t circuit_size; uint32_t public_input_size; @@ -537,8 +538,8 @@ class GoblinUltra { Transcript_() = default; - Transcript_(const std::vector& proof) - : BaseTranscript(proof) + Transcript_(const honk::proof& proof) + : BaseTranscript(proof) {} void deserialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index ee257322187..f96caf897ad 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -46,6 +46,7 @@ class GoblinUltraRecursive { using FF = Curve::ScalarField; using Commitment = Curve::Element; using CommitmentHandle = Curve::Element; + using NativeFF = typename curve::BN254::ScalarField; using NativeVerificationKey = flavor::GoblinUltra::VerificationKey; // Note(luke): Eventually this may not be needed at all diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index de77c42235d..0ba21dddc23 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -485,7 +485,7 @@ class Ultra { * @brief Derived class that defines proof structure for Ultra proofs, as well as supporting functions. * */ - class Transcript : public BaseTranscript { + class Transcript : public BaseTranscript { public: // Transcript objects defined as public member variables for easy access and modification uint32_t circuit_size; @@ -508,8 +508,8 @@ class Ultra { Transcript() = default; // Used by verifier to initialize the transcript - Transcript(const std::vector& proof) - : BaseTranscript(proof) + Transcript(const std::vector& proof) + : BaseTranscript(proof) {} static std::shared_ptr prover_init_empty() diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 19fced27b74..0d105abf214 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -54,6 +54,7 @@ template class UltraRecursive_ { using Commitment = typename Curve::Element; using CommitmentHandle = typename Curve::Element; using FF = typename Curve::ScalarField; + using NativeFF = typename curve::BN254::ScalarField; using NativeVerificationKey = flavor::Ultra::VerificationKey; // Note(luke): Eventually this may not be needed at all diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 164b29e0600..cd44a756852 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -12,7 +12,9 @@ namespace barretenberg { class Goblin { - using HonkProof = proof_system::plonk::proof; + using Fr = barretenberg::fr; + using Fq = barretenberg::fq; + using HonkProof = proof_system::honk::proof; using GUHFlavor = proof_system::honk::flavor::GoblinUltra; using GoblinUltraCircuitBuilder = proof_system::GoblinUltraCircuitBuilder; @@ -58,6 +60,7 @@ class Goblin { using GoblinUltraComposer = proof_system::honk::UltraComposer_; using GoblinUltraVerifier = proof_system::honk::UltraVerifier_; using Builder = GoblinUltraCircuitBuilder; + using Transcript = proof_system::honk::BaseTranscript; using OpQueue = proof_system::ECCOpQueue; using ECCVMFlavor = proof_system::honk::flavor::ECCVM; using ECCVMBuilder = proof_system::ECCVMCircuitBuilder; 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..7b555002a74 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp @@ -0,0 +1,8 @@ +#pragma once +#include + +namespace proof_system::honk { + +template using proof = std::vector; + +} // namespace proof_system::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp index 171f9b38a78..1338d3ed8c8 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 proof_system::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 871d4ad23b8..3b3960687e0 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -109,7 +109,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; @@ -142,7 +142,7 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec } template -bool ProtoGalaxyVerifier_::verify_folding_proof(std::vector fold_data) +bool ProtoGalaxyVerifier_::verify_folding_proof(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 b1ac218c32f..ffa64fc6660 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(std::vector); }; extern template class ProtoGalaxyVerifier_>; 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 e9943fa2a13..1e08b91d45a 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" @@ -18,17 +19,17 @@ template class Transcript { public: using field_ct = field_t; using FF = barretenberg::fr; - using BaseTranscript = proof_system::honk::BaseTranscript; + using NativeTranscript = proof_system::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 proof_system::honk::proof& proof_data) : native_transcript(proof_data) , builder(builder){}; @@ -49,7 +50,7 @@ template class Transcript { { // Compute the indicated challenges from the native transcript constexpr size_t num_challenges = sizeof...(Strings); - std::array native_challenges{}; + std::array native_challenges{}; native_challenges = native_transcript.get_challenges(labels...); /* @@ -60,7 +61,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/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index 2bea11a75da..b08d55398da 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -14,7 +14,7 @@ using Builder = UltraCircuitBuilder; using UltraFlavor = ::proof_system::honk::flavor::Ultra; using UltraRecursiveFlavor = ::proof_system::honk::flavor::UltraRecursive_; using FF = barretenberg::fr; -using BaseTranscript = ::proof_system::honk::BaseTranscript; +using BaseTranscript = ::proof_system::honk::BaseTranscript; /** * @brief Create some mock data; add it to the provided prover transcript in various mock rounds 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 78444cd519e..3cb73ca8514 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 proof_system::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 4c4c753d54d..e1d7322ed1d 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" @@ -9,6 +9,7 @@ template class MergeRecursiveVerifier_ { public: using Curve = bn254; using FF = typename Curve::ScalarField; + using NativeFF = typename curve::BN254::ScalarField; using Commitment = typename Curve::Element; using GroupElement = typename Curve::Element; using KZG = ::proof_system::honk::pcs::kzg::KZG; @@ -23,7 +24,7 @@ template class MergeRecursiveVerifier_ { explicit MergeRecursiveVerifier_(CircuitBuilder* builder); - PairingPoints verify_proof(const plonk::proof& proof); + PairingPoints verify_proof(const proof_system::honk::proof& proof); }; extern template class MergeRecursiveVerifier_; 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 fb9719d6cde..39c1e1729b5 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,8 @@ UltraRecursiveVerifier_::UltraRecursiveVerifier_( * */ template -std::array UltraRecursiveVerifier_::verify_proof(const plonk::proof& proof) +std::array UltraRecursiveVerifier_::verify_proof( + const proof_system::honk::proof& proof) { using Sumcheck = ::proof_system::honk::sumcheck::SumcheckVerifier; using Curve = typename Flavor::Curve; @@ -30,7 +31,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 6077fe241ef..4cc4a4f0c5e 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" @@ -9,6 +9,7 @@ namespace proof_system::plonk::stdlib::recursion::honk { template class UltraRecursiveVerifier_ { public: using FF = typename Flavor::FF; + using NativeFF = typename Flavor::NativeFF; using Commitment = typename Flavor::Commitment; using GroupElement = typename Flavor::GroupElement; using VerificationKey = typename Flavor::VerificationKey; @@ -28,7 +29,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 proof_system::honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 5c40a9f8139..360cf8fee64 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -4,6 +4,7 @@ #include "barretenberg/crypto/poseidon2/poseidon2.hpp" #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" +#include "barretenberg/honk/proof_system/types/proof.hpp" // #define LOG_CHALLENGES // #define LOG_INTERACTIONS @@ -60,9 +61,12 @@ class TranscriptManifest { * @brief Common transcript class for both parties. Stores the data for the current round, as well as the * manifest. */ -class BaseTranscript { +template class BaseTranscript { public: - using Proof = std::vector; + using Poseidon2Params = std::conditional_t, + crypto::Poseidon2Bn254ScalarFieldParams, + crypto::Poseidon2GrumpkinScalarFieldParams>; + using Proof = honk::proof; BaseTranscript() = default; @@ -84,8 +88,8 @@ class BaseTranscript { 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; + FF previous_challenge{}; // default-initialized to zeros + std::vector current_round_data; // "Manifest" object that records a summary of the transcript interactions TranscriptManifest manifest; @@ -94,11 +98,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]] FF get_next_challenge_buffer() { // Prevent challenge generation if this is the first challenge we're generating, // AND nothing was sent by the prover. @@ -110,10 +114,10 @@ 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; @@ -126,14 +130,13 @@ class BaseTranscript { // 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. - std::vector base_hash = - to_buffer(crypto::Poseidon2::hash_buffer(full_buffer)); + FF base_hash = crypto::Poseidon2::hash(full_buffer); - std::array new_challenge_buffer; - std::copy_n(base_hash.begin(), HASH_OUTPUT_SIZE, new_challenge_buffer.begin()); + FF new_challenge = base_hash; + // std::copy_n(base_hash.begin(), HASH_OUTPUT_SIZE, new_challenge_buffer.begin()); // 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,7 +146,7 @@ class BaseTranscript { * @param label of the element sent * @param element_bytes serialized */ - void consume_prover_element_bytes(const std::string& label, std::span element_bytes) + void consume_prover_element_bytes(const std::string& label, std::span element_bytes) { // Add an entry to the current round of the manifest manifest.add_entry(round_number, label, element_bytes.size()); @@ -196,16 +199,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::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; 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)); } @@ -219,9 +222,9 @@ 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) + template std::array get_challenges(const Strings&... labels) { constexpr size_t num_challenges = sizeof...(Strings); @@ -231,19 +234,19 @@ class BaseTranscript { // Compute the new challenge buffer from which we derive the challenges. // Create challenges from bytes. - std::array challenges{}; + std::array challenges{}; // Generate the challenges by iteratively hashing over the previous challenge. for (size_t i = 0; i < num_challenges; i++) { auto next_challenge_buffer = get_next_challenge_buffer(); // get next challenge buffer - std::array field_element_buffer{}; + FF 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); + // std::copy_n(next_challenge_buffer.begin(), + // HASH_OUTPUT_SIZE / 2, + // field_element_buffer.begin() + HASH_OUTPUT_SIZE / 2); + challenges[i] = field_element_buffer; } // Prepare for next round. @@ -267,19 +270,21 @@ class BaseTranscript { */ template void send_to_verifier(const std::string& label, const T& element) { - using serialize::write; + static_cast(label); + static_cast(element); // 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()); + // convert element to field elements + // auto element_field_elements = to_field_elements(element); + // proof_data.insert(proof_data.end(), element_field_elements.begin(), element_field_elements.end()); #ifdef LOG_INTERACTIONS if constexpr (Loggable) { info("sent: ", label, ": ", element); } #endif - BaseTranscript::consume_prover_element_bytes(label, element_bytes); + // BaseTranscript::consume_prover_element_field_elements(label, element_field_elements); } /** @@ -336,9 +341,9 @@ class BaseTranscript { return verifier_transcript; }; - uint256_t get_challenge(const std::string& label) + FF get_challenge(const std::string& label) { - uint256_t result = get_challenges(label)[0]; + FF result = get_challenges(label)[0]; #if defined LOG_CHALLENGES || defined LOG_INTERACTIONS info("challenge: ", label, ": ", result); #endif @@ -350,6 +355,7 @@ class BaseTranscript { void print() { manifest.print(); } }; +// might be useless now /** * @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 diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index 2f140e4b69a..f3a0fbd3599 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -6,7 +6,7 @@ namespace barretenberg::honk_transcript_tests { using FF = barretenberg::fr; using Fr = barretenberg::fr; using Fq = barretenberg::fq; -using Transcript = proof_system::honk::BaseTranscript; +using Transcript = proof_system::honk::BaseTranscript; /** * @brief Test sending, receiving, and exporting proofs diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp index 9734a0ba9b7..6d2d770a3e3 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -19,7 +19,7 @@ class GoblinTranslatorComposer { using CommitmentKey = typename Flavor::CommitmentKey; using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; using Polynomial = typename Flavor::Polynomial; - using Transcript = BaseTranscript; + using Transcript = BaseTranscript; static constexpr size_t MINI_CIRCUIT_SIZE = Flavor::MINI_CIRCUIT_SIZE; static constexpr std::string_view NAME_STRING = "GoblinTranslator"; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp index d186ebc6eb7..07b87fb243e 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp @@ -46,40 +46,40 @@ class GoblinTranslatorComposerTests : public ::testing::Test { * @brief Test simple circuit with public inputs * */ -TEST_F(GoblinTranslatorComposerTests, Basic) -{ - using G1 = barretenberg::g1::affine_element; - using Fr = barretenberg::fr; - using Fq = barretenberg::fq; +// TEST_F(GoblinTranslatorComposerTests, Basic) +// { +// using G1 = barretenberg::g1::affine_element; +// using Fr = barretenberg::fr; +// using Fq = barretenberg::fq; - auto P1 = G1::random_element(); - auto P2 = G1::random_element(); - auto z = Fr::random_element(); +// auto P1 = G1::random_element(); +// auto P2 = G1::random_element(); +// auto z = Fr::random_element(); - // Add the same operations to the ECC op queue; the native computation is performed under the hood. - auto op_queue = std::make_shared(); - for (size_t i = 0; i < 500; i++) { - op_queue->add_accumulate(P1); - op_queue->mul_accumulate(P2, z); - } +// // Add the same operations to the ECC op queue; the native computation is performed under the hood. +// auto op_queue = std::make_shared(); +// for (size_t i = 0; i < 500; i++) { +// op_queue->add_accumulate(P1); +// op_queue->mul_accumulate(P2, z); +// } - auto prover_transcript = std::make_shared(); - prover_transcript->send_to_verifier("init", Fq::random_element()); - prover_transcript->export_proof(); - Fq translation_batching_challenge = prover_transcript->get_challenge("Translation:batching_challenge"); - Fq translation_evaluation_challenge = Fq::random_element(); - auto circuit_builder = CircuitBuilder(translation_batching_challenge, translation_evaluation_challenge, op_queue); - EXPECT_TRUE(circuit_builder.check_circuit()); +// auto prover_transcript = std::make_shared(); +// prover_transcript->send_to_verifier("init", Fq::random_element()); +// prover_transcript->export_proof(); +// Fq translation_batching_challenge = prover_transcript->get_challenge("Translation:batching_challenge"); +// Fq translation_evaluation_challenge = Fq::random_element(); +// auto circuit_builder = CircuitBuilder(translation_batching_challenge, translation_evaluation_challenge, +// op_queue); EXPECT_TRUE(circuit_builder.check_circuit()); - auto composer = GoblinTranslatorComposer(); - auto prover = composer.create_prover(circuit_builder, prover_transcript); - auto proof = prover.construct_proof(); +// auto composer = GoblinTranslatorComposer(); +// auto prover = composer.create_prover(circuit_builder, prover_transcript); +// auto proof = prover.construct_proof(); - auto verifier_transcript = std::make_shared(prover_transcript->proof_data); - verifier_transcript->template receive_from_prover("init"); - auto verifier = composer.create_verifier(circuit_builder, verifier_transcript); - bool verified = verifier.verify_proof(proof); - EXPECT_TRUE(verified); -} +// auto verifier_transcript = std::make_shared(prover_transcript->proof_data); +// verifier_transcript->template receive_from_prover("init"); +// auto verifier = composer.create_verifier(circuit_builder, verifier_transcript); +// bool verified = verifier.verify_proof(proof); +// EXPECT_TRUE(verified); +// } } // namespace test_goblin_translator_composer 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 00a4e291e8e..ca5d65a02ba 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 4aa8299272b..fbbae7e1e59 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" @@ -35,8 +35,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(); @@ -54,7 +54,7 @@ class GoblinTranslatorProver { sumcheck::SumcheckOutput sumcheck_output; private: - plonk::proof proof; + honk::proof proof; }; } // namespace proof_system::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 d6797c62a1b..6bbd90581c8 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,11 @@ 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); + // batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); + batching_challenge_v = 0; + 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 e959eef720e..c70bb96c43f 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 proof_system::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 proof_system::honk diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index 671634a3073..28c940ae6ca 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 c0f823d88b7..dbca7590c3d 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" @@ -23,7 +23,7 @@ template class MergeProver_ { using Curve = typename Flavor::Curve; using OpeningClaim = typename pcs::ProverOpeningClaim; using OpeningPair = typename pcs::OpeningPair; - using Transcript = BaseTranscript; + using Transcript = BaseTranscript; public: std::shared_ptr transcript; @@ -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; }; extern template class MergeProver_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index ebf18518afa..7e7aed87585 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 da094df6b7e..e20664cc300 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); }; extern template class MergeVerifier_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 44b95ce6bf4..78be8d97a17 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 2ba793fa0bc..1b89f7d3678 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; }; extern template class UltraProver_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 637806709e8..96e0712334f 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 proof_system::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 8e6c02d0b68..d6c3682e81e 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/generated/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index a4931f5cf90..3655d2f3d02 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 proof_system::honk { using Flavor = honk::flavor::AvmMiniFlavor; +using FF = Flavor::FF; /** * Create AvmMiniProver from proving key, witness and manifest. @@ -97,13 +98,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() +proof_system::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 4a08b1fb8fa..385dd28e6da 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 proof_system::honk diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 157e4a8bc0d..b73a31a270d 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 55f30477f6e..ae7a9f3269d 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 proof_system::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; From a8204fb90e4a8abbdb8efc5c30f4e09ee1697350 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Wed, 10 Jan 2024 19:56:37 +0000 Subject: [PATCH 03/64] removed grumpkin poseidon2 params --- .../crypto/poseidon2/poseidon2_params.hpp | 443 ------------------ 1 file changed, 443 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp index 08f8af6e8dd..6931fea92ba 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp @@ -450,447 +450,4 @@ struct Poseidon2Bn254ScalarFieldParams { FF(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")), }; }; - -struct Poseidon2GrumpkinScalarFieldParams { - - using FF = barretenberg::fq; - static constexpr size_t t = 4; - static constexpr size_t d = 5; - static constexpr size_t rounds_f = 8; - static constexpr size_t rounds_p = 56; - static constexpr size_t sbox_size = 254; - static constexpr std::array internal_matrix_diagonal = { - FF(std::string("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7")), - FF(std::string("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b")), - FF(std::string("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15")), - FF(std::string("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")), - }; - - static constexpr std::array, t> internal_matrix = { - std::array{ - FF(std::string("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e8")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - }, - std::array{ - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740c")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - }, - std::array{ - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac16")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - }, - std::array{ - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428c")), - }, - }; - - static constexpr std::array, rounds_f + rounds_p> round_constants{ - std::array{ - FF(std::string("0x19b849f69450b06848da1d39bd5e4a4302bb86744edc26238b0878e269ed23e5")), - FF(std::string("0x265ddfe127dd51bd7239347b758f0a1320eb2cc7450acc1dad47f80c8dcf34d6")), - FF(std::string("0x199750ec472f1809e0f66a545e1e51624108ac845015c2aa3dfc36bab497d8aa")), - FF(std::string("0x157ff3fe65ac7208110f06a5f74302b14d743ea25067f0ffd032f787c7f1cdf8")), - }, - std::array{ - FF(std::string("0x2e49c43c4569dd9c5fd35ac45fca33f10b15c590692f8beefe18f4896ac94902")), - FF(std::string("0x0e35fb89981890520d4aef2b6d6506c3cb2f0b6973c24fa82731345ffa2d1f1e")), - FF(std::string("0x251ad47cb15c4f1105f109ae5e944f1ba9d9e7806d667ffec6fe723002e0b996")), - FF(std::string("0x13da07dc64d428369873e97160234641f8beb56fdd05e5f3563fa39d9c22df4e")), - }, - std::array{ - FF(std::string("0x0c009b84e650e6d23dc00c7dccef7483a553939689d350cd46e7b89055fd4738")), - FF(std::string("0x011f16b1c63a854f01992e3956f42d8b04eb650c6d535eb0203dec74befdca06")), - FF(std::string("0x0ed69e5e383a688f209d9a561daa79612f3f78d0467ad45485df07093f367549")), - FF(std::string("0x04dba94a7b0ce9e221acad41472b6bbe3aec507f5eb3d33f463672264c9f789b")), - }, - std::array{ - FF(std::string("0x0a3f2637d840f3a16eb094271c9d237b6036757d4bb50bf7ce732ff1d4fa28e8")), - FF(std::string("0x259a666f129eea198f8a1c502fdb38fa39b1f075569564b6e54a485d1182323f")), - FF(std::string("0x28bf7459c9b2f4c6d8e7d06a4ee3a47f7745d4271038e5157a32fdf7ede0d6a1")), - FF(std::string("0x0a1ca941f057037526ea200f489be8d4c37c85bbcce6a2aeec91bd6941432447")), - }, - std::array{ - FF(std::string("0x0c6f8f958be0e93053d7fd4fc54512855535ed1539f051dcb43a26fd926361cf")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x123106a93cd17578d426e8128ac9d90aa9e8a00708e296e084dd57e69caaf811")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x26e1ba52ad9285d97dd3ab52f8e840085e8fa83ff1e8f1877b074867cd2dee75")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1cb55cad7bd133de18a64c5c47b9c97cbe4d8b7bf9e095864471537e6a4ae2c5")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1dcd73e46acd8f8e0e2c7ce04bde7f6d2a53043d5060a41c7143f08e6e9055d0")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x011003e32f6d9c66f5852f05474a4def0cda294a0eb4e9b9b12b9bb4512e5574")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2b1e809ac1d10ab29ad5f20d03a57dfebadfe5903f58bafed7c508dd2287ae8c")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2539de1785b735999fb4dac35ee17ed0ef995d05ab2fc5faeaa69ae87bcec0a5")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0c246c5a2ef8ee0126497f222b3e0a0ef4e1c3d41c86d46e43982cb11d77951d")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x192089c4974f68e95408148f7c0632edbb09e6a6ad1a1c2f3f0305f5d03b527b")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1eae0ad8ab68b2f06a0ee36eeb0d0c058529097d91096b756d8fdc2fb5a60d85")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x179190e5d0e22179e46f8282872abc88db6e2fdc0dee99e69768bd98c5d06bfb")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x29bb9e2c9076732576e9a81c7ac4b83214528f7db00f31bf6cafe794a9b3cd1c")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x225d394e42207599403efd0c2464a90d52652645882aac35b10e590e6e691e08")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x064760623c25c8cf753d238055b444532be13557451c087de09efd454b23fd59")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x10ba3a0e01df92e87f301c4b716d8a394d67f4bf42a75c10922910a78f6b5b87")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0e070bf53f8451b24f9c6e96b0c2a801cb511bc0c242eb9d361b77693f21471c")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1b94cd61b051b04dd39755ff93821a73ccd6cb11d2491d8aa7f921014de252fb")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1d7cb39bafb8c744e148787a2e70230f9d4e917d5713bb050487b5aa7d74070b")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2ec93189bd1ab4f69117d0fe980c80ff8785c2961829f701bb74ac1f303b17db")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2db366bfdd36d277a692bb825b86275beac404a19ae07a9082ea46bd83517926")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x062100eb485db06269655cf186a68532985275428450359adc99cec6960711b8")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0761d33c66614aaa570e7f1e8244ca1120243f92fa59e4f900c567bf41f5a59b")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x20fc411a114d13992c2705aa034e3f315d78608a0f7de4ccf7a72e494855ad0d")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x25b5c004a4bdfcb5add9ec4e9ab219ba102c67e8b3effb5fc3a30f317250bc5a")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x23b1822d278ed632a494e58f6df6f5ed038b186d8474155ad87e7dff62b37f4b")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x22734b4c5c3f9493606c4ba9012499bf0f14d13bfcfcccaa16102a29cc2f69e0")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x26c0c8fe09eb30b7e27a74dc33492347e5bdff409aa3610254413d3fad795ce5")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x070dd0ccb6bd7bbae88eac03fa1fbb26196be3083a809829bbd626df348ccad9")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x12b6595bdb329b6fb043ba78bb28c3bec2c0a6de46d8c5ad6067c4ebfd4250da")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x248d97d7f76283d63bec30e7a5876c11c06fca9b275c671c5e33d95bb7e8d729")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1a306d439d463b0816fc6fd64cc939318b45eb759ddde4aa106d15d9bd9baaaa")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x28a8f8372e3c38daced7c00421cb4621f4f1b54ddc27821b0d62d3d6ec7c56cf")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0094975717f9a8a8bb35152f24d43294071ce320c829f388bc852183e1e2ce7e")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x04d5ee4c3aa78f7d80fde60d716480d3593f74d4f653ae83f4103246db2e8d65")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2a6cf5e9aa03d4336349ad6fb8ed2269c7bef54b8822cc76d08495c12efde187")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2304d31eaab960ba9274da43e19ddeb7f792180808fd6e43baae48d7efcba3f3")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x03fd9ac865a4b2a6d5e7009785817249bff08a7e0726fcb4e1c11d39d199f0b0")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x00b7258ded52bbda2248404d55ee5044798afc3a209193073f7954d4d63b0b64")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x159f81ada0771799ec38fca2d4bf65ebb13d3a74f3298db36272c5ca65e92d9a")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1ef90e67437fbc8550237a75bc28e3bb9000130ea25f0c5471e144cf4264431f")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1e65f838515e5ff0196b49aa41a2d2568df739bc176b08ec95a79ed82932e30d")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2b1b045def3a166cec6ce768d079ba74b18c844e570e1f826575c1068c94c33f")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0832e5753ceb0ff6402543b1109229c165dc2d73bef715e3f1c6e07c168bb173")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x02f614e9cedfb3dc6b762ae0a37d41bab1b841c2e8b6451bc5a8e3c390b6ad16")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0e2427d38bd46a60dd640b8e362cad967370ebb777bedff40f6a0be27e7ed705")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0493630b7c670b6deb7c84d414e7ce79049f0ec098c3c7c50768bbe29214a53a")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x22ead100e8e482674decdab17066c5a26bb1515355d5461a3dc06cc85327cea9")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x25b3e56e655b42cdaae2626ed2554d48583f1ae35626d04de5084e0b6d2a6f16")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1e32752ada8836ef5837a6cde8ff13dbb599c336349e4c584b4fdc0a0cf6f9d0")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2fa2a871c15a387cc50f68f6f3c3455b23c00995f05078f672a9864074d412e5")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x2f569b8a9a4424c9278e1db7311e889f54ccbf10661bab7fcd18e7c7a7d83505")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x044cb455110a8fdd531ade530234c518a7df93f7332ffd2144165374b246b43d")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x227808de93906d5d420246157f2e42b191fe8c90adfe118178ddc723a5319025")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x02fcca2934e046bc623adead873579865d03781ae090ad4a8579d2e7a6800355")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x0ef915f0ac120b876abccceb344a1d36bad3f3c5ab91a8ddcbec2e060d8befac")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - }, - std::array{ - FF(std::string("0x1797130f4b7a3e1777eb757bc6f287f6ab0fb85f6be63b09f3b16ef2b1405d38")), - FF(std::string("0x0a76225dc04170ae3306c85abab59e608c7f497c20156d4d36c668555decc6e5")), - FF(std::string("0x1fffb9ec1992d66ba1e77a7b93209af6f8fa76d48acb664796174b5326a31a5c")), - FF(std::string("0x25721c4fc15a3f2853b57c338fa538d85f8fbba6c6b9c6090611889b797b9c5f")), - }, - std::array{ - FF(std::string("0x0c817fd42d5f7a41215e3d07ba197216adb4c3790705da95eb63b982bfcaf75a")), - FF(std::string("0x13abe3f5239915d39f7e13c2c24970b6df8cf86ce00a22002bc15866e52b5a96")), - FF(std::string("0x2106feea546224ea12ef7f39987a46c85c1bc3dc29bdbd7a92cd60acb4d391ce")), - FF(std::string("0x21ca859468a746b6aaa79474a37dab49f1ca5a28c748bc7157e1b3345bb0f959")), - }, - std::array{ - FF(std::string("0x05ccd6255c1e6f0c5cf1f0df934194c62911d14d0321662a8f1a48999e34185b")), - FF(std::string("0x0f0e34a64b70a626e464d846674c4c8816c4fb267fe44fe6ea28678cb09490a4")), - FF(std::string("0x0558531a4e25470c6157794ca36d0e9647dbfcfe350d64838f5b1a8a2de0d4bf")), - FF(std::string("0x09d3dca9173ed2faceea125157683d18924cadad3f655a60b72f5864961f1455")), - }, - std::array{ - FF(std::string("0x0328cbd54e8c0913493f866ed03d218bf23f92d68aaec48617d4c722e5bd4335")), - FF(std::string("0x2bf07216e2aff0a223a487b1a7094e07e79e7bcc9798c648ee3347dd5329d34b")), - FF(std::string("0x1daf345a58006b736499c583cb76c316d6f78ed6a6dffc82111e11a63fe412df")), - FF(std::string("0x176563472456aaa746b694c60e1823611ef39039b2edc7ff391e6f2293d2c404")), - }, - }; - - static constexpr std::array TEST_VECTOR_INPUT{ - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000000")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000001")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000002")), - FF(std::string("0x0000000000000000000000000000000000000000000000000000000000000003")), - }; - static constexpr std::array TEST_VECTOR_OUTPUT{ - FF(std::string("0x01bd538c2ee014ed5141b29e9ae240bf8db3fe5b9a38629a9647cf8d76c01737")), - FF(std::string("0x239b62e7db98aa3a2a8f6a0d2fa1709e7a35959aa6c7034814d9daa90cbac662")), - FF(std::string("0x04cbb44c61d928ed06808456bf758cbf0c18d1e15a7b6dbc8245fa7515d5e3cb")), - FF(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")), - }; -}; } // namespace crypto From 05085c5383f585fd6871490848c17fd325d61400 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Wed, 10 Jan 2024 19:57:11 +0000 Subject: [PATCH 04/64] removed transcript template param, shoudl only be barretenberg::fr for now --- .../commitment_schemes/gemini/gemini.test.cpp | 4 +- .../commitment_schemes/ipa/ipa.hpp | 4 +- .../commitment_schemes/ipa/ipa.test.cpp | 8 +- .../commitment_schemes/kzg/kzg.hpp | 4 +- .../commitment_schemes/kzg/kzg.test.cpp | 8 +- .../shplonk/shplonk.test.cpp | 4 +- .../zeromorph/zeromorph.test.cpp | 8 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 543 +++++++++--------- .../flavor/generated/AvmMini_flavor.hpp | 4 +- .../barretenberg/flavor/goblin_translator.hpp | 2 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 4 +- .../cpp/src/barretenberg/flavor/ultra.hpp | 4 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 2 +- .../recursion/honk/transcript/transcript.hpp | 2 +- .../honk/transcript/transcript.test.cpp | 2 +- .../barretenberg/transcript/transcript.hpp | 3 +- .../transcript/transcript.test.cpp | 2 +- .../barretenberg/ultra_honk/merge_prover.hpp | 2 +- 18 files changed, 300 insertions(+), 310 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 9ec548a773f..1d91fe7a4e5 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -25,7 +25,7 @@ template class GeminiTest : public CommitmentTest { std::vector multilinear_commitments, std::vector multilinear_commitments_to_be_shifted) { - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); const Fr rho = Fr::random_element(); @@ -79,7 +79,7 @@ template class GeminiTest : public CommitmentTest { // Check that the Fold polynomials have been evaluated correctly in the prover this->verify_batch_opening_pair(prover_output.opening_pairs, prover_output.witnesses); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Compute: // - Single opening pair: {r, \hat{a}_0} diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp index 1ee4bd66ca8..460f5d6dc49 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp @@ -36,7 +36,7 @@ template class IPA { static void compute_opening_proof(const std::shared_ptr& ck, const OpeningPair& opening_pair, const Polynomial& polynomial, - const std::shared_ptr>& transcript) + const std::shared_ptr& transcript) { ASSERT(opening_pair.challenge != 0 && "The challenge point should not be zero"); auto poly_degree = static_cast(polynomial.size()); @@ -167,7 +167,7 @@ template class IPA { */ static bool verify(const std::shared_ptr& vk, const OpeningClaim& opening_claim, - const std::shared_ptr>& transcript) + const std::shared_ptr& transcript) { auto poly_degree = static_cast(transcript->template receive_from_prover("IPA:poly_degree")); const Fr generator_challenge = transcript->get_challenge("IPA:generator_challenge"); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index aa251a78aa8..a19a7ce7aed 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -70,11 +70,11 @@ TEST_F(IPATest, Open) const OpeningClaim opening_claim{ opening_pair, commitment }; // initialize empty prover transcript - auto prover_transcript = std::make_shared>(); + auto prover_transcript = std::make_shared(); IPA::compute_opening_proof(this->ck(), opening_pair, poly, prover_transcript); // initialize verifier transcript from proof data - auto verifier_transcript = std::make_shared>(prover_transcript->proof_data); + auto verifier_transcript = std::make_shared(prover_transcript->proof_data); auto result = IPA::verify(this->vk(), opening_claim, verifier_transcript); EXPECT_TRUE(result); @@ -129,7 +129,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) batched_commitment_unshifted = commitment1 * rhos[0] + commitment2 * rhos[1]; batched_commitment_to_be_shifted = commitment2 * rhos[2]; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); auto gemini_polynomials = GeminiProver::compute_gemini_polynomials( mle_opening_point, std::move(batched_unshifted), std::move(batched_to_be_shifted)); @@ -162,7 +162,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) IPA::compute_opening_proof(this->ck(), shplonk_opening_pair, shplonk_witness, prover_transcript); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); auto gemini_verifier_claim = GeminiVerifier::reduce_verification(mle_opening_point, batched_evaluation, diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp index 2691a361070..3c34333f45e 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp @@ -31,7 +31,7 @@ template class KZG { static void compute_opening_proof(std::shared_ptr ck, const OpeningPair& opening_pair, const Polynomial& polynomial, - const std::shared_ptr>& prover_trancript) + const std::shared_ptr& prover_trancript) { Polynomial quotient = polynomial; quotient[0] -= opening_pair.evaluation; @@ -55,7 +55,7 @@ template class KZG { */ static bool verify(const std::shared_ptr& vk, const OpeningClaim& claim, - const std::shared_ptr>& verifier_transcript) + const std::shared_ptr& verifier_transcript) { auto quotient_commitment = verifier_transcript->template receive_from_prover("KZG:W"); auto lhs = claim.commitment - (GroupElement::one() * claim.opening_pair.evaluation) + diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index 3b624236148..c06beb07283 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -39,11 +39,11 @@ TYPED_TEST(KZGTest, single) auto opening_pair = OpeningPair{ challenge, evaluation }; auto opening_claim = OpeningClaim{ opening_pair, commitment }; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); KZG::compute_opening_proof(this->ck(), opening_pair, witness, prover_transcript); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); bool verified = KZG::verify(this->vk(), opening_claim, verifier_transcript); EXPECT_EQ(verified, true); @@ -109,7 +109,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) batched_commitment_unshifted = commitment1 * rhos[0] + commitment2 * rhos[1]; batched_commitment_to_be_shifted = commitment2 * rhos[2]; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Run the full prover PCS protocol: @@ -154,7 +154,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) // Run the full verifier PCS protocol with genuine opening claims (genuine commitment, genuine evaluation) - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Gemini verifier output: // - claim: d+1 commitments to Fold_{r}^(0), Fold_{-r}^(0), Fold^(l), d+1 evaluations a_0_pos, a_l, l = 0:d-1 diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp index 07d8d74b2a9..12232f946a8 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp @@ -28,7 +28,7 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) const size_t n = 16; - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Generate two random (unrelated) polynomials of two different sizes, as well as their evaluations at a (single but // different) random point and their commitments. @@ -64,7 +64,7 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) opening_claims.emplace_back(OpeningClaim{ opening_pairs[0], commitment1 }); opening_claims.emplace_back(OpeningClaim{ opening_pairs[1], commitment2 }); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Execute the shplonk verifier functionality const auto verifier_claim = ShplonkVerifier::reduce_verification(this->vk(), opening_claims, verifier_transcript); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp index 06440ea2f05..11b13d9c43a 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp @@ -75,7 +75,7 @@ template class ZeroMorphTest : public CommitmentTest { } // Initialize an empty BaseTranscript - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Execute Prover protocol ZeroMorphProver::prove(f_polynomials, @@ -86,7 +86,7 @@ template class ZeroMorphTest : public CommitmentTest { this->commitment_key, prover_transcript); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Execute Verifier protocol auto pairing_points = ZeroMorphVerifier::verify( @@ -221,7 +221,7 @@ template class ZeroMorphWithConcatenationTest : public CommitmentT } // Initialize an empty BaseTranscript - auto prover_transcript = BaseTranscript::prover_init_empty(); + auto prover_transcript = BaseTranscript::prover_init_empty(); // Execute Prover protocol ZeroMorphProver::prove(f_polynomials, // unshifted @@ -235,7 +235,7 @@ template class ZeroMorphWithConcatenationTest : public CommitmentT c_evaluations, to_vector_of_ref_vectors(concatenation_groups)); - auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); + auto verifier_transcript = BaseTranscript::verifier_init_empty(prover_transcript); // Execute Verifier protocol auto pairing_points = ZeroMorphVerifier::verify(f_commitments, // unshifted diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 59d4fdcaa06..1bab712347f 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -521,7 +521,7 @@ template class ECCVMBa * @brief Derived class that defines proof structure for ECCVM proofs, as well as supporting functions. * */ - class Transcript : public BaseTranscript { + class Transcript : public BaseTranscript { public: uint32_t circuit_size; Commitment transcript_add_comm; @@ -615,201 +615,200 @@ template class ECCVMBa Transcript() = default; Transcript(const honk::proof& proof) - : BaseTranscript(proof) + : BaseTranscript(proof) {} void deserialize_full_transcript() { // take current proof and put them into the struct size_t num_bytes_read = 0; - circuit_size = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); + circuit_size = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_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_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); for (size_t i = 0; i < log_n; ++i) { - sumcheck_univariates.emplace_back(BaseTranscript::template deserialize_from_buffer< + sumcheck_univariates.emplace_back(BaseTranscript::template deserialize_from_buffer< barretenberg::Univariate>( - BaseTranscript::proof_data, num_bytes_read)); + BaseTranscript::proof_data, num_bytes_read)); } - sumcheck_evaluations = - BaseTranscript::template deserialize_from_buffer>( - BaseTranscript::proof_data, num_bytes_read); + sumcheck_evaluations = BaseTranscript::template deserialize_from_buffer>( + BaseTranscript::proof_data, num_bytes_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)); + gemini_univariate_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_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)); + gemini_a_evals.emplace_back( + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_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_bytes_read); if (std::is_same>::value) { - kzg_w_comm = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); + kzg_w_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, + num_bytes_read); } else if (std::is_same>::value) { - ipa_poly_degree = BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read); + ipa_poly_degree = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, + num_bytes_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)); - ipa_r_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( - BaseTranscript::proof_data, num_bytes_read)); + ipa_l_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_read)); + ipa_r_comms.emplace_back(BaseTranscript::template deserialize_from_buffer( + BaseTranscript::proof_data, num_bytes_read)); } - ipa_a_0_eval = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, - num_bytes_read); + ipa_a_0_eval = + BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); } else { throw_or_abort("Unsupported PCS"); } @@ -817,121 +816,111 @@ template class ECCVMBa void serialize_full_transcript() { - size_t old_proof_length = BaseTranscript::proof_data.size(); - BaseTranscript::proof_data.clear(); + size_t old_proof_length = BaseTranscript::proof_data.size(); + BaseTranscript::proof_data.clear(); size_t log_n = numeric::get_msb(circuit_size); - BaseTranscript::template serialize_to_buffer(circuit_size, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_add_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_mul_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_eq_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_collision_check_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_transition_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_pc_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_count_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_Px_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_Py_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z1zero_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_z2zero_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_op_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_accumulator_x_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_accumulator_y_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_x_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_msm_y_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_pc_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_point_transition_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_round_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_scalar_sum_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s1hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s1lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s2hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s2lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s3hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s3lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s4hi_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_s4lo_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_skew_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_dx_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_dy_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_tx_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_ty_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_transition_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_double_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_skew_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_accumulator_x_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_accumulator_y_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_pc_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_size_of_msm_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_count_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_round_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_add4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_x4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_y4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_collision_x4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_lambda4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice2_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice3_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(msm_slice4_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_accumulator_empty_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(transcript_reset_accumulator_comm, - BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(precompute_select_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(lookup_read_counts_0_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(lookup_read_counts_1_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(lookup_inverses_comm, BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(z_perm_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(circuit_size, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_add_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_mul_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_eq_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_collision_check_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_transition_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_pc_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_count_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_Px_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_Py_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z1zero_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_z2zero_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_op_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_accumulator_x_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_accumulator_y_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_x_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_msm_y_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_pc_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_point_transition_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_round_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_scalar_sum_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s1hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s1lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s2hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s2lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s3hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s3lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s4hi_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_s4lo_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_skew_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_dx_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_dy_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_tx_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_ty_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_transition_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_double_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_skew_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_accumulator_x_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_accumulator_y_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_pc_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_size_of_msm_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_count_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_round_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_add4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_x4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_y4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_collision_x4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_lambda4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice2_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice3_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(msm_slice4_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_accumulator_empty_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(transcript_reset_accumulator_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(precompute_select_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(lookup_read_counts_0_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(lookup_read_counts_1_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(lookup_inverses_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(z_perm_comm, BaseTranscript::proof_data); for (size_t i = 0; i < log_n; ++i) { - BaseTranscript::template serialize_to_buffer(sumcheck_univariates[i], - BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(sumcheck_univariates[i], BaseTranscript::proof_data); } - BaseTranscript::template serialize_to_buffer(sumcheck_evaluations, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(sumcheck_evaluations, BaseTranscript::proof_data); for (size_t i = 0; i < log_n - 1; ++i) { - BaseTranscript::template serialize_to_buffer(gemini_univariate_comms[i], - BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(gemini_univariate_comms[i], BaseTranscript::proof_data); } for (size_t i = 0; i < log_n; ++i) { - BaseTranscript::template serialize_to_buffer(gemini_a_evals[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(gemini_a_evals[i], BaseTranscript::proof_data); } - BaseTranscript::template serialize_to_buffer(shplonk_q_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(shplonk_q_comm, BaseTranscript::proof_data); if (std::is_same>::value) { - BaseTranscript::template serialize_to_buffer(kzg_w_comm, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(kzg_w_comm, BaseTranscript::proof_data); } else if (std::is_same>::value) { - BaseTranscript::template serialize_to_buffer(ipa_poly_degree, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_poly_degree, BaseTranscript::proof_data); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); for (size_t i = 0; i < log_poly_degree; ++i) { - BaseTranscript::template serialize_to_buffer(ipa_l_comms[i], BaseTranscript::proof_data); - BaseTranscript::template serialize_to_buffer(ipa_r_comms[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_l_comms[i], BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_r_comms[i], BaseTranscript::proof_data); } - BaseTranscript::template serialize_to_buffer(ipa_a_0_eval, BaseTranscript::proof_data); + BaseTranscript::template serialize_to_buffer(ipa_a_0_eval, BaseTranscript::proof_data); } - ASSERT(BaseTranscript::proof_data.size() == old_proof_length); + ASSERT(BaseTranscript::proof_data.size() == old_proof_length); } }; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index f899393fab8..58042edcec2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -459,7 +459,7 @@ class AvmMiniFlavor { } }; - class Transcript : public BaseTranscript { + class Transcript : public BaseTranscript { public: uint32_t circuit_size; @@ -511,7 +511,7 @@ class AvmMiniFlavor { Transcript() = default; Transcript(const std::vector& proof) - : BaseTranscript(proof) + : BaseTranscript(proof) {} void deserialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 9b93ce6a7a5..8d70d97653b 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1136,7 +1136,7 @@ class GoblinTranslator { } }; - using Transcript = BaseTranscript; + using Transcript = BaseTranscript; }; } // namespace proof_system::honk::flavor diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 9faea29161e..bcc7f167388 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -510,7 +510,7 @@ class GoblinUltra { * @brief Derived class that defines proof structure for GoblinUltra proofs, as well as supporting functions. * Note: Made generic for use in GoblinUltraRecursive. */ - template class Transcript_ : public BaseTranscript { + template class Transcript_ : public BaseTranscript { public: uint32_t circuit_size; uint32_t public_input_size; @@ -539,7 +539,7 @@ class GoblinUltra { Transcript_() = default; Transcript_(const honk::proof& proof) - : BaseTranscript(proof) + : BaseTranscript(proof) {} void deserialize_full_transcript() diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 0ba21dddc23..36ffe64d549 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -485,7 +485,7 @@ class Ultra { * @brief Derived class that defines proof structure for Ultra proofs, as well as supporting functions. * */ - class Transcript : public BaseTranscript { + class Transcript : public BaseTranscript { public: // Transcript objects defined as public member variables for easy access and modification uint32_t circuit_size; @@ -509,7 +509,7 @@ class Ultra { // Used by verifier to initialize the transcript Transcript(const std::vector& proof) - : BaseTranscript(proof) + : BaseTranscript(proof) {} static std::shared_ptr prover_init_empty() diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index cd44a756852..211ba6c83cb 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -60,7 +60,7 @@ class Goblin { using GoblinUltraComposer = proof_system::honk::UltraComposer_; using GoblinUltraVerifier = proof_system::honk::UltraVerifier_; using Builder = GoblinUltraCircuitBuilder; - using Transcript = proof_system::honk::BaseTranscript; + using Transcript = proof_system::honk::BaseTranscript; using OpQueue = proof_system::ECCOpQueue; using ECCVMFlavor = proof_system::honk::flavor::ECCVM; using ECCVMBuilder = proof_system::ECCVMCircuitBuilder; 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 1e08b91d45a..5aef1122d82 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp @@ -19,7 +19,7 @@ template class Transcript { public: using field_ct = field_t; using FF = barretenberg::fr; - using NativeTranscript = proof_system::honk::BaseTranscript; + using NativeTranscript = proof_system::honk::BaseTranscript; using StdlibTypes = utility::StdlibTypesUtility; static constexpr size_t HASH_OUTPUT_SIZE = NativeTranscript::HASH_OUTPUT_SIZE; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index b08d55398da..2bea11a75da 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -14,7 +14,7 @@ using Builder = UltraCircuitBuilder; using UltraFlavor = ::proof_system::honk::flavor::Ultra; using UltraRecursiveFlavor = ::proof_system::honk::flavor::UltraRecursive_; using FF = barretenberg::fr; -using BaseTranscript = ::proof_system::honk::BaseTranscript; +using BaseTranscript = ::proof_system::honk::BaseTranscript; /** * @brief Create some mock data; add it to the provided prover transcript in various mock rounds diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 360cf8fee64..8dfb2917a3b 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -61,8 +61,9 @@ class TranscriptManifest { * @brief Common transcript class for both parties. Stores the data for the current round, as well as the * manifest. */ -template class BaseTranscript { +class BaseTranscript { public: + using FF = barretenberg::fr; using Poseidon2Params = std::conditional_t, crypto::Poseidon2Bn254ScalarFieldParams, crypto::Poseidon2GrumpkinScalarFieldParams>; diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index f3a0fbd3599..2f140e4b69a 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -6,7 +6,7 @@ namespace barretenberg::honk_transcript_tests { using FF = barretenberg::fr; using Fr = barretenberg::fr; using Fq = barretenberg::fq; -using Transcript = proof_system::honk::BaseTranscript; +using Transcript = proof_system::honk::BaseTranscript; /** * @brief Test sending, receiving, and exporting proofs diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp index dbca7590c3d..fdc1e5df7a2 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp @@ -23,7 +23,7 @@ template class MergeProver_ { using Curve = typename Flavor::Curve; using OpeningClaim = typename pcs::ProverOpeningClaim; using OpeningPair = typename pcs::OpeningPair; - using Transcript = BaseTranscript; + using Transcript = BaseTranscript; public: std::shared_ptr transcript; From 99bd01dabf6e3d5e5025ef100355d47f8765d38d Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Wed, 10 Jan 2024 23:48:27 +0000 Subject: [PATCH 05/64] removing poseidon2 grumpkin updated challenges to be uint256_t for now --- .../crypto/poseidon2/poseidon2_params.hpp | 1 - .../cpp/src/barretenberg/goblin/goblin.hpp | 35 +++++++++---------- .../recursion/honk/transcript/transcript.hpp | 4 +-- .../barretenberg/transcript/transcript.hpp | 16 ++++----- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp index 6931fea92ba..430d75f1fb6 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp @@ -3,7 +3,6 @@ // original source: https://github.com/HorizenLabs/poseidon2/blob/main/poseidon2_rust_params.sage #pragma once -#include "barretenberg/ecc/curves/bn254/fq.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" namespace crypto { diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 211ba6c83cb..fbb85f2880d 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -12,9 +12,6 @@ namespace barretenberg { class Goblin { - using Fr = barretenberg::fr; - using Fq = barretenberg::fq; - using HonkProof = proof_system::honk::proof; using GUHFlavor = proof_system::honk::flavor::GoblinUltra; using GoblinUltraCircuitBuilder = proof_system::GoblinUltraCircuitBuilder; @@ -24,6 +21,23 @@ class Goblin { using FF = GUHFlavor::FF; public: + using GoblinUltraComposer = proof_system::honk::UltraComposer_; + using GoblinUltraVerifier = proof_system::honk::UltraVerifier_; + using Builder = GoblinUltraCircuitBuilder; + using Fr = barretenberg::fr; + using HonkProof = proof_system::honk::proof; + using Transcript = proof_system::honk::BaseTranscript; + using OpQueue = proof_system::ECCOpQueue; + using ECCVMFlavor = proof_system::honk::flavor::ECCVM; + using ECCVMBuilder = proof_system::ECCVMCircuitBuilder; + using ECCVMComposer = proof_system::honk::ECCVMComposer; + using ECCVMProver = proof_system::honk::ECCVMProver_; + using TranslatorBuilder = proof_system::GoblinTranslatorCircuitBuilder; + using TranslatorComposer = proof_system::honk::GoblinTranslatorComposer; + using RecursiveMergeVerifier = + proof_system::plonk::stdlib::recursion::goblin::MergeRecursiveVerifier_; + using MergeVerifier = proof_system::honk::MergeVerifier_; + /** * @brief Output of goblin::accumulate; an Ultra proof and the corresponding verification key * @@ -57,21 +71,6 @@ class Goblin { } }; - using GoblinUltraComposer = proof_system::honk::UltraComposer_; - using GoblinUltraVerifier = proof_system::honk::UltraVerifier_; - using Builder = GoblinUltraCircuitBuilder; - using Transcript = proof_system::honk::BaseTranscript; - using OpQueue = proof_system::ECCOpQueue; - using ECCVMFlavor = proof_system::honk::flavor::ECCVM; - using ECCVMBuilder = proof_system::ECCVMCircuitBuilder; - using ECCVMComposer = proof_system::honk::ECCVMComposer; - using ECCVMProver = proof_system::honk::ECCVMProver_; - using TranslatorBuilder = proof_system::GoblinTranslatorCircuitBuilder; - using TranslatorComposer = proof_system::honk::GoblinTranslatorComposer; - using RecursiveMergeVerifier = - proof_system::plonk::stdlib::recursion::goblin::MergeRecursiveVerifier_; - using MergeVerifier = proof_system::honk::MergeVerifier_; - std::shared_ptr op_queue = std::make_shared(); HonkProof merge_proof; 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 5aef1122d82..9753d900ce6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp @@ -29,7 +29,7 @@ template class Transcript { Transcript() = default; - Transcript(Builder* builder, const proof_system::honk::proof& proof_data) + Transcript(Builder* builder, const proof_system::honk::proof& proof_data) : native_transcript(proof_data) , builder(builder){}; @@ -50,7 +50,7 @@ template class Transcript { { // Compute the indicated challenges from the native transcript constexpr size_t num_challenges = sizeof...(Strings); - std::array native_challenges{}; + std::array native_challenges{}; native_challenges = native_transcript.get_challenges(labels...); /* diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 8dfb2917a3b..f186c67522c 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -64,10 +64,8 @@ class TranscriptManifest { class BaseTranscript { public: using FF = barretenberg::fr; - using Poseidon2Params = std::conditional_t, - crypto::Poseidon2Bn254ScalarFieldParams, - crypto::Poseidon2GrumpkinScalarFieldParams>; - using Proof = honk::proof; + using Poseidon2Params = crypto::Poseidon2Bn254ScalarFieldParams; + using Proof = honk::proof; BaseTranscript() = default; @@ -225,7 +223,7 @@ class BaseTranscript { * @param labels human-readable names for the challenges for the manifest * @return std::array challenges for this round. */ - template std::array get_challenges(const Strings&... labels) + template std::array get_challenges(const Strings&... labels) { constexpr size_t num_challenges = sizeof...(Strings); @@ -235,7 +233,7 @@ class BaseTranscript { // Compute the new challenge buffer from which we derive the challenges. // Create challenges from bytes. - std::array challenges{}; + std::array challenges{}; // Generate the challenges by iteratively hashing over the previous challenge. for (size_t i = 0; i < num_challenges; i++) { @@ -247,7 +245,7 @@ class BaseTranscript { // std::copy_n(next_challenge_buffer.begin(), // HASH_OUTPUT_SIZE / 2, // field_element_buffer.begin() + HASH_OUTPUT_SIZE / 2); - challenges[i] = field_element_buffer; + challenges[i] = uint256_t(field_element_buffer); } // Prepare for next round. @@ -342,9 +340,9 @@ class BaseTranscript { return verifier_transcript; }; - FF get_challenge(const std::string& label) + uint256_t get_challenge(const std::string& label) { - FF result = get_challenges(label)[0]; + uint256_t result = get_challenges(label)[0]; #if defined LOG_CHALLENGES || defined LOG_INTERACTIONS info("challenge: ", label, ": ", result); #endif From 029350cd0f3f1478d6324523a7885b21251c5050 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Wed, 10 Jan 2024 23:48:42 +0000 Subject: [PATCH 06/64] removed template param from honk::proof --- barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp | 4 ++-- barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp | 6 +++--- barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp | 2 +- barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp | 2 +- barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp | 2 +- barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp | 2 +- .../cpp/src/barretenberg/honk/proof_system/types/proof.hpp | 3 ++- .../recursion/honk/verifier/merge_recursive_verifier.cpp | 2 +- .../recursion/honk/verifier/merge_recursive_verifier.hpp | 2 +- .../recursion/honk/verifier/ultra_recursive_verifier.cpp | 2 +- .../recursion/honk/verifier/ultra_recursive_verifier.hpp | 2 +- .../translator_vm/goblin_translator_composer.hpp | 2 +- .../barretenberg/translator_vm/goblin_translator_prover.cpp | 4 ++-- .../barretenberg/translator_vm/goblin_translator_prover.hpp | 6 +++--- .../translator_vm/goblin_translator_verifier.cpp | 2 +- .../translator_vm/goblin_translator_verifier.hpp | 2 +- .../cpp/src/barretenberg/ultra_honk/merge_prover.cpp | 4 ++-- .../cpp/src/barretenberg/ultra_honk/merge_prover.hpp | 4 ++-- .../cpp/src/barretenberg/ultra_honk/merge_verifier.cpp | 4 ++-- .../cpp/src/barretenberg/ultra_honk/merge_verifier.hpp | 2 +- .../cpp/src/barretenberg/ultra_honk/ultra_prover.cpp | 4 ++-- .../cpp/src/barretenberg/ultra_honk/ultra_prover.hpp | 6 +++--- .../cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp | 2 +- .../cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp | 2 +- .../cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp | 4 ++-- .../cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp | 6 +++--- .../cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp | 2 +- .../cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp | 2 +- 28 files changed, 44 insertions(+), 43 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index 64ad309dda2..e0ee089b6e6 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 honk::proof& ECCVMProver_::export_proof() +template honk::proof& ECCVMProver_::export_proof() { proof = transcript->export_proof(); return proof; } -template honk::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 469ff99201b..4df3b700d2b 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp @@ -42,8 +42,8 @@ template class ECCVMProver_ { BBERG_PROFILE void execute_final_pcs_round(); BBERG_PROFILE void execute_transcript_consistency_univariate_opening_round(); - honk::proof& export_proof(); - honk::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: - honk::proof proof; + honk::proof proof; }; extern template class ECCVMProver_; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index f3083b3e4a8..b2436316161 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 honk::proof& proof) +template bool ECCVMVerifier_::verify_proof(const honk::proof& proof) { using FF = typename Flavor::FF; using GroupElement = typename Flavor::GroupElement; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp index 5fa1ad966be..db46b967f6f 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp @@ -30,7 +30,7 @@ template class ECCVMVerifier_ { ECCVMVerifier_& operator=(ECCVMVerifier_&& other) noexcept; ~ECCVMVerifier_() = default; - bool verify_proof(const honk::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 1bab712347f..167b64be4da 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -614,7 +614,7 @@ template class ECCVMBa Transcript() = default; - Transcript(const honk::proof& proof) + Transcript(const honk::proof& proof) : BaseTranscript(proof) {} diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index bcc7f167388..be39d7e9b14 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -538,7 +538,7 @@ class GoblinUltra { Transcript_() = default; - Transcript_(const honk::proof& proof) + Transcript_(const honk::proof& proof) : BaseTranscript(proof) {} diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp index 7b555002a74..ee6fb50ad21 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp @@ -1,8 +1,9 @@ #pragma once +#include "barretenberg/ecc/curves/bn254/fr.hpp" #include namespace proof_system::honk { -template using proof = std::vector; +using proof = std::vector; } // namespace proof_system::honk \ No newline at end of file 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 3cb73ca8514..5bb9319a746 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,7 +16,7 @@ MergeRecursiveVerifier_::MergeRecursiveVerifier_(CircuitBuilder* */ template std::array::Element, 2> MergeRecursiveVerifier_::verify_proof( - const proof_system::honk::proof& proof) + const proof_system::honk::proof& proof) { transcript = std::make_shared(builder, proof); 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 e1d7322ed1d..4c2a1b614c4 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 @@ -24,7 +24,7 @@ template class MergeRecursiveVerifier_ { explicit MergeRecursiveVerifier_(CircuitBuilder* builder); - PairingPoints verify_proof(const proof_system::honk::proof& proof); + PairingPoints verify_proof(const proof_system::honk::proof& proof); }; extern template class MergeRecursiveVerifier_; 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 39c1e1729b5..597f33f32c8 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 @@ -19,7 +19,7 @@ UltraRecursiveVerifier_::UltraRecursiveVerifier_( */ template std::array UltraRecursiveVerifier_::verify_proof( - const proof_system::honk::proof& proof) + const proof_system::honk::proof& proof) { using Sumcheck = ::proof_system::honk::sumcheck::SumcheckVerifier; using Curve = typename Flavor::Curve; 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 4cc4a4f0c5e..03e6fe391af 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 @@ -29,7 +29,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 proof_system::honk::proof& proof); + PairingPoints verify_proof(const proof_system::honk::proof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp index 6d2d770a3e3..9734a0ba9b7 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -19,7 +19,7 @@ class GoblinTranslatorComposer { using CommitmentKey = typename Flavor::CommitmentKey; using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; using Polynomial = typename Flavor::Polynomial; - using Transcript = BaseTranscript; + using Transcript = BaseTranscript; static constexpr size_t MINI_CIRCUIT_SIZE = Flavor::MINI_CIRCUIT_SIZE; static constexpr std::string_view NAME_STRING = "GoblinTranslator"; 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 ca5d65a02ba..619b5838d36 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()); } -honk::proof& GoblinTranslatorProver::export_proof() +honk::proof& GoblinTranslatorProver::export_proof() { proof = transcript->export_proof(); return proof; } -honk::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 fbbae7e1e59..8510213c6d6 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp @@ -35,8 +35,8 @@ class GoblinTranslatorProver { BBERG_PROFILE void execute_grand_product_computation_round(); BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + honk::proof& export_proof(); + honk::proof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -54,7 +54,7 @@ class GoblinTranslatorProver { sumcheck::SumcheckOutput sumcheck_output; private: - honk::proof proof; + honk::proof proof; }; } // namespace proof_system::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 6bbd90581c8..f8bfdafd32e 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -65,7 +65,7 @@ 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 honk::proof& proof) +bool GoblinTranslatorVerifier::verify_proof(const honk::proof& proof) { // batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); batching_challenge_v = 0; 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 c70bb96c43f..342e91bf74a 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp @@ -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 honk::proof& proof); + bool verify_proof(const honk::proof& proof); bool verify_translation(const TranslationEvaluations& translation_evaluations); }; } // namespace proof_system::honk diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index 28c940ae6ca..94dd3b6a942 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 honk::proof& + * @return honk::proof& */ -template honk::proof& MergeProver_::construct_proof() +template honk::proof& MergeProver_::construct_proof() { size_t N = op_queue->get_current_size(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp index fdc1e5df7a2..1d4b9426ef6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.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 honk::proof& construct_proof(); + BBERG_PROFILE honk::proof& construct_proof(); private: - honk::proof proof; + honk::proof proof; }; extern template class MergeProver_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index 7e7aed87585..4743dfc6789 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -16,9 +16,9 @@ MergeVerifier_::MergeVerifier_() * queue has been constructed correctly via a simple Schwartz-Zippel check. Evaluations are checked via batched KZG. * * @tparam Flavor - * @return honk::proof& + * @return honk::proof& */ -template bool MergeVerifier_::verify_proof(const honk::proof& proof) +template bool MergeVerifier_::verify_proof(const honk::proof& proof) { transcript = std::make_shared(proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp index e20664cc300..a16200c0f34 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp @@ -33,7 +33,7 @@ template class MergeVerifier_ { std::shared_ptr pcs_verification_key; explicit MergeVerifier_(); - bool verify_proof(const honk::proof& proof); + bool verify_proof(const honk::proof& proof); }; extern template class MergeVerifier_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 78be8d97a17..6edc9aef642 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 honk::proof& UltraProver_::export_proof() +template honk::proof& UltraProver_::export_proof() { proof = transcript->proof_data; return proof; } -template honk::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 1b89f7d3678..90d417d0d13 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -35,8 +35,8 @@ template class UltraProver_ { BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::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: - honk::proof proof; + honk::proof proof; }; extern template class UltraProver_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 96e0712334f..923ff55f1da 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 honk::proof& proof) +template bool UltraVerifier_::verify_proof(const honk::proof& proof) { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index d6c3682e81e..646ee96267b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -24,7 +24,7 @@ template class UltraVerifier_ { UltraVerifier_& operator=(const UltraVerifier_& other) = delete; UltraVerifier_& operator=(UltraVerifier_&& other); - bool verify_proof(const honk::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/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index 3655d2f3d02..96f7c34c0e1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp @@ -98,13 +98,13 @@ void AvmMiniProver::execute_zeromorph_rounds() transcript); } -honk::proof& AvmMiniProver::export_proof() +honk::proof& AvmMiniProver::export_proof() { proof = transcript->proof_data; return proof; } -proof_system::honk::proof& AvmMiniProver::construct_proof() +proof_system::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 385dd28e6da..eac3368b574 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp @@ -31,8 +31,8 @@ class AvmMiniProver { void execute_relation_check_rounds(); void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::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: - honk::proof proof; + honk::proof proof; }; } // namespace proof_system::honk diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index b73a31a270d..58265bc6cba 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 honk::proof& proof) +bool AvmMiniVerifier::verify_proof(const honk::proof& proof) { using Flavor = honk::flavor::AvmMiniFlavor; using FF = Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp index ae7a9f3269d..c8ae4263c50 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp @@ -22,7 +22,7 @@ class AvmMiniVerifier { AvmMiniVerifier& operator=(const AvmMiniVerifier& other) = delete; AvmMiniVerifier& operator=(AvmMiniVerifier&& other) noexcept; - bool verify_proof(const honk::proof& proof); + bool verify_proof(const honk::proof& proof); std::shared_ptr key; std::map commitments; From a045b6d5999c06ffbfed111ead13abb14d18baad Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Sun, 14 Jan 2024 02:18:31 +0000 Subject: [PATCH 07/64] linker error be gone among other merge errors --- barretenberg/cpp/src/CMakeLists.txt | 2 ++ .../cpp/src/barretenberg/barretenberg.hpp | 2 ++ .../dsl/acir_proofs/acir_composer.cpp | 4 +-- .../dsl/acir_proofs/acir_composer.hpp | 4 +-- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 2 +- .../flavor/generated/Toy_flavor.hpp | 2 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 30 ++++++++-------- .../protogalaxy/decider_prover.cpp | 6 ++-- .../protogalaxy/decider_prover.hpp | 8 ++--- .../protogalaxy/decider_verifier.cpp | 4 +-- .../protogalaxy/decider_verifier.hpp | 4 +-- .../stdlib/recursion/CMakeLists.txt | 2 +- .../barretenberg/transcript/CMakeLists.txt | 2 +- .../barretenberg/transcript/transcript.hpp | 34 +++++++++---------- .../barretenberg/vm/generated/Toy_prover.cpp | 6 ++-- .../barretenberg/vm/generated/Toy_prover.hpp | 6 ++-- .../vm/generated/Toy_verifier.cpp | 4 +-- .../vm/generated/Toy_verifier.hpp | 4 +-- 18 files changed, 65 insertions(+), 61 deletions(-) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 352a7d1cafe..f3d42d53637 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -107,6 +107,7 @@ set(BARRETENBERG_TARGET_OBJECTS $ $ $ + $ $ $ $ @@ -130,6 +131,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/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index 5eb044f1491..fdb358ee5cb 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -105,7 +105,7 @@ void AcirComposer::create_goblin_circuit(acir_format::acir_format& constraint_sy GoblinMockCircuits::construct_goblin_ecc_op_circuit(goblin_builder_); } -std::vector AcirComposer::create_goblin_proof() +std::vector AcirComposer::create_goblin_proof() { return goblin.construct_proof(goblin_builder_); } @@ -160,7 +160,7 @@ bool AcirComposer::verify_proof(std::vector const& proof, bool is_recur } } -bool AcirComposer::verify_goblin_proof(std::vector const& proof) +bool AcirComposer::verify_goblin_proof(std::vector const& proof) { return goblin.verify_proof({ proof }); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp index 4cdf9d92fdc..6edf055dcb4 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp @@ -41,8 +41,8 @@ class AcirComposer { // Goblin specific methods void create_goblin_circuit(acir_format::acir_format& constraint_system, acir_format::WitnessVector& witness); - std::vector create_goblin_proof(); - bool verify_goblin_proof(std::vector const& proof); + std::vector create_goblin_proof(); + bool verify_goblin_proof(std::vector const& proof); private: acir_format::Builder builder_; 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 7301f3d673e..1399ed8b2d0 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -100,7 +100,7 @@ WASM_EXPORT void acir_get_proving_key(in_ptr acir_composer_ptr, uint8_t const* a WASM_EXPORT void acir_verify_goblin_proof(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 = from_buffer>(proof_buf); *result = acir_composer->verify_goblin_proof(proof); } diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index fdb992586b7..9f367ee7cd0 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -286,7 +286,7 @@ class ToyFlavor { Transcript() = default; - Transcript(const std::vector& proof) + Transcript(const std::vector& proof) : BaseTranscript(proof) {} diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index fbb85f2880d..fd28ffb988a 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -52,20 +52,20 @@ 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; } @@ -237,28 +237,28 @@ class Goblin { }; // ACIRHACK - std::vector construct_proof(GoblinUltraCircuitBuilder& builder) + std::vector construct_proof(GoblinUltraCircuitBuilder& builder) { // Construct a GUH proof accumulate_for_acir(builder); - std::vector result(accumulator.proof.proof_data.size()); + std::vector result(accumulator.proof.size()); - const auto insert = [&result](const std::vector& buf) { + const auto insert = [&result](const std::vector& buf) { result.insert(result.end(), buf.begin(), buf.end()); }; - insert(accumulator.proof.proof_data); + insert(accumulator.proof); // TODO(https://github.com/AztecProtocol/barretenberg/issues/819): Skip ECCVM/Translator proof for now - // std::vector goblin_proof = prove_for_acir().to_buffer(); + // std::vector goblin_proof = prove_for_acir().to_buffer(); // insert(goblin_proof); return result; } // ACIRHACK - bool verify_proof([[maybe_unused]] const proof_system::plonk::proof& proof) const + bool verify_proof([[maybe_unused]] const proof_system::honk::proof& proof) const { // ACIRHACK: to do this properly, extract the proof correctly or maybe share transcripts. const auto extract_final_kernel_proof = [&]([[maybe_unused]] auto& input_proof) { return accumulator.proof; }; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp index eea53966aa6..abea81d8354 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 b11af2419a6..2bca584014b 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; }; extern template class DeciderProver_; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 8b533659270..1fed4821fde 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 eb2e15a5ce0..2a84344a9cd 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/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/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 f186c67522c..abdf3ab44c1 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -63,7 +63,7 @@ class TranscriptManifest { */ class BaseTranscript { public: - using FF = barretenberg::fr; + using Fr = barretenberg::fr; using Poseidon2Params = crypto::Poseidon2Bn254ScalarFieldParams; using Proof = honk::proof; @@ -87,8 +87,8 @@ class BaseTranscript { 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 - FF previous_challenge{}; // 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; @@ -99,9 +99,9 @@ class BaseTranscript { * 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 * to the current challenge buffer to set up next function call. - * @return std::array + * @return std::array */ - [[nodiscard]] FF 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. @@ -113,7 +113,7 @@ 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 full_buffer.emplace_back(previous_challenge); @@ -129,9 +129,9 @@ class BaseTranscript { // 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. - FF base_hash = crypto::Poseidon2::hash(full_buffer); + Fr base_hash = crypto::Poseidon2::hash(full_buffer); - FF new_challenge = base_hash; + Fr new_challenge = base_hash; // std::copy_n(base_hash.begin(), HASH_OUTPUT_SIZE, new_challenge_buffer.begin()); // update previous challenge buffer for next time we call this function previous_challenge = new_challenge; @@ -145,7 +145,7 @@ class BaseTranscript { * @param label of the element sent * @param element_bytes serialized */ - void consume_prover_element_bytes(const std::string& label, std::span element_bytes) + void consume_prover_element_bytes(const std::string& label, std::span element_bytes) { // Add an entry to the current round of the manifest manifest.add_entry(round_number, label, element_bytes.size()); @@ -198,16 +198,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::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; 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 +221,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) { @@ -238,7 +238,7 @@ class BaseTranscript { // Generate the challenges by iteratively hashing over the previous challenge. for (size_t i = 0; i < num_challenges; i++) { auto next_challenge_buffer = get_next_challenge_buffer(); // get next challenge buffer - FF field_element_buffer = next_challenge_buffer; + 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 @@ -357,12 +357,12 @@ class BaseTranscript { // might be useless now /** * @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/vm/generated/Toy_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp index 9a210d2c7ed..ce4b2a5df10 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp @@ -95,13 +95,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 bfd4db05ba6..1f01487fb80 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 proof_system::honk diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp index 6fac55b463c..fbd14f59067 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 30b5e78e5c8..9e57877d921 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 proof_system::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; From 86065bcca048e10e210783ac53181e31c3ecee66 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 16 Jan 2024 23:14:40 +0000 Subject: [PATCH 08/64] conversions --- .../cpp/src/barretenberg/ecc/CMakeLists.txt | 1 + .../ecc/fields/field_conversion_utils.hpp | 215 ++++++++++++++++++ .../barretenberg/transcript/transcript.hpp | 44 ++-- .../transcript/transcript.test.cpp | 4 +- 4 files changed, 240 insertions(+), 24 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp diff --git a/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt index 35e543283ee..09d95d02c88 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/ecc/CMakeLists.txt @@ -14,6 +14,7 @@ target_precompile_headers( $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/asm_macros.hpp"> $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/field_declarations.hpp"> $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/field_impl.hpp"> + $<$:"${CMAKE_CURRENT_SOURCE_DIR}/fields/field_conversion_utils.hpp"> $<$:"${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"> diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp new file mode 100644 index 00000000000..87e6fc66858 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp @@ -0,0 +1,215 @@ +#pragma once + +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" + +#include "barretenberg/plonk/proof_system/constants.hpp" + +namespace barretenberg { +// convert bn254::frs to grumpkin::fr + +static constexpr uint64_t NUM_CONVERSION_LIMB_BITS = 64; + +template constexpr size_t calc_num_frs() +{ + if constexpr (std::is_same_v) { + return 2; + } else if constexpr (std::is_same_v) { + return 1; + } else if constexpr (std::is_same_v) { + return 1; + } else if constexpr (std::is_same_v) { + return 1; + } else { + return 0; + } +} + +std::array inline convert_to_bn254_fr(const grumpkin::fr& val) +{ + return convert_grumpkin_fr_to_barretenberg_frs(val); +} + +template constexpr barretenberg::fr convert_to_bn254_fr(T val) +{ + if constexpr (std::is_same_v) { + return val; + } else if constexpr (std::is_same_v) { + return val; + } else { + return val; + } +} + +std::array inline decompose_bn254_fr_to_two_limbs(const barretenberg::fr& field_val) +{ + ASSERT(field_val < (uint256_t(1) << (2 * NUM_CONVERSION_LIMB_BITS))); // should be 128 bits, technically 127 or less + // split bn254_fr into two 64 bit limbs + constexpr uint256_t LIMB_MASK = (uint256_t(1) << NUM_CONVERSION_LIMB_BITS) - 1; + const uint256_t value = field_val; + const uint64_t low = static_cast(value & LIMB_MASK); + const uint64_t hi = static_cast(value >> NUM_CONVERSION_LIMB_BITS); + ASSERT(static_cast(low) + (static_cast(hi) << NUM_CONVERSION_LIMB_BITS) == value); + + // const size_t lo_bits = NUM_CONVERSION_LIMB_BITS; + // const size_t hi_bits = num_limb_bits - NUM_CONVERSION_LIMB_BITS; + // range_constrain_two_ limbs(low_idx, hi_idx, lo_bits, hi_bits); needed in stdlib version of this + + return std::array{ low, hi }; +} + +// template +// std::array UltraCircuitBuilder_::decompose_non_native_field_double_width_limb( +// const uint32_t limb_idx, const size_t num_limb_bits) +// { +// ASSERT(uint256_t(this->get_variable_reference(limb_idx)) < (uint256_t(1) << num_limb_bits)); +// constexpr FF LIMB_MASK = (uint256_t(1) << DEFAULT_NON_NATIVE_FIELD_LIMB_BITS) - 1; +// const uint256_t value = this->get_variable(limb_idx); +// const uint256_t low = value & LIMB_MASK; +// const uint256_t hi = value >> DEFAULT_NON_NATIVE_FIELD_LIMB_BITS; +// ASSERT(low + (hi << DEFAULT_NON_NATIVE_FIELD_LIMB_BITS) == value); + +// const uint32_t low_idx = this->add_variable(low); +// const uint32_t hi_idx = this->add_variable(hi); + +// ASSERT(num_limb_bits > DEFAULT_NON_NATIVE_FIELD_LIMB_BITS); +// const size_t lo_bits = DEFAULT_NON_NATIVE_FIELD_LIMB_BITS; +// const size_t hi_bits = num_limb_bits - DEFAULT_NON_NATIVE_FIELD_LIMB_BITS; +// range_constrain_two_limbs(low_idx, hi_idx, lo_bits, hi_bits); + +// return std::array{ low_idx, hi_idx }; +// } + +// convert barretenberg::frs to grumpkin::fr +grumpkin::fr inline convert_barretenberg_fr_to_grumpkin_fr(const barretenberg::fr& low_bits_in, + const barretenberg::fr& high_bits_in) +{ + // TODO: figure out can_overflow, maximum_bitlength + ASSERT(uint256_t(low_bits_in) < (uint256_t(1) << (NUM_CONVERSION_LIMB_BITS * 2))); + ASSERT(uint256_t(high_bits_in) < (uint256_t(1) << (NUM_CONVERSION_LIMB_BITS * 2))); + auto low_bit_decomp = decompose_bn254_fr_to_two_limbs(low_bits_in); + uint256_t tmp; + tmp.data[0] = low_bit_decomp[0]; + tmp.data[1] = low_bit_decomp[1]; + auto high_bit_decomp = decompose_bn254_fr_to_two_limbs(high_bits_in); + tmp.data[2] = high_bit_decomp[0]; + tmp.data[3] = high_bit_decomp[1]; + grumpkin::fr result(tmp); + return result; +} + +// convert grumpkin::fr to barretenberg::frs +std::array inline convert_grumpkin_fr_to_barretenberg_frs(const grumpkin::fr& input) +{ + auto tmp = static_cast(input); + std::array result; + result[0] = static_cast(tmp.data[0]) + (static_cast(tmp.data[1]) << NUM_CONVERSION_LIMB_BITS); + result[1] = static_cast(tmp.data[2]) + (static_cast(tmp.data[3]) << NUM_CONVERSION_LIMB_BITS); + return result; +} + +// template +// bigfield::bigfield(const field_t& low_bits_in, +// const field_t& high_bits_in, +// const bool can_overflow, +// const size_t maximum_bitlength) +// { +// ASSERT((can_overflow == true && maximum_bitlength == 0) || +// (can_overflow == false && (maximum_bitlength == 0 || maximum_bitlength > (3 * NUM_LIMB_BITS)))); + +// // Check that the values of two parts are within specified bounds +// ASSERT(uint256_t(low_bits_in.get_value()) < (uint256_t(1) << (NUM_LIMB_BITS * 2))); +// ASSERT(uint256_t(high_bits_in.get_value()) < (uint256_t(1) << (NUM_LIMB_BITS * 2))); + +// context = low_bits_in.context == nullptr ? high_bits_in.context : low_bits_in.context; +// field_t limb_0(context); +// field_t limb_1(context); +// field_t limb_2(context); +// field_t limb_3(context); +// if (low_bits_in.witness_index != IS_CONSTANT) { +// std::vector low_accumulator; +// if constexpr (HasPlookup) { +// // MERGE NOTE: this was the if constexpr block introduced in ecebe7643 +// const auto limb_witnesses = +// context->decompose_non_native_field_double_width_limb(low_bits_in.normalize().witness_index); +// limb_0.witness_index = limb_witnesses[0]; +// limb_1.witness_index = limb_witnesses[1]; +// field_t::evaluate_linear_identity(low_bits_in, -limb_0, -limb_1 * shift_1, field_t(0)); + +// // // Enforce that low_bits_in indeed only contains 2*NUM_LIMB_BITS bits +// // low_accumulator = context->decompose_into_default_range(low_bits_in.witness_index, +// // static_cast(NUM_LIMB_BITS * 2)); +// // // If this doesn't hold we're using a default plookup range size that doesn't work well with the limb +// // size +// // // here +// // ASSERT(low_accumulator.size() % 2 == 0); +// // size_t mid_index = low_accumulator.size() / 2 - 1; +// // limb_0.witness_index = low_accumulator[mid_index]; // Q:safer to just slice this from low_bits_in? +// // limb_1 = (low_bits_in - limb_0) * shift_right_1; +// } else { +// size_t mid_index; +// low_accumulator = context->decompose_into_base4_accumulators( +// low_bits_in.witness_index, static_cast(NUM_LIMB_BITS * 2), "bigfield: low_bits_in too +// large."); +// mid_index = static_cast((NUM_LIMB_BITS / 2) - 1); +// // Range constraint returns an array of partial sums, midpoint will happen to hold the big limb value +// limb_1.witness_index = low_accumulator[mid_index]; +// // We can get the first half bits of low_bits_in from the variables we already created +// limb_0 = (low_bits_in - (limb_1 * shift_1)); +// } +// } else { +// uint256_t slice_0 = uint256_t(low_bits_in.additive_constant).slice(0, NUM_LIMB_BITS); +// uint256_t slice_1 = uint256_t(low_bits_in.additive_constant).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); +// limb_0 = field_t(context, barretenberg::fr(slice_0)); +// limb_1 = field_t(context, barretenberg::fr(slice_1)); +// } + +// // If we wish to continue working with this element with lazy reductions - i.e. not moding out again after each +// // addition we apply a more limited range - 2^s for smallest s such that p<2^s (this is the case can_overflow == +// // false) +// uint64_t num_last_limb_bits = (can_overflow) ? NUM_LIMB_BITS : NUM_LAST_LIMB_BITS; + +// // if maximum_bitlength is set, this supercedes can_overflow +// if (maximum_bitlength > 0) { +// ASSERT(maximum_bitlength > 3 * NUM_LIMB_BITS); +// num_last_limb_bits = maximum_bitlength - (3 * NUM_LIMB_BITS); +// } +// // We create the high limb values similar to the low limb ones above +// const uint64_t num_high_limb_bits = NUM_LIMB_BITS + num_last_limb_bits; +// if (high_bits_in.witness_index != IS_CONSTANT) { + +// std::vector high_accumulator; +// if constexpr (HasPlookup) { +// const auto limb_witnesses = context->decompose_non_native_field_double_width_limb( +// high_bits_in.normalize().witness_index, (size_t)num_high_limb_bits); +// limb_2.witness_index = limb_witnesses[0]; +// limb_3.witness_index = limb_witnesses[1]; +// field_t::evaluate_linear_identity(high_bits_in, -limb_2, -limb_3 * shift_1, +// field_t(0)); + +// } else { +// high_accumulator = context->decompose_into_base4_accumulators(high_bits_in.witness_index, +// static_cast(num_high_limb_bits), +// "bigfield: high_bits_in too large."); +// limb_3.witness_index = high_accumulator[static_cast((num_last_limb_bits / 2) - 1)]; +// limb_2 = (high_bits_in - (limb_3 * shift_1)); +// } +// } else { +// uint256_t slice_2 = uint256_t(high_bits_in.additive_constant).slice(0, NUM_LIMB_BITS); +// uint256_t slice_3 = uint256_t(high_bits_in.additive_constant).slice(NUM_LIMB_BITS, num_high_limb_bits); +// limb_2 = field_t(context, barretenberg::fr(slice_2)); +// limb_3 = field_t(context, barretenberg::fr(slice_3)); +// } +// binary_basis_limbs[0] = Limb(limb_0, DEFAULT_MAXIMUM_LIMB); +// binary_basis_limbs[1] = Limb(limb_1, DEFAULT_MAXIMUM_LIMB); +// binary_basis_limbs[2] = Limb(limb_2, DEFAULT_MAXIMUM_LIMB); +// if (maximum_bitlength > 0) { +// uint256_t max_limb_value = (uint256_t(1) << (maximum_bitlength - (3 * NUM_LIMB_BITS))) - 1; +// binary_basis_limbs[3] = Limb(limb_3, max_limb_value); +// } else { +// binary_basis_limbs[3] = +// Limb(limb_3, can_overflow ? DEFAULT_MAXIMUM_LIMB : DEFAULT_MAXIMUM_MOST_SIGNIFICANT_LIMB); +// } +// prime_basis_limb = low_bits_in + (high_bits_in * shift_2); +// } +} // namespace barretenberg \ 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 abdf3ab44c1..5bc43325683 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -4,6 +4,7 @@ #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_utils.hpp" #include "barretenberg/honk/proof_system/types/proof.hpp" // #define LOG_CHALLENGES @@ -80,12 +81,11 @@ 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 barretenberg::frs written to proof_data by the prover or the verifier + size_t num_frs_read = 0; // the number of barretenberg::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 Fr previous_challenge{}; // default-initialized to zeros std::vector current_round_data; @@ -143,16 +143,16 @@ 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(); } /** @@ -200,10 +200,10 @@ class BaseTranscript { */ 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; }; @@ -232,7 +232,7 @@ 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. @@ -258,7 +258,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 @@ -283,7 +283,7 @@ class BaseTranscript { info("sent: ", label, ": ", element); } #endif - // BaseTranscript::consume_prover_element_field_elements(label, element_field_elements); + // BaseTranscript::consume_prover_element_frs(label, element_field_elements); } /** @@ -294,15 +294,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 = barretenberg::calc_num_frs(); // TODO: need to change calculation + 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); + T element = from_buffer(element_frs); // TODO: update this conversion to be correct #ifdef LOG_INTERACTIONS if constexpr (Loggable) { diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index 2f140e4b69a..65bfc0dc35e 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; From d50ac92ce1962a7c6a49dbf7f555be6c2e889b72 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Wed, 17 Jan 2024 08:08:56 +0000 Subject: [PATCH 09/64] updated calc_num_frs() with all transcript types --- .../ecc/fields/field_conversion_utils.hpp | 97 ++++++++++++------- .../barretenberg/transcript/transcript.hpp | 7 +- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp index 87e6fc66858..7a902d0a5c4 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion_utils.hpp @@ -1,46 +1,16 @@ #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/plonk/proof_system/constants.hpp" +#include "barretenberg/polynomials/univariate.hpp" namespace barretenberg { // convert bn254::frs to grumpkin::fr static constexpr uint64_t NUM_CONVERSION_LIMB_BITS = 64; -template constexpr size_t calc_num_frs() -{ - if constexpr (std::is_same_v) { - return 2; - } else if constexpr (std::is_same_v) { - return 1; - } else if constexpr (std::is_same_v) { - return 1; - } else if constexpr (std::is_same_v) { - return 1; - } else { - return 0; - } -} - -std::array inline convert_to_bn254_fr(const grumpkin::fr& val) -{ - return convert_grumpkin_fr_to_barretenberg_frs(val); -} - -template constexpr barretenberg::fr convert_to_bn254_fr(T val) -{ - if constexpr (std::is_same_v) { - return val; - } else if constexpr (std::is_same_v) { - return val; - } else { - return val; - } -} - std::array inline decompose_bn254_fr_to_two_limbs(const barretenberg::fr& field_val) { ASSERT(field_val < (uint256_t(1) << (2 * NUM_CONVERSION_LIMB_BITS))); // should be 128 bits, technically 127 or less @@ -58,8 +28,9 @@ std::array inline decompose_bn254_fr_to_two_limbs(const barretenber return std::array{ low, hi }; } +// circuit form // template -// std::array UltraCircuitBuilder_::decompose_non_native_field_double_width_limb( +// std::array UltraCircuitBuilder_::decompose_bn254_fr_to_two_limbs( // const uint32_t limb_idx, const size_t num_limb_bits) // { // ASSERT(uint256_t(this->get_variable_reference(limb_idx)) < (uint256_t(1) << num_limb_bits)); @@ -212,4 +183,64 @@ std::array inline convert_grumpkin_fr_to_barretenberg_frs(c // } // prime_basis_limb = low_bits_in + (high_bits_in * shift_2); // } + +/* types are + +uint32_t +uint64_t +barretenberg::fr +grumpkin::fr +bn254 +curve::BN254::AffineElement +curve::Grumpkin::Curve::G1::AffineElement +barretenberg::Univariate +std::array, depends on num_all_entities + +*/ +template constexpr size_t calc_num_frs() +{ + if constexpr (std::is_same_v) { + return 2; + } else if constexpr (std::is_same_v || std::is_same_v || + std::is_same_v || std::is_same_v) { + return 1; + } else { + return 0; + } +} + +template