diff --git a/barretenberg/cpp/notebook.ipynb b/barretenberg/cpp/notebook.ipynb index 86bb34e9997..19fe97b767c 100644 --- a/barretenberg/cpp/notebook.ipynb +++ b/barretenberg/cpp/notebook.ipynb @@ -37,7 +37,7 @@ ], "source": [ "# Convert a 256-bit hex string. Outputs four 64-bit limbs that can be used to construct a native field element.\n", - "# Idea: s == barretenberg::fr(hex_to_field(s)).to_montgomery_form() is true as hex strings if s was in Montgomery form.\n", + "# Idea: s == bb::fr(hex_to_field(s)).to_montgomery_form() is true as hex strings if s was in Montgomery form.\n", "def hex_to_field(s):\n", " s = s[2:] # slice off leading 0x\n", " data = [s[48:64], s[32:48], s[16:32], s[0:16]]\n", diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp index 96111060fa2..f724fad7ca0 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp @@ -27,7 +27,7 @@ std::vector download_bn254_g2_data() return exec_pipe(command); } -std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points) +std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points) { std::filesystem::create_directories(path); @@ -37,9 +37,9 @@ std::vector get_bn254_g1_data(const std::files if (g1_file_size >= num_points * 64 && g1_file_size % 64 == 0) { vinfo("using cached crs of size ", std::to_string(g1_file_size / 64), " at ", g1_path); auto data = read_file(g1_path, g1_file_size); - auto points = std::vector(num_points); + auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - points[i] = from_buffer(data, i * 64); + points[i] = from_buffer(data, i * 64); } return points; } @@ -48,14 +48,14 @@ std::vector get_bn254_g1_data(const std::files auto data = download_bn254_g1_data(num_points); write_file(g1_path, data); - auto points = std::vector(num_points); + auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - points[i] = from_buffer(data, i * 64); + points[i] = from_buffer(data, i * 64); } return points; } -barretenberg::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) +bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) { std::filesystem::create_directories(path); @@ -64,10 +64,10 @@ barretenberg::g2::affine_element get_bn254_g2_data(const std::filesystem::path& if (g2_file_size == 128) { auto data = read_file(g2_path); - return from_buffer(data.data()); + return from_buffer(data.data()); } auto data = download_bn254_g2_data(); write_file(g2_path, data); - return from_buffer(data.data()); + return from_buffer(data.data()); } diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp index 74c5e7bcea4..230e074f219 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp @@ -8,5 +8,5 @@ #include #include -std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); -barretenberg::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); \ No newline at end of file +std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); +bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp index 86b4e032097..fca6a54de7b 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp @@ -35,7 +35,7 @@ std::vector get_grumpkin_g1_data(const std::file auto data = read_file(file, 28 + num_points * 64); auto points = std::vector(num_points); auto size_of_points_in_bytes = num_points * 64; - barretenberg::srs::IO::read_affine_elements_from_buffer( + bb::srs::IO::read_affine_elements_from_buffer( points.data(), (char*)data.data(), size_of_points_in_bytes); return points; } @@ -52,7 +52,6 @@ std::vector get_grumpkin_g1_data(const std::file new_size_file.close(); auto points = std::vector(num_points); - barretenberg::srs::IO::read_affine_elements_from_buffer( - points.data(), (char*)data.data(), data.size()); + bb::srs::IO::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size()); return points; } diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 3657c516b8a..5f75206108e 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -16,7 +16,7 @@ #include #include -using namespace barretenberg; +using namespace bb; std::string getHomeDir() { diff --git a/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp index 32f6082d3a8..1d1cc37718a 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp @@ -25,7 +25,7 @@ #include using namespace benchmark; -using namespace barretenberg; +using namespace bb; namespace { using Curve = curve::BN254; using Fr = Curve::ScalarField; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp index 8631a1a550d..59e793ce187 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp @@ -45,7 +45,7 @@ Builder generate_trace(size_t target_num_gates) void eccvm_generate_prover(State& state) noexcept { - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); size_t target_num_gates = 1 << static_cast(state.range(0)); for (auto _ : state) { @@ -57,7 +57,7 @@ void eccvm_generate_prover(State& state) noexcept void eccvm_prove(State& state) noexcept { - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); size_t target_num_gates = 1 << static_cast(state.range(0)); Builder builder = generate_trace(target_num_gates); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp index 2ed5897aa00..44fe8180c9c 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp @@ -8,14 +8,14 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" using namespace benchmark; -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace { void goblin_full(State& state) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); Goblin goblin; @@ -48,8 +48,8 @@ void goblin_full(State& state) noexcept void goblin_accumulate(State& state) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); Goblin goblin; @@ -74,8 +74,8 @@ void goblin_accumulate(State& state) noexcept void goblin_eccvm_prove(State& state) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); Goblin goblin; @@ -102,8 +102,8 @@ void goblin_eccvm_prove(State& state) noexcept void goblin_translator_prove(State& state) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); Goblin goblin; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp index 9d4f7028e55..ff0c24b72c8 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp @@ -2,7 +2,7 @@ #include using namespace benchmark; -using namespace barretenberg; +using namespace bb; using namespace proof_system; using namespace proof_system::honk::pcs::ipa; namespace { @@ -17,8 +17,8 @@ using VerifierCommitmentKey = honk::pcs::VerifierCommitmentKey; constexpr size_t MIN_POLYNOMIAL_DEGREE_LOG2 = 10; constexpr size_t MAX_POLYNOMIAL_DEGREE_LOG2 = 16; -std::shared_ptr> crs_factory( - new barretenberg::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); +std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); auto ck = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); auto vk = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp b/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp index 85024ba6605..cd6adb52b36 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp @@ -15,7 +15,7 @@ // CALLGRIND_STOP_INSTRUMENTATION; // CALLGRIND_DUMP_STATS; -using namespace barretenberg; +using namespace bb; // constexpr size_t NUM_GATES = 1 << 10; @@ -44,12 +44,12 @@ using namespace barretenberg; // } constexpr size_t NUM_POINTS = 1 << 16; std::vector scalars; -static barretenberg::evaluation_domain small_domain; -static barretenberg::evaluation_domain large_domain; +static bb::evaluation_domain small_domain; +static bb::evaluation_domain large_domain; const auto init = []() { - small_domain = barretenberg::evaluation_domain(NUM_POINTS); - large_domain = barretenberg::evaluation_domain(NUM_POINTS * 4); + small_domain = bb::evaluation_domain(NUM_POINTS); + large_domain = bb::evaluation_domain(NUM_POINTS * 4); fr element = fr::random_element(); fr accumulator = element; @@ -66,7 +66,7 @@ const auto init = []() { // constexpr double add_to_mixed_add_complexity = 1.36; auto reference_string = - std::make_shared>(NUM_POINTS, "../srs_db/ignition"); + std::make_shared>(NUM_POINTS, "../srs_db/ignition"); int pippenger() { @@ -84,7 +84,7 @@ int pippenger() int coset_fft_split() { std::chrono::steady_clock::time_point time_start = std::chrono::steady_clock::now(); - barretenberg::polynomial_arithmetic::coset_fft(&scalars[0], small_domain, small_domain, 4); + bb::polynomial_arithmetic::coset_fft(&scalars[0], small_domain, small_domain, 4); std::chrono::steady_clock::time_point time_end = std::chrono::steady_clock::now(); std::chrono::microseconds diff = std::chrono::duration_cast(time_end - time_start); std::cout << "run time: " << diff.count() << "us" << std::endl; @@ -94,7 +94,7 @@ int coset_fft_split() int coset_fft_regular() { std::chrono::steady_clock::time_point time_start = std::chrono::steady_clock::now(); - barretenberg::polynomial_arithmetic::coset_fft(&scalars[0], large_domain); + bb::polynomial_arithmetic::coset_fft(&scalars[0], large_domain); std::chrono::steady_clock::time_point time_end = std::chrono::steady_clock::now(); std::chrono::microseconds diff = std::chrono::duration_cast(time_end - time_start); std::cout << "run time: " << diff.count() << "us" << std::endl; @@ -103,7 +103,7 @@ int coset_fft_regular() int main() { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); std::cout << "initializing" << std::endl; init(); std::cout << "executing normal fft" << std::endl; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/plonk.bench.cpp index 27989435cb6..8b62462e884 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/plonk.bench.cpp @@ -17,8 +17,8 @@ using Composer = proof_system::plonk::StandardComposer; void generate_test_plonk_circuit(Builder& builder, size_t num_gates) { - plonk::stdlib::field_t a(plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); - plonk::stdlib::field_t b(plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); + plonk::stdlib::field_t a(plonk::stdlib::witness_t(&builder, bb::fr::random_element())); + plonk::stdlib::field_t b(plonk::stdlib::witness_t(&builder, bb::fr::random_element())); plonk::stdlib::field_t c(&builder); for (size_t i = 0; i < (num_gates / 4) - 4; ++i) { c = a + b; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp index 4153499e672..cecb40bbf9f 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -16,7 +16,7 @@ using Builder = Flavor::CircuitBuilder; // Fold one instance into an accumulator. void fold_one(State& state) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); auto log2_num_gates = static_cast(state.range(0)); auto composer = UltraComposer(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp index 761cccd4670..3c731e49652 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp @@ -8,9 +8,9 @@ namespace { auto& engine = numeric::random::get_debug_engine(); } -using FF = barretenberg::fr; -using barretenberg::BarycentricData; -using barretenberg::Univariate; +using FF = bb::fr; +using bb::BarycentricData; +using bb::Univariate; namespace proof_system::benchmark { diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index e922e3b3209..c88167a4c97 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -12,7 +12,7 @@ using namespace proof_system::honk::sumcheck; namespace proof_system::benchmark::relations { -using Fr = barretenberg::fr; +using Fr = bb::fr; using Fq = grumpkin::fr; template void execute_relation(::benchmark::State& state) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp index 0ef9fabfa0a..e1419a591e9 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp @@ -32,10 +32,8 @@ namespace bench_utils { */ template void generate_basic_arithmetic_circuit(Builder& builder, size_t log2_num_gates) { - proof_system::plonk::stdlib::field_t a( - proof_system::plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); - proof_system::plonk::stdlib::field_t b( - proof_system::plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); + proof_system::plonk::stdlib::field_t a(proof_system::plonk::stdlib::witness_t(&builder, bb::fr::random_element())); + proof_system::plonk::stdlib::field_t b(proof_system::plonk::stdlib::witness_t(&builder, bb::fr::random_element())); proof_system::plonk::stdlib::field_t c(&builder); size_t passes = (1UL << log2_num_gates) / 4 - 4; if (static_cast(passes) <= 0) { @@ -213,7 +211,7 @@ template void construct_proof_with_specified_num_iterations( State& state, void (*test_circuit_function)(typename Composer::CircuitBuilder&, size_t), size_t num_iterations) { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); Composer composer; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp index 643aa216521..333b6ddcc86 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp @@ -49,7 +49,7 @@ BBERG_PROFILE static void test_round_inner(State& state, honk::UltraProver& prov } BBERG_PROFILE static void test_round(State& state, size_t index) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); for (auto _ : state) { state.PauseTiming(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp index 1c15df07798..ecc086303b9 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp @@ -49,7 +49,7 @@ BBERG_PROFILE static void test_round_inner(State& state, plonk::UltraProver& pro } BBERG_PROFILE static void test_round(State& state, size_t index) noexcept { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); for (auto _ : state) { state.PauseTiming(); plonk::UltraComposer composer; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp index 289679d0354..0ec974da527 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp @@ -36,7 +36,7 @@ struct BasicPlonkKeyAndTranscript { BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); auto inner_composer = plonk::UltraComposer(); auto builder = typename plonk::UltraComposer::CircuitBuilder(); bench_utils::generate_basic_arithmetic_circuit(builder, 16); @@ -55,7 +55,7 @@ template void execute_widget(::benchmark::Sta BasicPlonkKeyAndTranscript data = get_plonk_key_and_transcript(); Widget widget(data.key); for (auto _ : state) { - widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); + widget.compute_quotient_contribution(bb::fr::random_element(), data.transcript); } } @@ -67,7 +67,7 @@ template void quotient_contribution(::benchmark::State& state) #ifdef GET_PER_ROW_TIME auto start = std::chrono::high_resolution_clock::now(); #endif - widget.compute_quotient_contribution(barretenberg::fr::random_element(), data.transcript); + widget.compute_quotient_contribution(bb::fr::random_element(), data.transcript); #ifdef GET_PER_ROW_TIME auto end = std::chrono::high_resolution_clock::now(); auto elapsed_seconds = std::chrono::duration_cast>(end - start); @@ -100,11 +100,11 @@ template void accumulate_contribution(::benchmark::State& stat using FFTKernel = typename Widget::FFTKernel; auto polynomials = FFTGetter::get_polynomials(data.key.get(), FFTKernel::get_required_polynomial_ids()); - auto challenges = FFTGetter::get_challenges( - data.transcript, barretenberg::fr::random_element(), FFTKernel::quotient_required_challenges); + auto challenges = + FFTGetter::get_challenges(data.transcript, bb::fr::random_element(), FFTKernel::quotient_required_challenges); for (auto _ : state) { - barretenberg::fr result{ 0 }; + bb::fr result{ 0 }; FFTKernel::accumulate_contribution(polynomials, challenges, result, 0); } } diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp index f532689e981..27dea27d358 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp @@ -26,7 +26,7 @@ template class OpeningPair { */ template class ProverOpeningClaim { using Fr = typename Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; public: Polynomial polynomial; // p @@ -59,7 +59,7 @@ template class OpeningClaim { * @param polynomial the claimed witness polynomial p(X) * @return C = Commit(p(X)) && p(r) = v */ - bool verify(std::shared_ptr ck, const barretenberg::Polynomial& polynomial) const + bool verify(std::shared_ptr ck, const bb::Polynomial& polynomial) const { Fr real_eval = polynomial.evaluate(opening_pair.challenge); if (real_eval != opening_pair.evaluation) { diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp index 28359357e6c..c820054558a 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp @@ -45,14 +45,13 @@ template class CommitmentKey { * */ CommitmentKey(const size_t num_points, - std::shared_ptr> crs_factory = - barretenberg::srs::get_crs_factory()) + std::shared_ptr> crs_factory = bb::srs::get_crs_factory()) : pippenger_runtime_state(num_points) , srs(crs_factory->get_prover_crs(num_points)) {} // Note: This constructor is used only by Plonk; For Honk the srs is extracted by the CommitmentKey - CommitmentKey(const size_t num_points, std::shared_ptr> prover_crs) + CommitmentKey(const size_t num_points, std::shared_ptr> prover_crs) : pippenger_runtime_state(num_points) , srs(prover_crs) {} @@ -67,12 +66,12 @@ template class CommitmentKey { { const size_t degree = polynomial.size(); ASSERT(degree <= srs->get_monomial_size()); - return barretenberg::scalar_multiplication::pippenger_unsafe( + return bb::scalar_multiplication::pippenger_unsafe( const_cast(polynomial.data()), srs->get_monomial_points(), degree, pippenger_runtime_state); }; - barretenberg::scalar_multiplication::pippenger_runtime_state pippenger_runtime_state; - std::shared_ptr> srs; + bb::scalar_multiplication::pippenger_runtime_state pippenger_runtime_state; + std::shared_ptr> srs; }; } // namespace proof_system::honk::pcs diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp index 49e6dcd8838..27d8e2ed93f 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp @@ -20,16 +20,16 @@ template inline std::shared_ptr CreateCommitmentKey(); template <> inline std::shared_ptr> CreateCommitmentKey>() { constexpr size_t n = 4096; - std::shared_ptr> crs_factory( - new barretenberg::srs::factories::FileCrsFactory("../srs_db/ignition", 4096)); + std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/ignition", 4096)); return std::make_shared>(n, crs_factory); } // For IPA template <> inline std::shared_ptr> CreateCommitmentKey>() { constexpr size_t n = 4096; - std::shared_ptr> crs_factory( - new barretenberg::srs::factories::FileCrsFactory("../srs_db/grumpkin", 4096)); + std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 4096)); return std::make_shared>(n, crs_factory); } @@ -46,8 +46,8 @@ inline std::shared_ptr> CreateVerifierCommit VerifierCommitmentKey>() { constexpr size_t n = 4096; - std::shared_ptr> crs_factory( - new barretenberg::srs::factories::FileCrsFactory("../srs_db/ignition", 4096)); + std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/ignition", 4096)); return std::make_shared>(n, crs_factory); } // For IPA @@ -56,8 +56,8 @@ inline std::shared_ptr> CreateVerifierCom VerifierCommitmentKey>() { constexpr size_t n = 4096; - std::shared_ptr> crs_factory( - new barretenberg::srs::factories::FileCrsFactory("../srs_db/grumpkin", 4096)); + std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 4096)); return std::make_shared>(n, crs_factory); } template inline std::shared_ptr CreateVerifierCommitmentKey() @@ -71,7 +71,7 @@ template class CommitmentTest : public ::testing::Test { using Fr = typename Curve::ScalarField; using Commitment = typename Curve::AffineElement; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; public: CommitmentTest() @@ -204,6 +204,6 @@ using CommitmentSchemeParams = ::testing::Types; using IpaCommitmentSchemeParams = ::testing::Types; // IMPROVEMENT: reinstate typed-tests for multiple field types, i.e.: // using CommitmentSchemeParams = -// ::testing::Types, fake::Params, kzg::Params>; +// ::testing::Types, fake::Params, kzg::Params>; } // namespace proof_system::honk::pcs diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp index bbed763a388..72705c516db 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp @@ -53,10 +53,8 @@ namespace proof_system::honk::pcs::gemini { * @return std::vector */ template -std::vector> GeminiProver_< - Curve>::compute_gemini_polynomials(std::span mle_opening_point, - Polynomial&& batched_unshifted, - Polynomial&& batched_to_be_shifted) +std::vector> GeminiProver_::compute_gemini_polynomials( + std::span mle_opening_point, Polynomial&& batched_unshifted, Polynomial&& batched_to_be_shifted) { const size_t num_variables = mle_opening_point.size(); // m diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp index b0ed17cdc19..03b77e9645f 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp @@ -59,7 +59,7 @@ namespace proof_system::honk::pcs::gemini { */ template struct ProverOutput { std::vector> opening_pairs; - std::vector> witnesses; + std::vector> witnesses; }; /** @@ -99,7 +99,7 @@ template inline std::vector squares_of_r(const Fr r, const size_t template class GeminiProver_ { using Fr = typename Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; public: static std::vector compute_gemini_polynomials(std::span mle_opening_point, 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..80b93ed89e3 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -14,7 +14,7 @@ template class GeminiTest : public CommitmentTest { using GeminiVerifier = GeminiVerifier_; using Fr = typename Curve::ScalarField; using GroupElement = typename Curve::Element; - using Polynomial = typename barretenberg::Polynomial; + using Polynomial = typename bb::Polynomial; public: void execute_gemini_and_verify_claims(size_t log_n, diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp index 6ef30e0d296..b4b2a405187 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp @@ -21,7 +21,7 @@ template class IPA { using Commitment = typename Curve::AffineElement; using CK = CommitmentKey; using VK = VerifierCommitmentKey; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; public: /** @@ -116,12 +116,12 @@ template class IPA { /*finite_field_multiplications_per_iteration=*/2); // L_i = < a_vec_lo, G_vec_hi > + inner_prod_L * aux_generator - L_elements[i] = barretenberg::scalar_multiplication::pippenger_without_endomorphism_basis_points( + L_elements[i] = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( &a_vec[0], &G_vec_local[round_size], round_size, ck->pippenger_runtime_state); L_elements[i] += aux_generator * inner_prod_L; // R_i = < a_vec_hi, G_vec_lo > + inner_prod_R * aux_generator - R_elements[i] = barretenberg::scalar_multiplication::pippenger_without_endomorphism_basis_points( + R_elements[i] = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( &a_vec[round_size], &G_vec_local[0], round_size, ck->pippenger_runtime_state); R_elements[i] += aux_generator * inner_prod_R; @@ -205,7 +205,7 @@ template class IPA { msm_scalars[2 * i + 1] = round_challenges_inv[i].sqr(); } - GroupElement LR_sums = barretenberg::scalar_multiplication::pippenger_without_endomorphism_basis_points( + GroupElement LR_sums = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( &msm_scalars[0], &msm_elements[0], pippenger_size, vk->pippenger_runtime_state); GroupElement C_zero = C_prime + LR_sums; @@ -269,7 +269,7 @@ template class IPA { /*scalar_multiplications_per_iteration=*/0, /*sequential_copy_ops_per_iteration=*/1); - auto G_zero = barretenberg::scalar_multiplication::pippenger_without_endomorphism_basis_points( + auto G_zero = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( &s_vec[0], &G_vec_local[0], poly_degree, vk->pippenger_runtime_state); auto a_zero = transcript->template receive_from_prover("IPA:a_0"); 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..6abfce080c6 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -8,7 +8,7 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/polynomials/polynomial_arithmetic.hpp" #include -using namespace barretenberg; +using namespace bb; namespace proof_system::honk::pcs::ipa::test { using Curve = curve::Grumpkin; @@ -19,7 +19,7 @@ class IPATest : public CommitmentTest { using GroupElement = typename Curve::Element; using CK = CommitmentKey; using VK = VerifierCommitmentKey; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; }; TEST_F(IPATest, CommitOnManyZeroCoeffPolyWorks) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp index 3c34333f45e..940cefd30e8 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp @@ -17,7 +17,7 @@ template class KZG { using Fr = typename Curve::ScalarField; using Commitment = typename Curve::AffineElement; using GroupElement = typename Curve::Element; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; /** * @brief Computes the KZG commitment to an opening proof polynomial at a single evaluation point 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..e55633c575c 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -19,7 +19,7 @@ template class KZGTest : public CommitmentTest { using Fr = typename Curve::ScalarField; using Commitment = typename Curve::AffineElement; using GroupElement = typename Curve::Element; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; }; TYPED_TEST_SUITE(KZGTest, CommitmentSchemeParams); @@ -32,7 +32,7 @@ TYPED_TEST(KZGTest, single) using Fr = typename TypeParam::ScalarField; auto witness = this->random_polynomial(n); - barretenberg::g1::element commitment = this->commit(witness); + bb::g1::element commitment = this->commit(witness); auto challenge = Fr::random_element(); auto evaluation = witness.evaluate(challenge); @@ -64,7 +64,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) using KZG = KZG; using Fr = typename TypeParam::ScalarField; using GroupElement = typename TypeParam::Element; - using Polynomial = typename barretenberg::Polynomial; + using Polynomial = typename bb::Polynomial; const size_t n = 16; const size_t log_n = 4; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp index e4cb18795a4..fd61cf43191 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp @@ -25,7 +25,7 @@ namespace proof_system::honk::pcs::shplonk { * * @tparam Curve EC parameters */ -template using OutputWitness = barretenberg::Polynomial; +template using OutputWitness = bb::Polynomial; /** * @brief Prover output (claim=([G], r, 0), witness = G(X), proof = [Q]) @@ -45,7 +45,7 @@ template struct ProverOutput { */ template class ShplonkProver_ { using Fr = typename Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; public: /** 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..fbf01d10f5d 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp @@ -22,7 +22,7 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) using ShplonkProver = ShplonkProver_; using ShplonkVerifier = ShplonkVerifier_; using Fr = typename TypeParam::ScalarField; - using Polynomial = typename barretenberg::Polynomial; + using Polynomial = typename bb::Polynomial; using OpeningPair = OpeningPair; using OpeningClaim = OpeningClaim; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp index 49c77bebbdb..b9bcb636d11 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp @@ -44,7 +44,7 @@ template <> class VerifierCommitmentKey { * @param srs verifier G2 point */ VerifierCommitmentKey([[maybe_unused]] size_t num_points, - std::shared_ptr> crs_factory) + std::shared_ptr> crs_factory) : srs(crs_factory->get_verifier_crs()) {} @@ -59,13 +59,13 @@ template <> class VerifierCommitmentKey { { Commitment pairing_points[2]{ p0, p1 }; // The final pairing check of step 12. - Curve::TargetField result = barretenberg::pairing::reduced_ate_pairing_batch_precomputed( - pairing_points, srs->get_precomputed_g2_lines(), 2); + Curve::TargetField result = + bb::pairing::reduced_ate_pairing_batch_precomputed(pairing_points, srs->get_precomputed_g2_lines(), 2); return (result == Curve::TargetField::one()); } - std::shared_ptr> srs; + std::shared_ptr> srs; }; /** @@ -88,15 +88,14 @@ template <> class VerifierCommitmentKey { * @param num_points specifies the length of the SRS * @param path is the location to the SRS file */ - VerifierCommitmentKey(size_t num_points, - std::shared_ptr> crs_factory) + VerifierCommitmentKey(size_t num_points, std::shared_ptr> crs_factory) : pippenger_runtime_state(num_points) , srs(crs_factory->get_verifier_crs(num_points)) {} - barretenberg::scalar_multiplication::pippenger_runtime_state pippenger_runtime_state; - std::shared_ptr> srs; + bb::scalar_multiplication::pippenger_runtime_state pippenger_runtime_state; + std::shared_ptr> srs; }; } // namespace proof_system::honk::pcs diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp index 395f185d4f5..0fb5d130875 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp @@ -6,9 +6,9 @@ namespace proof_system::honk { struct OpeningProof { - std::vector gemini; - barretenberg::g1::affine_element shplonk; - barretenberg::g1::affine_element kzg; + std::vector gemini; + bb::g1::affine_element shplonk; + bb::g1::affine_element kzg; }; } // namespace proof_system::honk diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp index 0339e7fff1d..562f90cf355 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp @@ -33,7 +33,7 @@ template inline std::vector powers_of_challenge(const FF challeng template class ZeroMorphProver_ { using FF = typename Curve::ScalarField; using Commitment = typename Curve::AffineElement; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; // TODO(#742): Set this N_max to be the number of G1 elements in the mocked zeromorph SRS once it's in place. // (Then, eventually, set it based on the real SRS). For now we set it to be large but more or less arbitrary. 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..dcc5e39bed1 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp @@ -9,7 +9,7 @@ namespace proof_system::honk::pcs::zeromorph { template class ZeroMorphTest : public CommitmentTest { public: using Fr = typename Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using Commitment = typename Curve::AffineElement; using GroupElement = typename Curve::Element; using ZeroMorphProver = ZeroMorphProver_; @@ -104,7 +104,7 @@ template class ZeroMorphTest : public CommitmentTest { template class ZeroMorphWithConcatenationTest : public CommitmentTest { public: using Fr = typename Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using Commitment = typename Curve::AffineElement; using GroupElement = typename Curve::Element; using ZeroMorphProver = ZeroMorphProver_; @@ -273,7 +273,7 @@ TYPED_TEST(ZeroMorphTest, QuotientConstruction) // Define some useful type aliases using ZeroMorphProver = ZeroMorphProver_; using Fr = typename TypeParam::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; // Define size parameters size_t N = 16; @@ -320,7 +320,7 @@ TYPED_TEST(ZeroMorphTest, BatchedLiftedDegreeQuotient) // Define some useful type aliases using ZeroMorphProver = ZeroMorphProver_; using Fr = typename TypeParam::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; const size_t N = 8; @@ -364,7 +364,7 @@ TYPED_TEST(ZeroMorphTest, PartiallyEvaluatedQuotientZeta) // Define some useful type aliases using ZeroMorphProver = ZeroMorphProver_; using Fr = typename TypeParam::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; const size_t N = 8; @@ -446,7 +446,7 @@ TYPED_TEST(ZeroMorphTest, PartiallyEvaluatedQuotientZ) // Define some useful type aliases using ZeroMorphProver = ZeroMorphProver_; using Fr = typename TypeParam::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; const size_t N = 8; size_t log_N = numeric::get_msb(N); diff --git a/barretenberg/cpp/src/barretenberg/common/bbmalloc.cpp b/barretenberg/cpp/src/barretenberg/common/bbmalloc.cpp index d9c061acb12..7330acdfde0 100644 --- a/barretenberg/cpp/src/barretenberg/common/bbmalloc.cpp +++ b/barretenberg/cpp/src/barretenberg/common/bbmalloc.cpp @@ -3,10 +3,10 @@ WASM_EXPORT void* bbmalloc(size_t size) { - return barretenberg::get_mem_slab_raw(size); + return bb::get_mem_slab_raw(size); } WASM_EXPORT void bbfree(void* ptr) { - barretenberg::free_mem_slab_raw(ptr); + bb::free_mem_slab_raw(ptr); } diff --git a/barretenberg/cpp/src/barretenberg/common/c_bind.cpp b/barretenberg/cpp/src/barretenberg/common/c_bind.cpp index 2b2aa0f8115..8d3ba225620 100644 --- a/barretenberg/cpp/src/barretenberg/common/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/common/c_bind.cpp @@ -84,5 +84,5 @@ WASM_EXPORT void test_stdout_stderr() WASM_EXPORT void common_init_slab_allocator(uint32_t const* circuit_size) { - barretenberg::init_slab_allocator(ntohl(*circuit_size)); + bb::init_slab_allocator(ntohl(*circuit_size)); } diff --git a/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp b/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp index 29bbfc47387..9b5c7da2e86 100644 --- a/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp +++ b/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp @@ -13,7 +13,7 @@ * constexpr_for : loop over a range , where the size_t iterator `i` is a constexpr variable * constexpr_find : find if an element is in an array */ -namespace barretenberg { +namespace bb { /** * @brief Implements a loop using a compile-time iterator. Requires c++20. @@ -132,7 +132,7 @@ template constexpr bool constexpr_find() * 1. HAS NO CONSTEXPR DEFAULT CONSTRUCTOR * 2. HAS A CONSTEXPR COPY CONSTRUCTOR * - * An example of this is barretenberg::field_t + * An example of this is bb::field_t * (the default constructor does not default assign values to the field_t member variables for efficiency reasons, to * reduce the time require to construct large arrays of field elements. This means the default constructor for field_t * cannot be constexpr) @@ -159,4 +159,4 @@ template constexpr std::array create_empty_array() { return create_array(T(0), std::make_index_sequence()); } -}; // namespace barretenberg \ No newline at end of file +}; // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/slab_allocator.cpp b/barretenberg/cpp/src/barretenberg/common/slab_allocator.cpp index 7b6d2020caf..545cfaf3f11 100644 --- a/barretenberg/cpp/src/barretenberg/common/slab_allocator.cpp +++ b/barretenberg/cpp/src/barretenberg/common/slab_allocator.cpp @@ -200,7 +200,7 @@ void SlabAllocator::release(void* ptr, size_t size) SlabAllocator allocator; } // namespace -namespace barretenberg { +namespace bb { void init_slab_allocator(size_t circuit_subgroup_size) { allocator.init(circuit_subgroup_size); @@ -231,4 +231,4 @@ void free_mem_slab_raw(void* p) } manual_slabs.erase(p); } -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/common/slab_allocator.hpp b/barretenberg/cpp/src/barretenberg/common/slab_allocator.hpp index a5d5a691e7d..1eb03b1ae3a 100644 --- a/barretenberg/cpp/src/barretenberg/common/slab_allocator.hpp +++ b/barretenberg/cpp/src/barretenberg/common/slab_allocator.hpp @@ -9,7 +9,7 @@ #include #endif -namespace barretenberg { +namespace bb { /** * Allocates a bunch of memory slabs sized to serve an UltraPLONK proof construction. @@ -75,4 +75,4 @@ template class ContainerSlabAllocator { } }; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/std_string.cpp b/barretenberg/cpp/src/barretenberg/common/std_string.cpp index dc876db9ae2..2c78dd193a3 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_string.cpp +++ b/barretenberg/cpp/src/barretenberg/common/std_string.cpp @@ -6,7 +6,7 @@ #include #include -namespace barretenberg::detail { +namespace bb::detail { std::vector split(const std::string& str, char delimiter) { std::vector result; @@ -46,4 +46,4 @@ std::vector split_and_trim(const std::string& str, char delimiter) } return ret; } -} // namespace barretenberg::detail \ No newline at end of file +} // namespace bb::detail \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/std_string.hpp b/barretenberg/cpp/src/barretenberg/common/std_string.hpp index 5b5d132c921..75b85c35dbf 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_string.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_string.hpp @@ -1,7 +1,7 @@ #include #include -namespace barretenberg::detail { +namespace bb::detail { std::vector split(const std::string& str, char delimiter); // trim from start (in place) void ltrim(std::string& s); @@ -12,4 +12,4 @@ void trim(std::string& s); // Used to extract variables from a macro #__VA_ARGS__ std::vector split_and_trim(const std::string& str, char delimiter); -} // namespace barretenberg::detail \ No newline at end of file +} // namespace bb::detail \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/thread_utils.cpp b/barretenberg/cpp/src/barretenberg/common/thread_utils.cpp index 69549bbd7f0..de9181f3ecc 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread_utils.cpp +++ b/barretenberg/cpp/src/barretenberg/common/thread_utils.cpp @@ -1,6 +1,6 @@ #include "thread_utils.hpp" -namespace barretenberg::thread_utils { +namespace bb::thread_utils { /** * @brief calculates number of threads to create based on minimum iterations per thread * @details Finds the number of cpus with get_num_cpus(), and calculates `desired_num_threads` @@ -37,4 +37,4 @@ size_t calculate_num_threads_pow2(size_t num_iterations, size_t min_iterations_p return num_threads; } -} // namespace barretenberg::thread_utils \ No newline at end of file +} // namespace bb::thread_utils \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/thread_utils.hpp b/barretenberg/cpp/src/barretenberg/common/thread_utils.hpp index e6551665479..2e3dbf81c9f 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread_utils.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread_utils.hpp @@ -1,7 +1,7 @@ #pragma once #include "thread.hpp" -namespace barretenberg::thread_utils { +namespace bb::thread_utils { const size_t DEFAULT_MIN_ITERS_PER_THREAD = 1 << 4; @@ -27,4 +27,4 @@ size_t calculate_num_threads(size_t num_iterations, size_t min_iterations_per_th size_t calculate_num_threads_pow2(size_t num_iterations, size_t min_iterations_per_thread = DEFAULT_MIN_ITERS_PER_THREAD); -} // namespace barretenberg::thread_utils \ No newline at end of file +} // namespace bb::thread_utils \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp index 6db43fe006b..07dfd3a0b31 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp @@ -2,7 +2,7 @@ #include "blake2s.hpp" #include -using namespace barretenberg; +using namespace bb; extern "C" { @@ -18,8 +18,8 @@ WASM_EXPORT void blake2s_to_field(uint8_t const* data, size_t length, uint8_t* r { std::vector inputv(data, data + length); auto output = blake2::blake2s(inputv); - auto result = barretenberg::fr::serialize_from_buffer(output.data()); - barretenberg::fr::serialize_to_buffer(result, r); + auto result = bb::fr::serialize_from_buffer(output.data()); + bb::fr::serialize_to_buffer(result, r); } // Underscore to not conflict with old cbind. Remove the above when right. @@ -28,7 +28,7 @@ WASM_EXPORT void blake2s_to_field_(uint8_t const* data, fr::out_buf r) std::vector inputv; read(data, inputv); auto output = blake2::blake2s(inputv); - auto result = barretenberg::fr::serialize_from_buffer(output.data()); - barretenberg::fr::serialize_to_buffer(result, r); + auto result = bb::fr::serialize_from_buffer(output.data()); + bb::fr::serialize_to_buffer(result, r); } } diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.hpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.hpp index 03f312df8d2..cf124a5a6c9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.hpp @@ -5,7 +5,7 @@ extern "C" { -using namespace barretenberg; +using namespace bb; WASM_EXPORT void blake2s(uint8_t const* data, out_buf32 r); diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp index 59ff387ba0b..c4d93f3051d 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp @@ -392,7 +392,7 @@ static constexpr std::array test_vectors{ TEST(MiscBlake3s, TestVectors) { - barretenberg::constexpr_for<0, 1, 73>([&]() { + bb::constexpr_for<0, 1, 73>([&]() { constexpr auto v = test_vectors[index]; std::vector input(v.input.begin(), v.input.end()); auto result_vector = blake3::blake3s(input); diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake3s/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake3s/c_bind.cpp index f4455ce95ff..69b448782e4 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake3s/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake3s/c_bind.cpp @@ -6,6 +6,6 @@ WASM_EXPORT void blake3s_to_field(uint8_t const* data, size_t length, uint8_t* r { std::vector inputv(data, data + length); std::vector output = blake3::blake3s(inputv); - auto result = barretenberg::fr::serialize_from_buffer(output.data()); - barretenberg::fr::serialize_to_buffer(result, r); + auto result = bb::fr::serialize_from_buffer(output.data()); + bb::fr::serialize_to_buffer(result, r); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp index a10610600dc..b15e4a234be 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp @@ -5,7 +5,7 @@ #include "barretenberg/serialize/test_helper.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(ecdsa, msgpack) { diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.cpp index 67188995545..0d08ccff975 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.cpp @@ -5,7 +5,7 @@ extern "C" { -using namespace barretenberg; +using namespace bb; WASM_EXPORT void pedersen_commit(fr::vec_in_buf inputs_buffer, affine_element::out_buf output) { diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.hpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.hpp index 3de155cae2b..a4a37b9eac5 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.hpp @@ -5,7 +5,7 @@ extern "C" { -using namespace barretenberg; +using namespace bb; using affine_element = grumpkin::g1::affine_element; WASM_EXPORT void pedersen_commit(fr::vec_in_buf inputs_buffer, affine_element::out_buf output); diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp index 821f42ac1b1..f25ac05f0f2 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp @@ -5,7 +5,7 @@ namespace crypto { -using barretenberg::fr; +using bb::fr; TEST(Pedersen, Commitment) { diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp index 3f4d41567a8..86f505105ba 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp @@ -12,7 +12,7 @@ WASM_EXPORT void pedersen_hash(uint8_t const* inputs_buffer, uint32_t const* has crypto::GeneratorContext ctx; ctx.offset = static_cast(ntohl(*hash_index)); auto r = crypto::pedersen_hash::hash(to_hash, ctx); - barretenberg::fr::serialize_to_buffer(r, output); + bb::fr::serialize_to_buffer(r, output); } WASM_EXPORT void pedersen_hash_buffer(uint8_t const* input_buffer, uint32_t const* hash_index, uint8_t* output) @@ -22,6 +22,6 @@ WASM_EXPORT void pedersen_hash_buffer(uint8_t const* input_buffer, uint32_t cons crypto::GeneratorContext ctx; ctx.offset = static_cast(ntohl(*hash_index)); auto r = crypto::pedersen_hash::hash_buffer(to_hash, ctx); - barretenberg::fr::serialize_to_buffer(r, output); + bb::fr::serialize_to_buffer(r, output); } } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.hpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.hpp index 7369e743c19..b3d8d50c30d 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.hpp @@ -5,7 +5,7 @@ extern "C" { -using namespace barretenberg; +using namespace bb; WASM_EXPORT void pedersen_hash(fr::vec_in_buf inputs_buffer, uint32_t const* hash_index, fr::out_buf output); diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp index ed757d8cbaf..47c96cba9c7 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp @@ -5,7 +5,7 @@ namespace crypto { -using barretenberg::fr; +using bb::fr; TEST(Pedersen, Hash) { diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp index 9649f757728..0360b569673 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -13,13 +13,13 @@ namespace poseidon2_tests { TEST(Poseidon2, HashBasicTests) { - barretenberg::fr a = barretenberg::fr::random_element(&engine); - barretenberg::fr b = barretenberg::fr::random_element(&engine); - barretenberg::fr c = barretenberg::fr::random_element(&engine); - barretenberg::fr d = barretenberg::fr::random_element(&engine); + bb::fr a = bb::fr::random_element(&engine); + bb::fr b = bb::fr::random_element(&engine); + bb::fr c = bb::fr::random_element(&engine); + bb::fr d = bb::fr::random_element(&engine); - std::vector input1{ a, b, c, d }; - std::vector input2{ d, c, b, a }; + std::vector input1{ a, b, c, d }; + std::vector input2{ d, c, b, a }; auto r0 = crypto::Poseidon2::hash(input1); auto r1 = crypto::Poseidon2::hash(input1); @@ -34,15 +34,15 @@ TEST(Poseidon2, HashBasicTests) // flexibility of Poseidon's parametrisation) TEST(Poseidon2, HashConsistencyCheck) { - barretenberg::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - barretenberg::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - barretenberg::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - barretenberg::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - std::vector input{ a, b, c, d }; + std::vector input{ a, b, c, d }; auto result = crypto::Poseidon2::hash(input); - barretenberg::fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11")); + bb::fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11")); EXPECT_EQ(result, expected); } @@ -51,14 +51,14 @@ TEST(Poseidon2, HashBufferConsistencyCheck) { // 31 byte inputs because hash_buffer slicing is only injective with 31 bytes, as it slices 31 bytes for each field // element - barretenberg::fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); auto input_vec = to_buffer(a); // takes field element and converts it to 32 bytes input_vec.erase(input_vec.begin()); // erase first byte since we want 31 bytes - std::vector input{ a }; + std::vector input{ a }; auto expected = crypto::Poseidon2::hash(input); - barretenberg::fr result = crypto::Poseidon2::hash_buffer(input_vec); + bb::fr result = crypto::Poseidon2::hash_buffer(input_vec); EXPECT_EQ(result, expected); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage index 98eb6ab0204..4250e98e8a9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage @@ -664,7 +664,7 @@ print("#include \"barretenberg/ecc/curves/bn254/fr.hpp\"\n") print("namespace crypto {\n") print("struct Poseidon2Bn254ScalarFieldParams{\n") -print(" using FF = barretenberg::fr;") +print(" using FF = bb::fr;") print(" static constexpr size_t t = {};".format(t)) print(" static constexpr size_t d = {};".format(alpha)) diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp index 430d75f1fb6..7a4a3ab0619 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp @@ -9,7 +9,7 @@ namespace crypto { struct Poseidon2Bn254ScalarFieldParams { - using FF = barretenberg::fr; + using FF = bb::fr; static constexpr size_t t = 4; static constexpr size_t d = 5; static constexpr size_t rounds_f = 8; diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp index 759a00c768a..57d4b56a957 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -24,13 +24,13 @@ TEST(Poseidon2Permutation, TestVectors) TEST(Poseidon2Permutation, BasicTests) { - barretenberg::fr a = barretenberg::fr::random_element(&engine); - barretenberg::fr b = barretenberg::fr::random_element(&engine); - barretenberg::fr c = barretenberg::fr::random_element(&engine); - barretenberg::fr d = barretenberg::fr::random_element(&engine); + bb::fr a = bb::fr::random_element(&engine); + bb::fr b = bb::fr::random_element(&engine); + bb::fr c = bb::fr::random_element(&engine); + bb::fr d = bb::fr::random_element(&engine); - std::array input1{ a, b, c, d }; - std::array input2{ d, c, b, a }; + std::array input1{ a, b, c, d }; + std::array input2{ d, c, b, a }; auto r0 = crypto::Poseidon2Permutation::permutation(input1); auto r1 = crypto::Poseidon2Permutation::permutation(input1); @@ -45,19 +45,19 @@ TEST(Poseidon2Permutation, BasicTests) // flexibility of Poseidon's parametrisation) TEST(Poseidon2Permutation, ConsistencyCheck) { - barretenberg::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - barretenberg::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - barretenberg::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - barretenberg::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - std::array input{ a, b, c, d }; + std::array input{ a, b, c, d }; auto result = crypto::Poseidon2Permutation::permutation(input); - std::array expected{ - barretenberg::fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), - barretenberg::fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), - barretenberg::fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")), - barretenberg::fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")), + std::array expected{ + bb::fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), + bb::fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), + bb::fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")), + bb::fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")), }; EXPECT_EQ(result, expected); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp index b1ceb606a33..fa7a66811fe 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp @@ -4,7 +4,7 @@ extern "C" { -using namespace barretenberg; +using namespace bb; using affine_element = grumpkin::g1::affine_element; using multisig = crypto::schnorr::multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp index cb65671fafc..f18caabe3fe 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp @@ -5,7 +5,7 @@ extern "C" { -using namespace barretenberg; +using namespace bb; using affine_element = grumpkin::g1::affine_element; using multisig = crypto::schnorr::multisig; diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp index 09372702df3..e21f8231e7b 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp @@ -3,7 +3,7 @@ #include "./multisig.hpp" -using namespace barretenberg; +using namespace bb; template struct MultisigTest : public ::testing::Test { using G = grumpkin::g1; diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp index 6036ead0807..92f46cc3eba 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include -using namespace barretenberg; +using namespace bb; template struct ProofOfPossessionTest : public ::testing::Test { using G = grumpkin::g1; diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp index b485895235b..8890d4a5454 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace crypto::schnorr; crypto::schnorr::key_pair generate_signature() diff --git a/barretenberg/cpp/src/barretenberg/crypto/sha256/sha256.hpp b/barretenberg/cpp/src/barretenberg/crypto/sha256/sha256.hpp index 6e022a59b9c..0a121bfe63e 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/sha256/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/sha256/sha256.hpp @@ -15,10 +15,10 @@ hash sha256_block(const std::vector& input); template hash sha256(const T& input); -inline barretenberg::fr sha256_to_field(std::vector const& input) +inline bb::fr sha256_to_field(std::vector const& input) { auto result = sha256::sha256(input); - return from_buffer(&result[0]); + return from_buffer(&result[0]); } inline bool operator==(hash const& lhs, std::vector const& rhs) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp index 2aa6557b03f..7aa0a0364ff 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp @@ -11,7 +11,7 @@ namespace acir_format::tests { class AcirFormatTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index d1ebbb6b89f..4e6b0f8a617 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -66,7 +66,7 @@ poly_triple serialize_arithmetic_gate(Circuit::Expression const& arg) // If necessary, set values for linears terms q_l * w_l, q_r * w_r and q_o * w_o ASSERT(arg.linear_combinations.size() <= 3); // We can only accommodate 3 linear terms for (const auto& linear_term : arg.linear_combinations) { - barretenberg::fr selector_value(uint256_t(std::get<0>(linear_term))); + bb::fr selector_value(uint256_t(std::get<0>(linear_term))); uint32_t witness_idx = std::get<1>(linear_term).value; // If the witness index has not yet been set or if the corresponding linear term is active, set the witness @@ -347,10 +347,10 @@ WitnessVector witness_buf_to_witness_data(std::vector const& buf) // To ensure that witnesses sit at the correct indices in the `WitnessVector`, we fill any indices // which do not exist within the `WitnessMap` with the dummy value of zero. while (index < e.first.value) { - wv.push_back(barretenberg::fr(0)); + wv.push_back(bb::fr(0)); index++; } - wv.push_back(barretenberg::fr(uint256_t(e.second))); + wv.push_back(bb::fr(uint256_t(e.second))); index++; } return wv; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp index 526eabed481..cb87035cae5 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp @@ -10,7 +10,7 @@ namespace acir_format::tests { class UltraPlonkRAM : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& witness_values) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp index f629482d363..6711b237439 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp @@ -48,14 +48,14 @@ secp256k1_ct::g1_ct ecdsa_convert_inputs(Builder* ctx, const secp256k1::g1::affi { uint256_t x_u256(input.x); uint256_t y_u256(input.y); - secp256k1_ct::fq_ct x(witness_ct(ctx, barretenberg::fr(x_u256.slice(0, secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2))), - witness_ct(ctx, - barretenberg::fr(x_u256.slice(secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2, - secp256k1_ct::fq_ct::NUM_LIMB_BITS * 4)))); - secp256k1_ct::fq_ct y(witness_ct(ctx, barretenberg::fr(y_u256.slice(0, secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2))), - witness_ct(ctx, - barretenberg::fr(y_u256.slice(secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2, - secp256k1_ct::fq_ct::NUM_LIMB_BITS * 4)))); + secp256k1_ct::fq_ct x( + witness_ct(ctx, bb::fr(x_u256.slice(0, secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2))), + witness_ct( + ctx, bb::fr(x_u256.slice(secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2, secp256k1_ct::fq_ct::NUM_LIMB_BITS * 4)))); + secp256k1_ct::fq_ct y( + witness_ct(ctx, bb::fr(y_u256.slice(0, secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2))), + witness_ct( + ctx, bb::fr(y_u256.slice(secp256k1_ct::fq_ct::NUM_LIMB_BITS * 2, secp256k1_ct::fq_ct::NUM_LIMB_BITS * 4)))); return { x, y }; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp index be404915e22..86a7be58ef5 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp @@ -12,7 +12,7 @@ using curve_ct = proof_system::plonk::stdlib::secp256k1; class ECDSASecp256k1 : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; size_t generate_ecdsa_constraint(EcdsaSecp256k1Constraint& ecdsa_constraint, WitnessVector& witness_values) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp index 7cf9742b132..ab68a947ff0 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp @@ -11,14 +11,14 @@ secp256r1_ct::g1_ct ecdsa_convert_inputs(Builder* ctx, const secp256r1::g1::affi { uint256_t x_u256(input.x); uint256_t y_u256(input.y); - secp256r1_ct::fq_ct x(witness_ct(ctx, barretenberg::fr(x_u256.slice(0, secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2))), - witness_ct(ctx, - barretenberg::fr(x_u256.slice(secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2, - secp256r1_ct::fq_ct::NUM_LIMB_BITS * 4)))); - secp256r1_ct::fq_ct y(witness_ct(ctx, barretenberg::fr(y_u256.slice(0, secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2))), - witness_ct(ctx, - barretenberg::fr(y_u256.slice(secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2, - secp256r1_ct::fq_ct::NUM_LIMB_BITS * 4)))); + secp256r1_ct::fq_ct x( + witness_ct(ctx, bb::fr(x_u256.slice(0, secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2))), + witness_ct( + ctx, bb::fr(x_u256.slice(secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2, secp256r1_ct::fq_ct::NUM_LIMB_BITS * 4)))); + secp256r1_ct::fq_ct y( + witness_ct(ctx, bb::fr(y_u256.slice(0, secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2))), + witness_ct( + ctx, bb::fr(y_u256.slice(secp256r1_ct::fq_ct::NUM_LIMB_BITS * 2, secp256r1_ct::fq_ct::NUM_LIMB_BITS * 4)))); return { x, y }; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp index 813f2022745..449b2b972b1 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp @@ -50,7 +50,7 @@ std::array create_recurs const std::vector dummy_key = export_dummy_key_in_recursion_format( PolynomialManifest(Builder::CIRCUIT_TYPE), inner_proof_contains_recursive_proof); const auto manifest = Composer::create_manifest(input.public_inputs.size()); - std::vector dummy_proof = + std::vector dummy_proof = export_dummy_transcript_in_recursion_format(manifest, inner_proof_contains_recursive_proof); // Remove the public inputs from the dummy proof @@ -61,8 +61,7 @@ std::array create_recurs // if we do NOT have a witness assignment (i.e. are just building the proving/verification keys), // we add our dummy proof values as Builder variables. // if we DO have a valid witness assignment, we use the real witness assignment - barretenberg::fr dummy_field = - has_valid_witness_assignments ? builder.get_variable(proof_field_idx) : dummy_proof[i]; + bb::fr dummy_field = has_valid_witness_assignments ? builder.get_variable(proof_field_idx) : dummy_proof[i]; // Create a copy constraint between our dummy field and the witness index provided by RecursionConstraint. // This will make the RecursionConstraint idx equal to `dummy_field`. // In the case of a valid witness assignment, this does nothing (as dummy_field = real value) @@ -72,8 +71,7 @@ std::array create_recurs } for (size_t i = 0; i < input.key.size(); ++i) { const auto key_field_idx = input.key[i]; - barretenberg::fr dummy_field = - has_valid_witness_assignments ? builder.get_variable(key_field_idx) : dummy_key[i]; + bb::fr dummy_field = has_valid_witness_assignments ? builder.get_variable(key_field_idx) : dummy_key[i]; builder.assert_equal(builder.add_variable(dummy_field), key_field_idx); } } @@ -166,9 +164,9 @@ std::array create_recurs * This method exports the key formatted in the manner our recursive verifier expects. * NOTE: only used by the dsl at the moment. Might be cleaner to make this a dsl function? * - * @return std::vector + * @return std::vector */ -std::vector export_key_in_recursion_format(std::shared_ptr const& vkey) +std::vector export_key_in_recursion_format(std::shared_ptr const& vkey) { std::vector output; output.emplace_back(vkey->domain.root); @@ -216,10 +214,10 @@ std::vector export_key_in_recursion_format(std::shared_ptr + * @return std::vector */ -std::vector export_dummy_key_in_recursion_format(const PolynomialManifest& polynomial_manifest, - const bool contains_recursive_proof) +std::vector export_dummy_key_in_recursion_format(const PolynomialManifest& polynomial_manifest, + const bool contains_recursive_proof) { std::vector output; output.emplace_back(1); // domain.domain (will be inverted) @@ -242,8 +240,8 @@ std::vector export_dummy_key_in_recursion_format(const Polynom // This check can also trigger a runtime error due to causing 0 to be inverted. // When creating dummy verification key points we must be mindful of the above and make sure that each // transcript point is unique. - auto scalar = barretenberg::fr::random_element(); - const auto element = barretenberg::g1::affine_element(barretenberg::g1::one * scalar); + auto scalar = bb::fr::random_element(); + const auto element = bb::g1::affine_element(bb::g1::one * scalar); auto g1_as_fields = export_g1_affine_element_as_fields(element); output.emplace_back(g1_as_fields.x_lo); output.emplace_back(g1_as_fields.x_hi); @@ -258,14 +256,14 @@ std::vector export_dummy_key_in_recursion_format(const Polynom } /** - * @brief Returns transcript represented as a vector of barretenberg::fr. + * @brief Returns transcript represented as a vector of bb::fr. * Used to represent recursive proofs (i.e. proof represented as circuit-native field elements) * - * @return std::vector + * @return std::vector */ -std::vector export_transcript_in_recursion_format(const transcript::StandardTranscript& transcript) +std::vector export_transcript_in_recursion_format(const transcript::StandardTranscript& transcript) { - std::vector fields; + std::vector fields; const auto num_rounds = transcript.get_manifest().get_num_rounds(); for (size_t i = 0; i < num_rounds; ++i) { for (const auto& manifest_element : transcript.get_manifest().get_round_manifest(i).elements) { @@ -297,18 +295,18 @@ std::vector export_transcript_in_recursion_format(const transc * errors being thrown. * * @param manifest - * @return std::vector + * @return std::vector */ -std::vector export_dummy_transcript_in_recursion_format(const transcript::Manifest& manifest, - const bool contains_recursive_proof) +std::vector export_dummy_transcript_in_recursion_format(const transcript::Manifest& manifest, + const bool contains_recursive_proof) { - std::vector fields; + std::vector fields; const auto num_rounds = manifest.get_num_rounds(); for (size_t i = 0; i < num_rounds; ++i) { for (const auto& manifest_element : manifest.get_round_manifest(i).elements) { if (!manifest_element.derived_by_verifier) { if (manifest_element.num_bytes == 32 && manifest_element.name != "public_inputs") { - // auto scalar = barretenberg::fr::random_element(); + // auto scalar = bb::fr::random_element(); fields.emplace_back(0); } else if (manifest_element.num_bytes == 64 && manifest_element.name != "public_inputs") { // the std::biggroup class creates unsatisfiable constraints when identical points are @@ -317,8 +315,8 @@ std::vector export_dummy_transcript_in_recursion_format(const // identical. And prover points should contain randomness for an honest Prover). This check can // also trigger a runtime error due to causing 0 to be inverted. When creating dummy proof // points we must be mindful of the above and make sure that each point is unique. - auto scalar = barretenberg::fr::random_element(); - const auto group_element = barretenberg::g1::affine_element(barretenberg::g1::one * scalar); + auto scalar = bb::fr::random_element(); + const auto group_element = bb::g1::affine_element(bb::g1::one * scalar); auto g1_as_fields = export_g1_affine_element_as_fields(group_element); fields.emplace_back(g1_as_fields.x_lo); fields.emplace_back(g1_as_fields.x_hi); @@ -333,8 +331,8 @@ std::vector export_dummy_transcript_in_recursion_format(const if (contains_recursive_proof) { ASSERT(num_public_inputs == RecursionConstraint::AGGREGATION_OBJECT_SIZE); for (size_t k = 0; k < RecursionConstraint::NUM_AGGREGATION_ELEMENTS; ++k) { - auto scalar = barretenberg::fr::random_element(); - const auto group_element = barretenberg::g1::affine_element(barretenberg::g1::one * scalar); + auto scalar = bb::fr::random_element(); + const auto group_element = bb::g1::affine_element(bb::g1::one * scalar); auto g1_as_fields = export_g1_affine_element_as_fields(group_element); fields.emplace_back(g1_as_fields.x_lo); fields.emplace_back(g1_as_fields.x_hi); @@ -343,7 +341,7 @@ std::vector export_dummy_transcript_in_recursion_format(const } } else { for (size_t j = 0; j < num_public_inputs; ++j) { - // auto scalar = barretenberg::fr::random_element(); + // auto scalar = bb::fr::random_element(); fields.emplace_back(0); } } @@ -361,14 +359,14 @@ size_t recursion_proof_size_without_public_inputs() return dummy_transcript.size(); } -G1AsFields export_g1_affine_element_as_fields(const barretenberg::g1::affine_element& group_element) +G1AsFields export_g1_affine_element_as_fields(const bb::g1::affine_element& group_element) { const uint256_t x = group_element.x; const uint256_t y = group_element.y; - const barretenberg::fr x_lo = x.slice(0, TWO_LIMBS_BITS_IN_FIELD_SIMULATION); - const barretenberg::fr x_hi = x.slice(TWO_LIMBS_BITS_IN_FIELD_SIMULATION, FOUR_LIMBS_BITS_IN_FIELD_SIMULATION); - const barretenberg::fr y_lo = y.slice(0, TWO_LIMBS_BITS_IN_FIELD_SIMULATION); - const barretenberg::fr y_hi = y.slice(TWO_LIMBS_BITS_IN_FIELD_SIMULATION, FOUR_LIMBS_BITS_IN_FIELD_SIMULATION); + const bb::fr x_lo = x.slice(0, TWO_LIMBS_BITS_IN_FIELD_SIMULATION); + const bb::fr x_hi = x.slice(TWO_LIMBS_BITS_IN_FIELD_SIMULATION, FOUR_LIMBS_BITS_IN_FIELD_SIMULATION); + const bb::fr y_lo = y.slice(0, TWO_LIMBS_BITS_IN_FIELD_SIMULATION); + const bb::fr y_hi = y.slice(TWO_LIMBS_BITS_IN_FIELD_SIMULATION, FOUR_LIMBS_BITS_IN_FIELD_SIMULATION); return G1AsFields{ x_lo, x_hi, y_lo, y_hi }; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp index d048ce93bdf..7be0282be1a 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp @@ -64,25 +64,25 @@ std::array create_recurs std::array nested_aggregation_object, bool has_valid_witness_assignments = false); -std::vector export_key_in_recursion_format(std::shared_ptr const& vkey); -std::vector export_dummy_key_in_recursion_format(const PolynomialManifest& polynomial_manifest, - bool contains_recursive_proof = 0); +std::vector export_key_in_recursion_format(std::shared_ptr const& vkey); +std::vector export_dummy_key_in_recursion_format(const PolynomialManifest& polynomial_manifest, + bool contains_recursive_proof = 0); -std::vector export_transcript_in_recursion_format(const transcript::StandardTranscript& transcript); -std::vector export_dummy_transcript_in_recursion_format(const transcript::Manifest& manifest, - const bool contains_recursive_proof); +std::vector export_transcript_in_recursion_format(const transcript::StandardTranscript& transcript); +std::vector export_dummy_transcript_in_recursion_format(const transcript::Manifest& manifest, + const bool contains_recursive_proof); size_t recursion_proof_size_without_public_inputs(); // In order to interact with a recursive aggregation state inside of a circuit, we need to represent its internal G1 // elements as field elements. This happens in multiple locations when creating a recursion constraint. The struct and // method below export a g1 affine element as fields to use as part of the recursive circuit. struct G1AsFields { - barretenberg::fr x_lo; - barretenberg::fr x_hi; - barretenberg::fr y_lo; - barretenberg::fr y_hi; + bb::fr x_lo; + bb::fr x_hi; + bb::fr y_lo; + bb::fr y_hi; }; -G1AsFields export_g1_affine_element_as_fields(const barretenberg::g1::affine_element& group_element); +G1AsFields export_g1_affine_element_as_fields(const bb::g1::affine_element& group_element); template inline void read(B& buf, RecursionConstraint& constraint) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp index 4e8e53ff327..ba6ff3a6f5f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp @@ -10,7 +10,7 @@ using namespace proof_system::plonk; class AcirRecursionConstraint : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; namespace acir_format::test { Builder create_inner_circuit() @@ -143,10 +143,10 @@ Builder create_outer_circuit(std::vector& inner_circuits) transcript::HashType::PedersenBlake3s, 16); - std::vector proof_witnesses = export_transcript_in_recursion_format(transcript); + std::vector proof_witnesses = export_transcript_in_recursion_format(transcript); // - Save the public inputs so that we can set their values. // - Then truncate them from the proof because the ACIR API expects proofs without public inputs - std::vector inner_public_input_values( + std::vector inner_public_input_values( proof_witnesses.begin(), proof_witnesses.begin() + static_cast(num_inner_public_inputs)); // We want to make sure that we do not remove the nested aggregation object in the case of the proof we want to @@ -157,7 +157,7 @@ Builder create_outer_circuit(std::vector& inner_circuits) proof_witnesses.begin() + static_cast(num_inner_public_inputs)); } - const std::vector key_witnesses = export_key_in_recursion_format(inner_verifier.key); + const std::vector key_witnesses = export_key_in_recursion_format(inner_verifier.key); const uint32_t key_hash_start_idx = static_cast(witness_offset); const uint32_t public_input_start_idx = key_hash_start_idx + 1; 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 3a36a359591..a17e430d937 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -154,8 +154,8 @@ std::string AcirComposer::get_solidity_verifier() * @param proof * @param num_inner_public_inputs - number of public inputs on the proof being serialized */ -std::vector AcirComposer::serialize_proof_into_fields(std::vector const& proof, - size_t num_inner_public_inputs) +std::vector AcirComposer::serialize_proof_into_fields(std::vector const& proof, + size_t num_inner_public_inputs) { transcript::StandardTranscript transcript(proof, acir_format::Composer::create_manifest(num_inner_public_inputs), @@ -171,7 +171,7 @@ std::vector AcirComposer::serialize_proof_into_fields(std::vec * Use this method to get the witness values! * The composer should already have a verification key initialized. */ -std::vector AcirComposer::serialize_verification_key_into_fields() +std::vector AcirComposer::serialize_verification_key_into_fields() { return acir_format::export_key_in_recursion_format(verification_key_); } 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 12fbb8938d8..aaf77de67fa 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp @@ -34,10 +34,9 @@ class AcirComposer { size_t get_total_circuit_size() { return builder_.get_total_circuit_size(); }; size_t get_dyadic_circuit_size() { return builder_.get_circuit_subgroup_size(builder_.get_total_circuit_size()); }; - std::vector serialize_proof_into_fields(std::vector const& proof, - size_t num_inner_public_inputs); + std::vector serialize_proof_into_fields(std::vector const& proof, size_t num_inner_public_inputs); - std::vector serialize_verification_key_into_fields(); + std::vector serialize_verification_key_into_fields(); // Goblin specific methods void create_goblin_circuit(acir_format::acir_format& constraint_system, acir_format::WitnessVector& witness); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp index ea1ec4766f8..cb6b8643512 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -4,7 +4,7 @@ #include #include -using namespace barretenberg; +using namespace bb; WASM_EXPORT void acir_get_circuit_sizes(uint8_t const* constraint_system_buf, uint32_t* exact, diff --git a/barretenberg/cpp/src/barretenberg/dsl/types.hpp b/barretenberg/cpp/src/barretenberg/dsl/types.hpp index 56ecb208121..6969eae4410 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/types.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/types.hpp @@ -26,7 +26,7 @@ namespace acir_format { using Builder = proof_system::UltraCircuitBuilder; -using GoblinBuilder = barretenberg::Goblin::Builder; +using GoblinBuilder = bb::Goblin::Builder; using Composer = plonk::UltraComposer; using Prover = @@ -49,8 +49,8 @@ using uint16_ct = proof_system::plonk::stdlib::uint16; using uint32_ct = proof_system::plonk::stdlib::uint32; using uint64_ct = proof_system::plonk::stdlib::uint64; using bit_array_ct = proof_system::plonk::stdlib::bit_array; -using fq_ct = proof_system::plonk::stdlib::bigfield; -using biggroup_ct = proof_system::plonk::stdlib::element; +using fq_ct = proof_system::plonk::stdlib::bigfield; +using biggroup_ct = proof_system::plonk::stdlib::element; using cycle_group_ct = proof_system::plonk::stdlib::cycle_group; using cycle_scalar_ct = proof_system::plonk::stdlib::cycle_group::cycle_scalar; using pedersen_commitment = proof_system::plonk::stdlib::pedersen_commitment; diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp index dadc92964b0..4b171066d86 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp @@ -9,14 +9,14 @@ namespace curve { class BN254 { public: - using ScalarField = barretenberg::fr; - using BaseField = barretenberg::fq; - using Group = typename barretenberg::g1; + using ScalarField = bb::fr; + using BaseField = bb::fq; + using Group = typename bb::g1; using Element = typename Group::element; using AffineElement = typename Group::affine_element; - using G2AffineElement = typename barretenberg::g2::affine_element; - using G2BaseField = typename barretenberg::fq2; - using TargetField = barretenberg::fq12; + using G2AffineElement = typename bb::g2::affine_element; + using G2BaseField = typename bb::fq2; + using TargetField = bb::fq12; // TODO(#673): This flag is temporary. It is needed in the verifier classes (GeminiVerifier, etc.) while these // classes are instantiated with "native" curve types. Eventually, the verifier classes will be instantiated only diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.hpp index 21aca46a03c..782702d5a52 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.hpp @@ -6,7 +6,7 @@ #include "../../fields/field.hpp" // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays) -namespace barretenberg { +namespace bb { class Bn254FqParams { public: static constexpr uint64_t modulus_0 = 0x3C208C16D87CFD47UL; @@ -64,6 +64,6 @@ class Bn254FqParams { using fq = field; -} // namespace barretenberg +} // namespace bb // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.test.cpp index 779f5c84712..e65527e6424 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/serialize/test_helper.hpp" #include -using namespace barretenberg; +using namespace bb; // Used to ensure variables are evaluated at runtime and not compile time. // If EXPECT_EQ macro params are evaluated at compile-time, compiler can optimize them away. @@ -16,7 +16,7 @@ void shallow_copy(const fq& in, fq& out) }; TEST(fq, Msgpack) { - auto [actual, expected] = msgpack_roundtrip(barretenberg::fq{ 1ULL, 2ULL, 3ULL, 4ULL }); + auto [actual, expected] = msgpack_roundtrip(bb::fq{ 1ULL, 2ULL, 3ULL, 4ULL }); EXPECT_EQ(actual, expected); } diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.hpp index 40d513192e8..1fddd927768 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.hpp @@ -4,7 +4,7 @@ #include "./fq2.hpp" #include "./fq6.hpp" -namespace barretenberg { +namespace bb { struct Bn254Fq12Params { static constexpr fq2 frobenius_coefficients_1{ { 0xaf9ba69633144907UL, 0xca6b1d7387afb78aUL, 0x11bded5ef08a2087UL, 0x02f34d751a1f3a7cUL }, @@ -23,4 +23,4 @@ struct Bn254Fq12Params { }; using fq12 = field12; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.test.cpp index 79af5af3a86..c6dc81000b6 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq12.test.cpp @@ -1,7 +1,7 @@ #include "fq12.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(fq12, Eq) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.hpp index d659ee4e766..ec4148ad2d1 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.hpp @@ -3,7 +3,7 @@ #include "../../fields/field2.hpp" #include "./fq.hpp" -namespace barretenberg { +namespace bb { struct Bn254Fq2Params { static constexpr fq twist_coeff_b_0{ 0x3bf938e377b802a8UL, 0x020b1b273633535dUL, 0x26b7edf049755260UL, 0x2514c6324384a86dUL @@ -32,4 +32,4 @@ struct Bn254Fq2Params { }; using fq2 = field2; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.test.cpp index 491f8f54d1b..168b1c95ea7 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq2.test.cpp @@ -1,7 +1,7 @@ #include "fq2.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(fq2, eq) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.hpp index a9c582db319..360b5d140d6 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.hpp @@ -4,7 +4,7 @@ #include "./fq.hpp" #include "./fq2.hpp" -namespace barretenberg { +namespace bb { struct Bn254Fq6Params { static constexpr fq2 frobenius_coeffs_c1_1{ { 0xb5773b104563ab30UL, 0x347f91c8a9aa6454UL, 0x7a007127242e0991UL, 0x1956bcd8118214ecUL }, @@ -58,4 +58,4 @@ struct Bn254Fq6Params { }; using fq6 = field6; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.test.cpp index baf0830af8b..370abd9a6e7 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fq6.test.cpp @@ -1,7 +1,7 @@ #include "fq6.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(fq6, Eq) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.bench.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.bench.cpp index 77618655f6b..6ceb7d14929 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.bench.cpp @@ -63,7 +63,7 @@ unsafe pippenger. 1048576 points. clock cycles = 3626871186 unsafe pippenger clock cycles per mul = 3458 unsafe_pippenger_bench/1048576 1717275300 ns 1640625000 ns 1 */ -using namespace barretenberg; +using namespace bb; void field_mixed_add(const fr& x1, const fr& y1, const fr& z1, const fr& x2, const fr& y2, fr& x3, fr& y3, fr& z3) { @@ -126,8 +126,8 @@ uint64_t rdtsc() constexpr size_t NUM_POINTS = 1 << 24; constexpr size_t NUM_INVERSIONS = 1 << 20; -std::vector oldx; -std::vector oldy; +std::vector oldx; +std::vector oldy; fr accx; fr accy; diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.hpp index 81609405385..bfa55e67e2e 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.hpp @@ -8,7 +8,7 @@ // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays) -namespace barretenberg { +namespace bb { class Bn254FrParams { public: // Note: limbs here are combined as concat(_3, _2, _1, _0) @@ -70,6 +70,6 @@ class Bn254FrParams { using fr = field; -} // namespace barretenberg +} // namespace bb // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.test.cpp index 0fd94822024..2b2fa35fb75 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/fr.test.cpp @@ -2,11 +2,11 @@ #include "barretenberg/serialize/test_helper.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(fr, Msgpack) { - auto [actual, expected] = msgpack_roundtrip(barretenberg::fr{ 1ULL, 2ULL, 3ULL, 4ULL }); + auto [actual, expected] = msgpack_roundtrip(bb::fr{ 1ULL, 2ULL, 3ULL, 4ULL }); EXPECT_EQ(actual, expected); } diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.hpp index ed16dbdb036..ef5240fad94 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.hpp @@ -4,7 +4,7 @@ #include "./fq.hpp" #include "./fr.hpp" -namespace barretenberg { +namespace bb { struct Bn254G1Params { static constexpr bool USE_ENDOMORPHISM = true; static constexpr bool can_hash_to_curve = true; @@ -18,11 +18,11 @@ struct Bn254G1Params { using g1 = group; -} // namespace barretenberg +} // namespace bb // specialize the name in msgpack schema generation // consumed by the typescript schema compiler, helps disambiguate templates -inline std::string msgpack_schema_name(barretenberg::g1::affine_element const& /*unused*/) +inline std::string msgpack_schema_name(bb::g1::affine_element const& /*unused*/) { return "G1AffineElement"; } diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp index 17850940abd..bf7d05d14ce 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp @@ -1,7 +1,7 @@ #include "g1.hpp" #include -using namespace barretenberg; +using namespace bb; namespace test_g1 { TEST(g1, RandomElement) @@ -416,7 +416,7 @@ template void write(const T t) TEST(g1, InitializationCheck) { // NOLINTNEXTLINE not our fault googletest uses `goto`! - EXPECT_NO_THROW(write({})); + EXPECT_NO_THROW(write({})); } #endif } // namespace test_g1 \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.hpp index 0be3e32e6f9..37c84d4517d 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.hpp @@ -4,7 +4,7 @@ #include "./fq2.hpp" #include "./fr.hpp" -namespace barretenberg { +namespace bb { struct Bn254G2Params { static constexpr bool USE_ENDOMORPHISM = false; static constexpr bool can_hash_to_curve = false; @@ -20,4 +20,4 @@ struct Bn254G2Params { }; using g2 = group; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp index 467744ac06c..6905aeb1023 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp @@ -1,7 +1,7 @@ #include "g2.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(g2, RandomElement) { @@ -385,6 +385,6 @@ template void write(const T t) TEST(g2, InitializationCheck) { // NOLINTNEXTLINE not our fault googletest uses `goto`! - EXPECT_NO_THROW(write({})); + EXPECT_NO_THROW(write({})); } #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.hpp index cffd6e5de5f..849d061c9ef 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.hpp @@ -8,7 +8,7 @@ #include "./g1.hpp" #include "./g2.hpp" -namespace barretenberg::pairing { +namespace bb::pairing { constexpr size_t loop_length = 64; constexpr size_t neg_z_loop_length = 62; constexpr size_t precomputed_coefficients_length = 87; @@ -56,6 +56,6 @@ inline fq12 reduced_ate_pairing_batch_precomputed(const g1::affine_element* P_af const miller_lines* lines, size_t num_points); -} // namespace barretenberg::pairing +} // namespace bb::pairing #include "./pairing_impl.hpp" \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.test.cpp index 2d5cf8fe0a8..57d4d579bda 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.test.cpp @@ -1,7 +1,7 @@ #include "pairing.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(pairing, ReducedAtePairingCheckAgainstConstants) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing_impl.hpp index e49174151b5..de1f4cdc18a 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing_impl.hpp @@ -5,7 +5,7 @@ #include "./g2.hpp" #include "barretenberg/ecc/curves/bn254/pairing.hpp" -namespace barretenberg::pairing { +namespace bb::pairing { constexpr fq two_inv = fq(2).invert(); inline constexpr g2::element mul_by_q(const g2::element& a) { @@ -298,4 +298,4 @@ fq12 reduced_ate_pairing_batch(const g1::affine_element* P_affines, return result; } -} // namespace barretenberg::pairing +} // namespace bb::pairing diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/c_bind.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/c_bind.cpp index 9520e87bff1..39f5d688a96 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/c_bind.cpp @@ -36,7 +36,7 @@ WASM_EXPORT void ecc_grumpkin__batch_mul(uint8_t const* point_buf, WASM_EXPORT void ecc_grumpkin__get_random_scalar_mod_circuit_modulus(uint8_t* result) { - barretenberg::fr output = barretenberg::fr::random_element(); + bb::fr output = bb::fr::random_element(); write(result, output); } @@ -44,7 +44,7 @@ WASM_EXPORT void ecc_grumpkin__reduce512_buffer_mod_circuit_modulus(uint8_t* inp { auto bigint_input = from_buffer(input); - uint512_t barretenberg_modulus(barretenberg::fr::modulus); + uint512_t barretenberg_modulus(bb::fr::modulus); uint512_t target_output = bigint_input % barretenberg_modulus; write(result, target_output.lo); diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp index 53d677f322a..c378aad9ee6 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp @@ -8,8 +8,8 @@ namespace grumpkin { constexpr size_t MAX_NO_WRAP_INTEGER_BIT_LENGTH = 252; -using fq = barretenberg::fr; -using fr = barretenberg::fq; +using fq = bb::fr; +using fr = bb::fq; struct GrumpkinG1Params { static constexpr bool USE_ENDOMORPHISM = true; @@ -17,26 +17,24 @@ struct GrumpkinG1Params { static constexpr bool small_elements = true; static constexpr bool has_a = false; // have checked in grumpkin.test_b that b is Montgomery form of -17 - static constexpr barretenberg::fr b{ - 0xdd7056026000005a, 0x223fa97acb319311, 0xcc388229877910c0, 0x34394632b724eaa - }; - static constexpr barretenberg::fr a{ 0UL, 0UL, 0UL, 0UL }; + static constexpr bb::fr b{ 0xdd7056026000005a, 0x223fa97acb319311, 0xcc388229877910c0, 0x34394632b724eaa }; + static constexpr bb::fr a{ 0UL, 0UL, 0UL, 0UL }; // generator point = (x, y) = (1, sqrt(-16)), sqrt(-16) = 4i - static constexpr barretenberg::fr one_x = barretenberg::fr::one(); - static constexpr barretenberg::fr one_y{ + static constexpr bb::fr one_x = bb::fr::one(); + static constexpr bb::fr one_y{ 0x11b2dff1448c41d8UL, 0x23d3446f21c77dc3UL, 0xaa7b8cf435dfafbbUL, 0x14b34cf69dc25d68UL }; }; -using g1 = barretenberg::group; +using g1 = bb::group; }; // namespace grumpkin namespace curve { class Grumpkin { public: - using ScalarField = barretenberg::fq; - using BaseField = barretenberg::fr; + using ScalarField = bb::fq; + using BaseField = bb::fr; using Group = typename grumpkin::g1; using Element = typename Group::element; using AffineElement = typename Group::affine_element; diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp index 43111906478..fefa6a6d0dc 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp @@ -7,7 +7,7 @@ namespace test_grumpkin { TEST(grumpkin, CheckB) { auto b = grumpkin::g1::curve_b; - barretenberg::fr seventeen = 17; + bb::fr seventeen = 17; EXPECT_EQ(seventeen, -b); } diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp index 866cc3da77e..8b4a4d67367 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp @@ -100,8 +100,8 @@ struct Secp256k1FrParams { static constexpr uint64_t primitive_root_3 = 0UL; }; -using fq = barretenberg::field; -using fr = barretenberg::field; +using fq = bb::field; +using fr = bb::field; struct Secp256k1G1Params { static constexpr bool USE_ENDOMORPHISM = false; @@ -118,8 +118,7 @@ struct Secp256k1G1Params { fq(0x9C47D08FFB10D4B8UL, 0xFD17B448A6855419UL, 0x5DA4FBFC0E1108A8UL, 0x483ADA7726A3C465UL).to_montgomery_form(); }; -using g1 = barretenberg:: - group, barretenberg::field, Secp256k1G1Params>; +using g1 = bb::group, bb::field, Secp256k1G1Params>; } // namespace secp256k1 namespace curve { diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp index c20431e35b5..c4478e06b50 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp @@ -84,8 +84,8 @@ struct Secp256r1FrParams { static constexpr uint64_t primitive_root_3 = 0UL; }; -using fq = barretenberg::field; -using fr = barretenberg::field; +using fq = bb::field; +using fr = bb::field; struct Secp256r1G1Params { static constexpr bool USE_ENDOMORPHISM = false; @@ -104,8 +104,7 @@ struct Secp256r1G1Params { fq(0xCBB6406837BF51F5, 0x2BCE33576B315ECE, 0x8EE7EB4A7C0F9E16, 0x4FE342E2FE1A7F9B).to_montgomery_form(); }; -using g1 = barretenberg:: - group, barretenberg::field, Secp256r1G1Params>; +using g1 = bb::group, bb::field, Secp256r1G1Params>; } // namespace secp256r1 namespace curve { diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp index cde920f036c..77d6dab770d 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/numeric/random/engine.hpp" -namespace barretenberg { +namespace bb { template class field12 { public: constexpr field12(const base_field& a = base_field::zero(), const base_field& b = base_field::zero()) @@ -266,4 +266,4 @@ template cl constexpr bool operator==(const field12& other) const { return c0 == other.c0 && c1 == other.c1; } }; -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp index cac701076c7..aa42dad75aa 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp @@ -8,7 +8,7 @@ * Include ordering ensures linter/language server has knowledge of declarations when parsing definitions * */ -namespace barretenberg { +namespace bb { template constexpr field2 field2::operator*(const field2& other) const noexcept { // no funny primes please! we assume -1 is not a quadratic residue @@ -194,4 +194,4 @@ template field2 field2::random_element(n { return { base::random_element(engine), base::random_element(engine) }; } -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp index e1196d23c10..ba9a1281526 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp @@ -7,7 +7,7 @@ namespace numeric::random { class Engine; } -namespace barretenberg { +namespace bb { template struct alignas(32) field2 { public: constexpr field2(const base_field& a = base_field::zero(), const base_field& b = base_field::zero()) @@ -150,4 +150,4 @@ template void write(B& buf, f write(buf, value.c0); write(buf, value.c1); } -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp index 873916060a5..b69df21e2a3 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/numeric/random/engine.hpp" -namespace barretenberg { +namespace bb { template class field6 { public: constexpr field6(const base_field& a = base_field::zero(), @@ -221,4 +221,4 @@ template class field6 { constexpr bool operator==(const field6& other) const { return c0 == other.c0 && c1 == other.c1 && c2 == other.c2; } }; -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp index a0446f17916..192be60d0d2 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -20,7 +20,7 @@ #define BBERG_NO_ASM 1 #endif -namespace barretenberg { +namespace bb { template struct alignas(32) field { public: using View = field; @@ -586,4 +586,4 @@ template void write(B& buf, field const& v write(buf, input.data[0]); } -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp index 1bb8756ad25..ca322101b76 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp @@ -10,7 +10,7 @@ #include "./field_declarations.hpp" -namespace barretenberg { +namespace bb { // clang-format off // disable the following style guides: @@ -518,7 +518,7 @@ template constexpr std::pair> field::sqrt() const no } return std::pair(false, field::zero()); -} // namespace barretenberg +} // namespace bb; template constexpr field field::operator/(const field& other) const noexcept { @@ -670,7 +670,7 @@ template void field::msgpack_unpack(auto o) *this = to_montgomery_form(); } -} // namespace barretenberg +} // namespace bb // clang-format off // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_generic.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_generic.hpp index 25fb238ec6d..8eab68d1b24 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_generic.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_generic.hpp @@ -4,7 +4,7 @@ #include #include "./field_impl.hpp" -namespace barretenberg { +namespace bb { // NOLINTBEGIN(readability-implicit-bool-conversion) template constexpr std::pair field::mul_wide(uint64_t a, uint64_t b) noexcept @@ -814,4 +814,4 @@ template constexpr struct field::wide_array field::mul_512(const } // NOLINTEND(readability-implicit-bool-conversion) -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp index 1934724dccf..6424ec239ce 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp @@ -3,7 +3,7 @@ #if (BBERG_NO_ASM == 0) #include "./field_impl.hpp" #include "asm_macros.hpp" -namespace barretenberg { +namespace bb { template field field::asm_mul_with_coarse_reduction(const field& a, const field& b) noexcept { @@ -363,5 +363,5 @@ template void field::asm_self_reduce_once(const field& a) noexcept [not_modulus_3] "m"(not_modulus_3) : "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory"); } -} // namespace barretenberg +} // namespace bb #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp index f8d874cc601..528bed056d3 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp @@ -5,7 +5,7 @@ #include #include -namespace barretenberg::group_elements { +namespace bb::group_elements { template concept SupportsHashToCurve = T::can_hash_to_curve; template class alignas(64) affine_element { @@ -91,8 +91,8 @@ template class alignas(64) affine_el /** * @brief Serialize the point to the given buffer * - * @details We support serializing the point at infinity for curves defined over a barretenberg::field (i.e., a - * native field of prime order) and for points of barretenberg::g2. + * @details We support serializing the point at infinity for curves defined over a bb::field (i.e., a + * native field of prime order) and for points of bb::g2. * * @warning This will need to be updated if we serialize points over composite-order fields other than fq2! * @@ -120,8 +120,8 @@ template class alignas(64) affine_el * * @return Deserialized point * - * @details We support serializing the point at infinity for curves defined over a barretenberg::field (i.e., a - * native field of prime order) and for points of barretenberg::g2. + * @details We support serializing the point at infinity for curves defined over a bb::field (i.e., a + * native field of prime order) and for points of bb::g2. * * @warning This will need to be updated if we serialize points over composite-order fields other than fq2! */ @@ -184,6 +184,6 @@ template class alignas(64) affine_el // for serialization: update with new fields MSGPACK_FIELDS(x, y); }; -} // namespace barretenberg::group_elements +} // namespace bb::group_elements #include "./affine_element_impl.hpp" diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp index dfb4e8e4b85..eb2bdfbbffa 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp @@ -87,7 +87,7 @@ template class TestAffineElement : public testing::Test { } }; -using TestTypes = testing::Types; +using TestTypes = testing::Types; TYPED_TEST_SUITE(TestAffineElement, TestTypes); diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp index 21fa09e3f64..3c8b0d8504f 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/blake3s/blake3s.hpp" #include "barretenberg/crypto/keccak/keccak.hpp" -namespace barretenberg::group_elements { +namespace bb::group_elements { template constexpr affine_element::affine_element(const Fq& a, const Fq& b) noexcept : x(a) @@ -287,4 +287,4 @@ affine_element affine_element::random_element(numeric::ran return affine_element(x, y); } -} // namespace barretenberg::group_elements +} // namespace bb::group_elements diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp index 22477f8352e..639b32b366b 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp @@ -10,7 +10,7 @@ #include #include -namespace barretenberg::group_elements { +namespace bb::group_elements { /** * @brief element class. Implements ecc group arithmetic using Jacobian coordinates @@ -147,21 +147,20 @@ template std::ostream& operator<<(std::ostrea // constexpr element::one = element{ Params::one_x, Params::one_y, Fq::one() }; // constexpr element::point_at_infinity = one.set_infinity(); // constexpr element::curve_b = Params::b; -} // namespace barretenberg::group_elements +} // namespace bb::group_elements #include "./element_impl.hpp" template -barretenberg::group_elements::affine_element operator*( - const barretenberg::group_elements::affine_element& base, const Fr& exponent) noexcept +bb::group_elements::affine_element operator*( + const bb::group_elements::affine_element& base, const Fr& exponent) noexcept { - return barretenberg::group_elements::affine_element(barretenberg::group_elements::element(base) * - exponent); + return bb::group_elements::affine_element(bb::group_elements::element(base) * exponent); } template -barretenberg::group_elements::affine_element operator*( - const barretenberg::group_elements::element& base, const Fr& exponent) noexcept +bb::group_elements::affine_element operator*(const bb::group_elements::element& base, + const Fr& exponent) noexcept { - return (barretenberg::group_elements::element(base) * exponent); + return (bb::group_elements::element(base) * exponent); } diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp index a679fa6152c..6a7cb0ada76 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp @@ -4,7 +4,7 @@ #include "element.hpp" // NOLINTBEGIN(readability-implicit-bool-conversion, cppcoreguidelines-avoid-c-arrays) -namespace barretenberg::group_elements { +namespace bb::group_elements { template constexpr element::element(const Fq& a, const Fq& b, const Fq& c) noexcept : x(a) @@ -1164,5 +1164,5 @@ element element::random_coordinates_on_curve(numeric::rand return { x, y, Fq::one() }; } -} // namespace barretenberg::group_elements +} // namespace bb::group_elements // NOLINTEND(readability-implicit-bool-conversion, cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp index a2c35796640..ce13dfec331 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/group.hpp @@ -11,7 +11,7 @@ #include #include #include -namespace barretenberg { +namespace bb { /** * @brief group class. Represents an elliptic curve group element. @@ -120,7 +120,7 @@ template -namespace barretenberg { +namespace bb { // copies src into dest. n.b. both src and dest must be aligned on 32 byte boundaries // template // inline void group::copy(const affine_element* src, affine_element* @@ -157,6 +157,6 @@ inline void group::conditional_ne } } -} // namespace barretenberg +} // namespace bb #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc b/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc index 49453e640f9..275a89a2edf 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/group_impl_int128.tcc @@ -5,7 +5,7 @@ #include "barretenberg/ecc/groups/group.hpp" #include -namespace barretenberg { +namespace bb { // // copies src into dest. n.b. both src and dest must be aligned on 32 byte boundaries // template @@ -29,6 +29,6 @@ inline void group::conditional_ne { *dest = predicate ? -(*src) : (*src); } -} // namespace barretenberg +} // namespace bb #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp index 846d11d64c0..e7da2ad084a 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp @@ -4,10 +4,10 @@ #include // NOLINTBEGIN(readability-implicit-bool-conversion) -namespace barretenberg::wnaf { +namespace bb::wnaf { constexpr size_t SCALAR_BITS = 127; -#define WNAF_SIZE(x) ((barretenberg::wnaf::SCALAR_BITS + (x)-1) / (x)) // NOLINT(cppcoreguidelines-macro-usage) +#define WNAF_SIZE(x) ((bb::wnaf::SCALAR_BITS + (x)-1) / (x)) // NOLINT(cppcoreguidelines-macro-usage) constexpr size_t get_optimal_bucket_width(const size_t num_points) { @@ -495,6 +495,6 @@ inline void fixed_wnaf_with_restricted_first_slice(uint64_t* scalar, // uint64_t previous = get_wnaf_bits_const(scalar) + (uint64_t)skew_map; // std::array result; // } -} // namespace barretenberg::wnaf +} // namespace bb::wnaf // NOLINTEND(readability-implicit-bool-conversion) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp index 916dd3de970..01916f4c2bb 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/numeric/random/engine.hpp" #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -60,7 +60,7 @@ TEST(wnaf, WnafTwoBitWindow) constexpr uint32_t num_quads = (num_bits >> 1) + 1; uint64_t wnaf[num_quads] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); + bb::wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); /** * For representing even numbers, we define a skew: diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/point_table.hpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/point_table.hpp index 2dc1fb76add..1b164ddf5fd 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/point_table.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/point_table.hpp @@ -4,7 +4,7 @@ #include "barretenberg/ecc/curves/bn254/g1.hpp" #include -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { inline size_t point_table_size(size_t num_points) { @@ -25,4 +25,4 @@ template inline std::shared_ptr point_table_alloc(size_t num_p return std::static_pointer_cast(get_mem_slab(point_table_buf_size(num_points))); } -} // namespace barretenberg::scalar_multiplication +} // namespace bb::scalar_multiplication diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.cpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.cpp index e96132b2946..30cfc2b3771 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.cpp @@ -2,7 +2,7 @@ #include -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { // NOLINTNEXTLINE(misc-no-recursion) recursion is fine here, max recursion depth is 8 (64 bit int / 8 bits per call) void radix_sort(uint64_t* keys, const size_t num_entries, const uint32_t shift) noexcept @@ -61,4 +61,4 @@ void process_buckets(uint64_t* wnaf_entries, const size_t num_entries, const uin radix_sort(wnaf_entries, num_entries, shift); } -} // namespace barretenberg::scalar_multiplication +} // namespace bb::scalar_multiplication diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.hpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.hpp index f2bbd415569..c9ceca307ec 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/process_buckets.hpp @@ -3,8 +3,8 @@ #include #include -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { void radix_sort(uint64_t* keys, size_t num_entries, uint32_t shift) noexcept; void process_buckets(uint64_t* wnaf_entries, size_t num_entries, uint32_t num_bits) noexcept; -} // namespace barretenberg::scalar_multiplication \ No newline at end of file +} // namespace bb::scalar_multiplication \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.cpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.cpp index e9ab38acf08..a86acbbf44e 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.cpp @@ -6,20 +6,20 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" // NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast) -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { size_t get_num_pippenger_rounds(const size_t num_points) { const auto num_points_floor = static_cast(1ULL << (numeric::get_msb(num_points))); const auto num_rounds = - static_cast(barretenberg::scalar_multiplication::get_num_rounds(static_cast(num_points_floor))); + static_cast(bb::scalar_multiplication::get_num_rounds(static_cast(num_points_floor))); return num_rounds; } template pippenger_runtime_state::pippenger_runtime_state(const size_t num_initial_points) noexcept : num_points(num_initial_points * 2) - , num_buckets(static_cast(1ULL << barretenberg::scalar_multiplication::get_optimal_bucket_width( - static_cast(num_initial_points)))) + , num_buckets(static_cast( + 1ULL << bb::scalar_multiplication::get_optimal_bucket_width(static_cast(num_initial_points)))) , num_rounds(get_num_pippenger_rounds(static_cast(num_points))) , num_threads(get_num_cpus_pow2()) , prefetch_overflow(num_threads * 16) @@ -45,9 +45,9 @@ pippenger_runtime_state::pippenger_runtime_state(const size_t num_initial const auto num_points_floor = static_cast(1ULL << (numeric::get_msb(num_points))); const auto num_buckets = static_cast( - 1ULL << barretenberg::scalar_multiplication::get_optimal_bucket_width(static_cast(num_initial_points))); + 1ULL << bb::scalar_multiplication::get_optimal_bucket_width(static_cast(num_initial_points))); const auto num_rounds = - static_cast(barretenberg::scalar_multiplication::get_num_rounds(static_cast(num_points_floor))); + static_cast(bb::scalar_multiplication::get_num_rounds(static_cast(num_points_floor))); const size_t points_per_thread = static_cast(num_points) / num_threads; parallel_for(num_threads, [&](size_t i) { @@ -206,6 +206,6 @@ template struct affine_product_runtime_state; template struct affine_product_runtime_state; template struct pippenger_runtime_state; template struct pippenger_runtime_state; -} // namespace barretenberg::scalar_multiplication +} // namespace bb::scalar_multiplication // NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.hpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.hpp index a8291eb2e30..19f686f2f3b 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/runtime_states.hpp @@ -4,7 +4,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/ecc/groups/wnaf.hpp" -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { // simple helper functions to retrieve pointers to pre-allocated memory for the scalar multiplication algorithm. // This is to eliminate page faults when allocating (and writing) to large tranches of memory. constexpr size_t get_optimal_bucket_width(const size_t num_points) @@ -114,4 +114,4 @@ template struct pippenger_runtime_state { affine_product_runtime_state get_affine_product_runtime_state(size_t num_threads, size_t thread_index); }; -} // namespace barretenberg::scalar_multiplication +} // namespace bb::scalar_multiplication diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp index 84be0133581..8053fcf22b5 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp @@ -93,7 +93,7 @@ current_offset += 16; \ schedule_it += 16; -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { /** * The pippppenger point table computes for each point P = (x,y), a point P' = (\beta * x, -y) which enables us @@ -951,7 +951,7 @@ typename Curve::Element pippenger_without_endomorphism_basis_points(typename Cur pippenger_runtime_state& state) { std::vector G_mod(num_initial_points * 2); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, &G_mod[0], num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, &G_mod[0], num_initial_points); return pippenger(scalars, &G_mod[0], num_initial_points, state, false); } @@ -1058,6 +1058,6 @@ template curve::Grumpkin::Element pippenger_without_endomorphism_basis_points& state); -} // namespace barretenberg::scalar_multiplication +} // namespace bb::scalar_multiplication // NOLINTEND(cppcoreguidelines-avoid-c-arrays, google-readability-casting) diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp index 0cc1ee31a00..c93b602bfe1 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp @@ -6,7 +6,7 @@ #include #include -namespace barretenberg::scalar_multiplication { +namespace bb::scalar_multiplication { constexpr size_t get_num_buckets(const size_t num_points) { @@ -173,4 +173,4 @@ typename Curve::Element pippenger_without_endomorphism_basis_points(typename Cur // Explicit instantiation // BN254 -} // namespace barretenberg::scalar_multiplication +} // namespace bb::scalar_multiplication diff --git a/barretenberg/cpp/src/barretenberg/ecc/serialize.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/serialize.test.cpp index 603525720e4..fd7dfba20af 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/serialize.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/serialize.test.cpp @@ -5,6 +5,6 @@ TEST(MsgpackTests, MsgpackField) { - auto [actual, expected] = msgpack_roundtrip(barretenberg::fr{ 1ULL, 2ULL, 3ULL, 4ULL }); + auto [actual, expected] = msgpack_roundtrip(bb::fr{ 1ULL, 2ULL, 3ULL, 4ULL }); EXPECT_EQ(actual, expected); } diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp index c34da4ec6ab..34eede401c7 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp @@ -26,7 +26,7 @@ template class ECCVMComposer_ { std::shared_ptr verification_key; // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; + std::shared_ptr> crs_factory_; // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; @@ -37,11 +37,10 @@ template class ECCVMComposer_ { ECCVMComposer_() requires(std::same_as) { - crs_factory_ = barretenberg::srs::get_grumpkin_crs_factory(); + crs_factory_ = bb::srs::get_grumpkin_crs_factory(); }; - explicit ECCVMComposer_( - std::shared_ptr> crs_factory) + explicit ECCVMComposer_(std::shared_ptr> crs_factory) : crs_factory_(std::move(crs_factory)) {} @@ -67,7 +66,7 @@ template class ECCVMComposer_ { CircuitConstructor& circuit_constructor, const std::shared_ptr& transcript = std::make_shared()); - void add_table_column_selector_poly_to_proving_key(barretenberg::polynomial& small, const std::string& tag); + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); void compute_commitment_key(size_t circuit_size) { diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp index 4ae39747236..7fa288957e2 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp @@ -22,9 +22,9 @@ template class ECCVMComposerTests : public ::testing::Test { void SetUp() override { if constexpr (std::is_same::value) { - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); } }; }; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp index 15bc9fa9ebd..a3dc81a67da 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp @@ -23,7 +23,7 @@ template class ECCVMProver_ { using CommitmentLabels = typename Flavor::CommitmentLabels; using Curve = typename Flavor::Curve; using Transcript = typename Flavor::Transcript; - using TranslationEvaluations = barretenberg::TranslationEvaluations; + using TranslationEvaluations = bb::TranslationEvaluations; public: explicit ECCVMProver_(const std::shared_ptr& input_key, diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index 63abcda97de..e501bc30489 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -13,9 +13,9 @@ template class ECCVMTranscriptTests : public ::testing::Test { void SetUp() override { if constexpr (std::is_same::value) { - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); } }; using FF = typename Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 6e23963e617..e23019988e8 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -4,7 +4,7 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::honk::sumcheck; namespace proof_system::honk { diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index d3971aeab0d..e7ac05b68f4 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -38,7 +38,7 @@ template class ECCVMBa using PCS = PCS_T; using FF = typename G1::subgroup_field; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; using GroupElement = typename G1::element; using Commitment = typename G1::affine_element; @@ -376,7 +376,7 @@ template class ECCVMBa /** * @brief A container for univariates used during sumcheck. */ - template using ProverUnivariates = AllEntities>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -600,7 +600,7 @@ template class ECCVMBa Commitment lookup_read_counts_1_comm; Commitment z_perm_comm; Commitment lookup_inverses_comm; - std::vector> sumcheck_univariates; + std::vector> sumcheck_univariates; std::array sumcheck_evaluations; std::vector gemini_univariate_comms; std::vector gemini_a_evals; @@ -779,7 +779,7 @@ template class ECCVMBa num_bytes_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back(BaseTranscript::template deserialize_from_buffer< - barretenberg::Univariate>( + bb::Univariate>( BaseTranscript::proof_data, num_bytes_read)); } sumcheck_evaluations = BaseTranscript::template deserialize_from_buffer>( @@ -925,7 +925,7 @@ template class ECCVMBa }; }; -class ECCVM : public ECCVMBase> {}; +class ECCVM : public ECCVMBase> {}; // NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members) diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index a8c5ac25942..e5979a6cd82 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -105,7 +105,7 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { bool contains_recursive_proof; std::vector recursive_proof_public_input_indices; - barretenberg::EvaluationDomain evaluation_domain; + bb::EvaluationDomain evaluation_domain; std::vector get_labels() const { @@ -118,7 +118,7 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials { ProvingKey_() = default; ProvingKey_(const size_t circuit_size, const size_t num_public_inputs) { - this->evaluation_domain = barretenberg::EvaluationDomain(circuit_size, circuit_size); + this->evaluation_domain = bb::EvaluationDomain(circuit_size, circuit_size); PrecomputedPolynomials::circuit_size = circuit_size; this->log_circuit_size = numeric::get_msb(circuit_size); this->num_public_inputs = num_public_inputs; diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index 07d93358de2..efed36edf11 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -45,7 +45,7 @@ TEST(Flavor, AllEntitiesSpecialMemberFunctions) using Flavor = proof_system::honk::flavor::Ultra; using FF = Flavor::FF; using PartiallyEvaluatedMultivariates = Flavor::PartiallyEvaluatedMultivariates; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; PartiallyEvaluatedMultivariates polynomials_A; auto random_poly = Polynomial(10); diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index de19c2d6bd2..97c48d97b34 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -14,7 +14,7 @@ #include #include -namespace barretenberg::detail { +namespace bb::detail { template constexpr std::size_t _va_count(Args&&... /*unused*/) { return sizeof...(Args); @@ -35,7 +35,7 @@ template auto _concatenate_base_class_get_la { return concatenate(static_cast(arg).get_labels()...); } -} // namespace barretenberg::detail +} // namespace bb::detail #define DEFINE_REF_VIEW(...) \ [[nodiscard]] auto get_all() \ @@ -59,27 +59,27 @@ template auto _concatenate_base_class_get_la DEFINE_REF_VIEW(__VA_ARGS__) \ std::vector get_labels() const \ { \ - return barretenberg::detail::split_and_trim(#__VA_ARGS__, ','); \ + return bb::detail::split_and_trim(#__VA_ARGS__, ','); \ } \ constexpr std::size_t size() const \ { \ - return barretenberg::detail::_va_count(__VA_ARGS__); \ + return bb::detail::_va_count(__VA_ARGS__); \ } #define DEFINE_COMPOUND_GET_ALL(...) \ [[nodiscard]] auto get_all() \ { \ - return barretenberg::detail::_concatenate_base_class_get_all(*this); \ + return bb::detail::_concatenate_base_class_get_all(*this); \ } \ [[nodiscard]] auto get_all() const \ { \ - return barretenberg::detail::_concatenate_base_class_get_all_const(*this); \ + return bb::detail::_concatenate_base_class_get_all_const(*this); \ } \ constexpr std::size_t size() const \ { \ - return barretenberg::detail::_sum_base_class_size(*this); \ + return bb::detail::_sum_base_class_size(*this); \ } \ std::vector get_labels() const \ { \ - return barretenberg::detail::_concatenate_base_class_get_labels(*this); \ + return bb::detail::_concatenate_base_class_get_labels(*this); \ } diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index a7bca46d6bc..6dd48112fac 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -26,7 +26,7 @@ class AvmMiniFlavor { using PCS = pcs::kzg::KZG; using FF = G1::subgroup_field; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; using GroupElement = G1::element; using Commitment = G1::affine_element; @@ -389,7 +389,7 @@ class AvmMiniFlavor { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template using ProverUnivariates = AllEntities>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -502,7 +502,7 @@ class AvmMiniFlavor { Commitment avmMini_mem_idx_c; Commitment avmMini_last; - std::vector> sumcheck_univariates; + std::vector> sumcheck_univariates; std::array sumcheck_evaluations; std::vector zm_cq_comms; Commitment zm_cq_comm; @@ -561,8 +561,8 @@ class AvmMiniFlavor { for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back( - deserialize_from_buffer>( - Transcript::proof_data, num_bytes_read)); + deserialize_from_buffer>(Transcript::proof_data, + num_bytes_read)); } sumcheck_evaluations = deserialize_from_buffer>(Transcript::proof_data, num_bytes_read); diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index 0c4ab938da0..2be19ce53c9 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -27,7 +27,7 @@ class ToyFlavor { using PCS = pcs::kzg::KZG; using FF = G1::subgroup_field; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; using GroupElement = G1::element; using Commitment = G1::affine_element; @@ -211,7 +211,7 @@ class ToyFlavor { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template using ProverUnivariates = AllEntities>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -278,7 +278,7 @@ class ToyFlavor { Commitment lookup_xor; Commitment lookup_xor_counts; - std::vector> sumcheck_univariates; + std::vector> sumcheck_univariates; std::array sumcheck_evaluations; std::vector zm_cq_comms; Commitment zm_cq_comm; @@ -315,8 +315,8 @@ class ToyFlavor { for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.emplace_back( - deserialize_from_buffer>( - Transcript::proof_data, num_bytes_read)); + deserialize_from_buffer>(Transcript::proof_data, + num_bytes_read)); } sumcheck_evaluations = deserialize_from_buffer>(Transcript::proof_data, num_bytes_read); diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 8f7fb7edad8..d8c27e69b47 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -32,7 +32,7 @@ class GoblinTranslator { using VerifierCommitmentKey = pcs::VerifierCommitmentKey; using FF = Curve::ScalarField; using BF = Curve::BaseField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; using RelationSeparator = FF; @@ -1007,7 +1007,7 @@ class GoblinTranslator { /** * @brief A container for univariates used during sumcheck. */ - template using ProverUnivariates = AllEntities>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index eb491ef0445..fd21c504a78 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -30,7 +30,7 @@ class GoblinUltra { using Commitment = Curve::AffineElement; using CommitmentHandle = Curve::AffineElement; using PCS = pcs::kzg::KZG; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; using CommitmentKey = pcs::CommitmentKey; using VerifierCommitmentKey = pcs::VerifierCommitmentKey; @@ -310,7 +310,7 @@ class GoblinUltra { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template using ProverUnivariates = AllEntities>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -529,7 +529,7 @@ class GoblinUltra { Commitment w_4_comm; Commitment z_perm_comm; Commitment z_lookup_comm; - std::vector> sumcheck_univariates; + std::vector> sumcheck_univariates; std::array sumcheck_evaluations; std::vector zm_cq_comms; Commitment zm_cq_comm; @@ -569,8 +569,8 @@ class GoblinUltra { z_lookup_comm = deserialize_from_buffer(proof_data, num_bytes_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.push_back( - deserialize_from_buffer>( - proof_data, num_bytes_read)); + deserialize_from_buffer>(proof_data, + num_bytes_read)); } sumcheck_evaluations = deserialize_from_buffer>(proof_data, num_bytes_read); diff --git a/barretenberg/cpp/src/barretenberg/flavor/plonk_flavors.hpp b/barretenberg/cpp/src/barretenberg/flavor/plonk_flavors.hpp index 0335d7bd1d7..6ecbe0c90e6 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/plonk_flavors.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/plonk_flavors.hpp @@ -12,7 +12,7 @@ class Standard { using ProvingKey = plonk::proving_key; using Curve = curve::BN254; using FF = Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // Whether or not the first row of the execution trace is reserved for 0s to enable shifts static constexpr bool has_zero_row = false; @@ -24,7 +24,7 @@ class Ultra { using ProvingKey = plonk::proving_key; using Curve = curve::BN254; using FF = Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // Whether or not the first row of the execution trace is reserved for 0s to enable shifts static constexpr bool has_zero_row = false; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index de77c42235d..e2527750bf6 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -27,7 +27,7 @@ class Ultra { using Commitment = Curve::AffineElement; using CommitmentHandle = Curve::AffineElement; using PCS = pcs::kzg::KZG; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; using CommitmentKey = pcs::CommitmentKey; using VerifierCommitmentKey = pcs::VerifierCommitmentKey; @@ -348,7 +348,7 @@ class Ultra { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template using ProverUnivariates = AllEntities>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -499,7 +499,7 @@ class Ultra { Commitment w_4_comm; Commitment z_perm_comm; Commitment z_lookup_comm; - std::vector> sumcheck_univariates; + std::vector> sumcheck_univariates; std::array sumcheck_evaluations; std::vector zm_cq_comms; Commitment zm_cq_comm; @@ -553,8 +553,8 @@ class Ultra { z_lookup_comm = deserialize_from_buffer(proof_data, num_bytes_read); for (size_t i = 0; i < log_n; ++i) { sumcheck_univariates.push_back( - deserialize_from_buffer>( - proof_data, num_bytes_read)); + deserialize_from_buffer>(proof_data, + num_bytes_read)); } sumcheck_evaluations = deserialize_from_buffer>(proof_data, num_bytes_read); diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp index cf5cb15c4f6..1ed235df14b 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp @@ -18,8 +18,8 @@ class GoblinRecursionTests : public ::testing::Test { protected: static void SetUpTestSuite() { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); - barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } using Curve = curve::BN254; diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 164b29e0600..1d669484f93 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -9,7 +9,7 @@ #include "barretenberg/translator_vm/goblin_translator_composer.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" -namespace barretenberg { +namespace bb { class Goblin { using HonkProof = proof_system::plonk::proof; @@ -272,4 +272,4 @@ class Goblin { return verified; } }; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index 7bc3f7f3e6d..bd959eeea77 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -7,7 +7,7 @@ #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" -namespace barretenberg { +namespace bb { class GoblinMockCircuits { public: using Curve = curve::BN254; @@ -72,7 +72,7 @@ class GoblinMockCircuits { op_queue->set_size_data(); // Manually compute the op queue transcript commitments (which would normally be done by the merge prover) - auto crs_factory_ = barretenberg::srs::get_crs_factory(); + auto crs_factory_ = bb::srs::get_crs_factory(); auto commitment_key = CommitmentKey(op_queue->get_current_size(), crs_factory_); std::array op_queue_commitments; size_t idx = 0; @@ -126,4 +126,4 @@ class GoblinMockCircuits { pairing_points = verifier.verify_proof(kernel_input.proof); // previous kernel proof } }; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/goblin/translation_evaluations.hpp b/barretenberg/cpp/src/barretenberg/goblin/translation_evaluations.hpp index 5f5f70e2c75..6dcee0e24fd 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/translation_evaluations.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/translation_evaluations.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/ecc/curves/bn254/fq.hpp" -namespace barretenberg { +namespace bb { struct TranslationEvaluations { fq op, Px, Py, z1, z2; std::vector to_buffer() @@ -19,4 +19,4 @@ struct TranslationEvaluations { return result; } }; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp b/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp index a04606b383a..f6e1f23c034 100644 --- a/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp @@ -69,11 +69,10 @@ int main(int argc, char** argv) } } - barretenberg::srs::Manifest manifest{ - 0, 1, static_cast(subgroup_size), 0, static_cast(subgroup_size), 0, 0 - }; + bb::srs::Manifest manifest{ 0, 1, static_cast(subgroup_size), 0, static_cast(subgroup_size), + 0, 0 }; - barretenberg::srs::IO::write_transcript(&srs[0], manifest, srs_path); + bb::srs::IO::write_transcript(&srs[0], manifest, srs_path); return 0; } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp index f2247d3f6fe..53914202f43 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp @@ -40,12 +40,12 @@ void compute_logderivative_inverse(Polynomials& polynomials, auto& relation_para continue; } FF denominator = 1; - barretenberg::constexpr_for<0, READ_TERMS, 1>([&] { + bb::constexpr_for<0, READ_TERMS, 1>([&] { auto denominator_term = lookup_relation.template compute_read_term(row, relation_parameters); denominator *= denominator_term; }); - barretenberg::constexpr_for<0, WRITE_TERMS, 1>([&] { + bb::constexpr_for<0, WRITE_TERMS, 1>([&] { auto denominator_term = lookup_relation.template compute_write_term(row, relation_parameters); denominator *= denominator_term; @@ -110,16 +110,15 @@ void accumulate_logderivative_lookup_subrelation_contributions(ContainerOverSubr // The purpose of this next section is to derive individual inverse terms using `lookup_inverses` // i.e. (1 / read_term[i]) = lookup_inverse * \prod_{j /ne i} (read_term[j]) * \prod_k (write_term[k]) // (1 / write_term[i]) = lookup_inverse * \prod_j (read_term[j]) * \prod_{k ne i} (write_term[k]) - barretenberg::constexpr_for<0, READ_TERMS, 1>( + bb::constexpr_for<0, READ_TERMS, 1>( [&]() { lookup_terms[i] = lookup_relation.template compute_read_term(in, params); }); - barretenberg::constexpr_for<0, WRITE_TERMS, 1>([&]() { + bb::constexpr_for<0, WRITE_TERMS, 1>([&]() { lookup_terms[i + READ_TERMS] = lookup_relation.template compute_write_term(in, params); }); - barretenberg::constexpr_for<0, NUM_TOTAL_TERMS, 1>( - [&]() { denominator_accumulator[i] = lookup_terms[i]; }); + bb::constexpr_for<0, NUM_TOTAL_TERMS, 1>([&]() { denominator_accumulator[i] = lookup_terms[i]; }); - barretenberg::constexpr_for<0, NUM_TOTAL_TERMS - 1, 1>( + bb::constexpr_for<0, NUM_TOTAL_TERMS - 1, 1>( [&]() { denominator_accumulator[i + 1] *= denominator_accumulator[i]; }); auto inverse_accumulator = Accumulator(lookup_inverses); // denominator_accumulator[NUM_TOTAL_TERMS - 1]; @@ -140,14 +139,14 @@ void accumulate_logderivative_lookup_subrelation_contributions(ContainerOverSubr // each predicate is degree-1 // degree of relation at this point = NUM_TOTAL_TERMS + 1 - barretenberg::constexpr_for<0, READ_TERMS, 1>([&]() { + bb::constexpr_for<0, READ_TERMS, 1>([&]() { std::get<1>(accumulator) += lookup_relation.template compute_read_term_predicate(in) * denominator_accumulator[i]; }); // each predicate is degree-1, `lookup_read_counts` is degree-1 // degree of relation = NUM_TOTAL_TERMS + 2 - barretenberg::constexpr_for<0, WRITE_TERMS, 1>([&]() { + bb::constexpr_for<0, WRITE_TERMS, 1>([&]() { const auto p = lookup_relation.template compute_write_term_predicate(in); const auto lookup_read_count = lookup_relation.template lookup_read_counts(in); std::get<1>(accumulator) -= p * (denominator_accumulator[i + READ_TERMS] * lookup_read_count); @@ -216,10 +215,9 @@ void accumulate_logderivative_permutation_subrelation_contributions(ContainerOve permutation_terms[0] = permutation_relation.template compute_read_term(in, params); permutation_terms[1] = permutation_relation.template compute_write_term(in, params); - barretenberg::constexpr_for<0, NUM_TOTAL_TERMS, 1>( - [&]() { denominator_accumulator[i] = permutation_terms[i]; }); + bb::constexpr_for<0, NUM_TOTAL_TERMS, 1>([&]() { denominator_accumulator[i] = permutation_terms[i]; }); - barretenberg::constexpr_for<0, NUM_TOTAL_TERMS - 1, 1>( + bb::constexpr_for<0, NUM_TOTAL_TERMS - 1, 1>( [&]() { denominator_accumulator[i + 1] *= denominator_accumulator[i]; }); auto inverse_accumulator = Accumulator(permutation_inverses); // denominator_accumulator[NUM_TOTAL_TERMS - 1]; diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp index eb14f30c063..59572097c7e 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp @@ -148,20 +148,19 @@ void compute_permutation_grand_products(std::shared_ptr{}; - barretenberg::constexpr_for<0, NUM_RELATIONS, 1>([&]() { + bb::constexpr_for<0, NUM_RELATIONS, 1>([&]() { using PermutationRelation = typename std::tuple_element::type; // Assign the grand product polynomial to the relevant std::span member of `full_polynomials` (and its shift) // For example, for UltraPermutationRelation, this will be `full_polynomials.z_perm` // For example, for LookupRelation, this will be `full_polynomials.z_lookup` - barretenberg::Polynomial& full_polynomial = - PermutationRelation::get_grand_product_polynomial(full_polynomials); - barretenberg::Polynomial& key_polynomial = PermutationRelation::get_grand_product_polynomial(*key); + bb::Polynomial& full_polynomial = PermutationRelation::get_grand_product_polynomial(full_polynomials); + bb::Polynomial& key_polynomial = PermutationRelation::get_grand_product_polynomial(*key); full_polynomial = key_polynomial.share(); compute_permutation_grand_product( key->circuit_size, full_polynomials, relation_parameters); - barretenberg::Polynomial& full_polynomial_shift = + bb::Polynomial& full_polynomial_shift = PermutationRelation::get_shifted_grand_product_polynomial(full_polynomials); full_polynomial_shift = key_polynomial.shifted(); }); diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp index 5f5624b46d4..5a9db57c059 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp @@ -9,17 +9,17 @@ namespace fixtures { typedef crypto::schnorr::key_pair grumpkin_key_pair; struct user_context { - barretenberg::fr note_secret; + bb::fr note_secret; grumpkin_key_pair owner; grumpkin_key_pair signing_keys[2]; - barretenberg::fr alias_hash; + bb::fr alias_hash; }; -inline barretenberg::fr generate_alias_hash(std::string const& alias) +inline bb::fr generate_alias_hash(std::string const& alias) { std::vector inputv(alias.begin(), alias.end()); auto output = blake2::blake2s(inputv); - return barretenberg::fr(uint256_t(from_buffer(output.data())) >> 32); + return bb::fr(uint256_t(from_buffer(output.data())) >> 32); } inline grumpkin_key_pair create_key_pair(numeric::random::Engine* engine) @@ -33,7 +33,7 @@ inline user_context create_user_context(numeric::random::Engine* engine = nullpt { uint8_t vk[] = { 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11 }; - barretenberg::fr note_secret = barretenberg::fr::serialize_from_buffer(vk); + bb::fr note_secret = bb::fr::serialize_from_buffer(vk); auto alias_hash = generate_alias_hash("pebble"); return { note_secret, create_key_pair(engine), { create_key_pair(engine), create_key_pair(engine) }, alias_hash }; } diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp index cdf0dbeb171..2a1f4b42343 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp @@ -21,7 +21,7 @@ struct circuit_data { : num_gates(0) {} - std::shared_ptr> srs; + std::shared_ptr> srs; std::shared_ptr proving_key; std::shared_ptr verification_key; size_t num_gates; @@ -40,7 +40,7 @@ inline bool exists(std::string const& path) template circuit_data get_circuit_data(std::string const& name, std::string const& path_name, - std::shared_ptr> const& srs, + std::shared_ptr> const& srs, std::string const& key_path, bool compute, bool save, diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp index 8e1c81dc54e..f9f339d723e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp @@ -3,7 +3,7 @@ namespace join_split_example { namespace proofs { -using namespace barretenberg; +using namespace bb; inner_proof_data::inner_proof_data(std::vector const& proof_data) { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp index 803d07bd511..7bc81c657b1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp @@ -53,22 +53,22 @@ enum { struct inner_proof_data { uint256_t proof_id; - barretenberg::fr note_commitment1; - barretenberg::fr note_commitment2; + bb::fr note_commitment1; + bb::fr note_commitment2; uint256_t nullifier1; uint256_t nullifier2; uint256_t public_value; - barretenberg::fr public_owner; + bb::fr public_owner; uint256_t asset_id; - barretenberg::fr merkle_root; + bb::fr merkle_root; uint256_t tx_fee; uint256_t tx_fee_asset_id; uint256_t bridge_call_data; uint256_t defi_deposit_value; - barretenberg::fr defi_root; + bb::fr defi_root; - barretenberg::fr backward_link; + bb::fr backward_link; uint256_t allow_chain; inner_proof_data(std::vector const& proof_data); diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp index e9d90145ad0..f01df175b29 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp @@ -1,7 +1,7 @@ #include "inner_proof_data.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace join_split_example::proofs; namespace { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp index 6f0d1f952c8..5e1e8d2c1ee 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp @@ -59,8 +59,7 @@ join_split_tx noop_tx() return tx; } -circuit_data get_circuit_data(std::shared_ptr> const& srs, - bool mock) +circuit_data get_circuit_data(std::shared_ptr> const& srs, bool mock) { std::cerr << "Getting join-split circuit data..." << std::endl; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.hpp index 459fc36a9dd..a2cce6cf20d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.hpp @@ -10,7 +10,7 @@ join_split_tx noop_tx(); using circuit_data = proofs::circuit_data; -circuit_data get_circuit_data(std::shared_ptr> const& srs, +circuit_data get_circuit_data(std::shared_ptr> const& srs, bool mock = false); } // namespace join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp index 2ae243dff27..4efcd5323dc 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp @@ -8,7 +8,7 @@ namespace join_split { using namespace notes::native; -barretenberg::fr compute_signing_data(join_split_tx const& tx) +bb::fr compute_signing_data(join_split_tx const& tx) { auto proof_id = tx.proof_id; auto is_deposit = proof_id == ProofIds::DEPOSIT; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp index 51cb6df0ae5..6a6836220dd 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp @@ -5,7 +5,7 @@ namespace join_split_example { namespace proofs { namespace join_split { -barretenberg::fr compute_signing_data(join_split_tx const& tx); +bb::fr compute_signing_data(join_split_tx const& tx); } // namespace join_split } // namespace proofs diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp index 48a169b17bd..69909b43d2e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp @@ -25,7 +25,7 @@ constexpr bool CIRCUIT_CHANGE_EXPECTED = false; constexpr bool CIRCUIT_CHANGE_EXPECTED = false; #endif -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; using namespace proof_system::plonk::stdlib::merkle_tree; using namespace join_split_example::proofs::notes::native; @@ -43,10 +43,9 @@ class join_split_tests : public ::testing::Test { static constexpr size_t ACCOUNT_INDEX = 14; static void SetUpTestCase() { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); init_proving_key(false); - auto crs_factory = - std::make_unique>("../srs_db/ignition"); + auto crs_factory = std::make_unique>("../srs_db/ignition"); init_verification_key(); info("vk hash: ", get_verification_key()->sha256_hash()); } @@ -901,7 +900,7 @@ void assign_backward_link(join_split_tx& tx, size_t& indicator) tx.backward_link = tx.input_note[1].commit(); break; default: - tx.backward_link = barretenberg::fr::random_element(); + tx.backward_link = bb::fr::random_element(); } } diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp index ba601d93447..b6a9734e264 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp @@ -12,7 +12,7 @@ namespace join_split_example { namespace proofs { namespace join_split { -using namespace barretenberg; +using namespace bb; // using namespace proof_system::plonk::stdlib::types; using namespace proof_system::plonk::stdlib::merkle_tree; using namespace join_split_example::proofs::notes::native; @@ -67,13 +67,13 @@ TEST_F(join_split_js_parity_tests, test_full_proof) 0x0b, 0x9b, 0x3a, 0xde, 0xe6, 0xb3, 0xd8, 0x1b, 0x28, 0xa0, 0x88, 0x6b, 0x2a, 0x84, 0x15, 0xc7, 0xda, 0x31, 0x29, 0x1a, 0x5e, 0x96, 0xbb, 0x7a, 0x56, 0x63, 0x9e, 0x17, 0x7d, 0x30, 0x1b, 0xeb }); auto public_key = grumpkin::g1::one * private_key; - auto note_secret = from_buffer(std::vector{ + auto note_secret = from_buffer(std::vector{ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11 }); - auto input_nullifier1 = from_buffer(std::vector{ + auto input_nullifier1 = from_buffer(std::vector{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }); - auto input_nullifier2 = from_buffer(std::vector{ + auto input_nullifier2 = from_buffer(std::vector{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }); diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp index 03cd1b0fe0a..d1543e0123f 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp @@ -5,7 +5,7 @@ namespace join_split_example { namespace proofs { namespace join_split { -using namespace barretenberg; +using namespace bb; void write(std::vector& buf, join_split_tx const& tx) { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp index e0c0620d309..99be198d910 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp @@ -12,11 +12,11 @@ namespace join_split { struct join_split_tx { uint32_t proof_id; uint256_t public_value; - barretenberg::fr public_owner; + bb::fr public_owner; uint32_t asset_id; uint32_t num_input_notes; std::array input_index; - barretenberg::fr old_data_root; + bb::fr old_data_root; std::array input_path; std::array input_note; std::array output_note; @@ -24,14 +24,14 @@ struct join_split_tx { notes::native::claim::partial_claim_note_data partial_claim_note; grumpkin::fr account_private_key; - barretenberg::fr alias_hash; + bb::fr alias_hash; bool account_required; uint32_t account_note_index; proof_system::plonk::stdlib::merkle_tree::fr_hash_path account_note_path; grumpkin::g1::affine_element signing_pub_key; - barretenberg::fr backward_link; // 0: no link, otherwise: any commitment. - uint32_t allow_chain; // 0: none, 1: output_note1, 2: output_note2 + bb::fr backward_link; // 0: no link, otherwise: any commitment. + uint32_t allow_chain; // 0: none, 1: output_note1, 2: output_note2 crypto::schnorr::signature signature; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp index a671dc164b1..0c3c90bd9fd 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp @@ -10,7 +10,7 @@ #include #include -using namespace barretenberg; +using namespace bb; using namespace join_split_example::proofs::join_split; namespace { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp index 97ba9abbfac..23e65d902aa 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp @@ -8,7 +8,7 @@ namespace mock { using namespace proof_system::plonk; -template void mock_circuit(Builder& builder, std::vector const& public_inputs_) +template void mock_circuit(Builder& builder, std::vector const& public_inputs_) { const auto public_inputs = map(public_inputs_, [&](auto& i) { return stdlib::field_t(stdlib::witness_t(&builder, i)); }); diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp index dfdc491c981..89a768d17f6 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.test.cpp @@ -11,7 +11,7 @@ namespace mock { class MockCircuitTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; TEST_F(MockCircuitTests, test_simple_circuit) diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp index 22ce20ba9af..440cd424415 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp @@ -4,7 +4,7 @@ namespace join_split_example::proofs::notes::circuit { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; field_ct compute_nullifier(field_ct const& note_commitment, diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp index ec813ad8dff..d73431384e2 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp @@ -6,14 +6,14 @@ #include namespace join_split_example { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; using namespace join_split_example::proofs::notes; using namespace join_split_example::proofs::notes::circuit::value; class ValueNote : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; TEST_F(ValueNote, Commits) diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp index db5113cf897..24f19552897 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp @@ -4,9 +4,7 @@ namespace join_split_example::proofs::notes::native::account { -grumpkin::fq generate_account_commitment(const barretenberg::fr& alias_hash, - const barretenberg::fr& owner_x, - const barretenberg::fr& signing_x) +grumpkin::fq generate_account_commitment(const bb::fr& alias_hash, const bb::fr& owner_x, const bb::fr& signing_x) { return crypto::pedersen_hash::hash({ alias_hash, owner_x, signing_x }, GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); } diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp index 33ac735f780..25674ca4876 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp @@ -9,12 +9,10 @@ namespace notes { namespace native { namespace account { -grumpkin::fq generate_account_commitment(const barretenberg::fr& alias_hash, - const barretenberg::fr& owner_x, - const barretenberg::fr& signing_x); +grumpkin::fq generate_account_commitment(const bb::fr& alias_hash, const bb::fr& owner_x, const bb::fr& signing_x); struct account_note { - barretenberg::fr alias_hash; + bb::fr alias_hash; grumpkin::g1::affine_element owner_key; grumpkin::g1::affine_element signing_key; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp index 236f8e76c92..0dbcdcfac8f 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp @@ -5,7 +5,7 @@ namespace join_split_example::proofs::notes::native::account { -using fr = barretenberg::fr; +using fr = bb::fr; inline fr compute_account_alias_hash_nullifier(fr const& alias_hash) { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp index 43808ae7ea1..d2bdc842f84 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp @@ -5,7 +5,7 @@ namespace join_split_example::proofs::notes::native::account { -using namespace barretenberg; +using namespace bb; inline fr compute_account_public_key_nullifier(grumpkin::g1::affine_element const& public_key) { diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp index c37fac0763f..f15bc431e20 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp @@ -14,7 +14,7 @@ struct partial_claim_note_data { uint256_t deposit_value; uint256_t bridge_call_data; uint256_t note_secret; - barretenberg::fr input_nullifier; + bb::fr input_nullifier; bool operator==(partial_claim_note_data const&) const = default; }; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp index e1720039a0c..827690d6f6d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp @@ -6,7 +6,7 @@ namespace join_split_example::proofs::notes::native { -using namespace barretenberg; +using namespace bb; /** * Computes a nullifier for a _value_ note @@ -18,7 +18,7 @@ fr compute_nullifier(grumpkin::fq const& note_commitment, auto hashed_pk = crypto::pedersen_commitment::commit_native( { fr(account_private_key) }, GeneratorIndex::JOIN_SPLIT_NULLIFIER_ACCOUNT_PRIVATE_KEY); - std::vector buf{ + std::vector buf{ note_commitment, hashed_pk.x, hashed_pk.y, diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp index 4d380e2992f..66f913d263d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp @@ -6,9 +6,9 @@ namespace proofs { namespace notes { namespace native { -barretenberg::fr compute_nullifier(grumpkin::fq const& note_commitment, - grumpkin::fr const& account_private_key, - const bool is_note_in_use); +bb::fr compute_nullifier(grumpkin::fq const& note_commitment, + grumpkin::fr const& account_private_key, + const bool is_note_in_use); } // namespace native } // namespace notes diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp index 320b1e33b71..56829f92006 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp @@ -6,10 +6,10 @@ namespace join_split_example::proofs::notes::native::value { -inline auto create_partial_commitment(barretenberg::fr const& secret, +inline auto create_partial_commitment(bb::fr const& secret, grumpkin::g1::affine_element const& owner, bool account_required, - barretenberg::fr const& creator_pubkey) + bb::fr const& creator_pubkey) { return crypto::pedersen_hash::hash({ secret, owner.x, owner.y, account_required, creator_pubkey }, GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp index fc5fb4dc5ff..4010f060f84 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp @@ -11,16 +11,16 @@ namespace notes { namespace native { namespace value { -using namespace barretenberg; +using namespace bb; struct value_note { uint256_t value; uint32_t asset_id; bool account_required; grumpkin::g1::affine_element owner; - barretenberg::fr secret; - barretenberg::fr creator_pubkey; - barretenberg::fr input_nullifier; + bb::fr secret; + bb::fr creator_pubkey; + bb::fr input_nullifier; bool operator==(value_note const&) const = default; diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp index d79d42d1565..f73a8598d0e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp @@ -27,16 +27,16 @@ template struct verify_result { template inline bool pairing_check(plonk::stdlib::recursion::aggregation_state> aggregation_state, - std::shared_ptr const& srs) + std::shared_ptr const& srs) { g1::affine_element P[2]; - P[0].x = barretenberg::fq(aggregation_state.P0.x.get_value().lo); - P[0].y = barretenberg::fq(aggregation_state.P0.y.get_value().lo); - P[1].x = barretenberg::fq(aggregation_state.P1.x.get_value().lo); - P[1].y = barretenberg::fq(aggregation_state.P1.y.get_value().lo); - barretenberg::fq12 inner_proof_result = - barretenberg::pairing::reduced_ate_pairing_batch_precomputed(P, srs->get_precomputed_g2_lines(), 2); - return inner_proof_result == barretenberg::fq12::one(); + P[0].x = bb::fq(aggregation_state.P0.x.get_value().lo); + P[0].y = bb::fq(aggregation_state.P0.y.get_value().lo); + P[1].x = bb::fq(aggregation_state.P1.x.get_value().lo); + P[1].y = bb::fq(aggregation_state.P1.y.get_value().lo); + bb::fq12 inner_proof_result = + bb::pairing::reduced_ate_pairing_batch_precomputed(P, srs->get_precomputed_g2_lines(), 2); + return inner_proof_result == bb::fq12::one(); } template diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp index f4b1f80e17b..32e5cc6da5f 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp @@ -67,27 +67,27 @@ TEST(uintx, DivAndMod) TEST(uintx, DISABLEDMulmod) { /* - barretenberg::fq a = barretenberg::fq::random_element(); - barretenberg::fq b = barretenberg::fq::random_element(); - // barretenberg::fq a_converted = a.from_montgomery_form(); - // barretenberg::fq b_converted = b.from_montgomery_form(); + bb::fq a = bb::fq::random_element(); + bb::fq b = bb::fq::random_element(); + // bb::fq a_converted = a.from_montgomery_form(); + // bb::fq b_converted = b.from_montgomery_form(); uint256_t a_uint = uint256_t(a); // { a_converted.data[0], a_converted.data[1], a_converted.data[2], a_converted.data[3] }; uint256_t b_uint = uint256_t(b); // { b_converted.data[0], b_converted.data[1], b_converted.data[2], b_converted.data[3] }; - uint256_t modulus_uint{ barretenberg::Bn254FqParams::modulus_0, - barretenberg::Bn254FqParams::modulus_1, - barretenberg::Bn254FqParams::modulus_2, - barretenberg::Bn254FqParams::modulus_3 }; + uint256_t modulus_uint{ bb::Bn254FqParams::modulus_0, + bb::Bn254FqParams::modulus_1, + bb::Bn254FqParams::modulus_2, + bb::Bn254FqParams::modulus_3 }; uint1024_t a_uintx = uint1024_t(uint512_t(a_uint)); uint1024_t b_uintx = uint1024_t(uint512_t(b_uint)); uint1024_t modulus_uintx = uint1024_t(uint512_t(modulus_uint)); const auto [quotient, remainder] = (a_uintx * b_uintx).divmod(modulus_uintx); - // barretenberg::fq expected_a = a_converted.to_montgomery_form(); - // barretenberg::fq expected_b = b_converted.to_montgomery_form(); - barretenberg::fq expected = (a * b).from_montgomery_form(); + // bb::fq expected_a = a_converted.to_montgomery_form(); + // bb::fq expected_b = b_converted.to_montgomery_form(); + bb::fq expected = (a * b).from_montgomery_form(); EXPECT_EQ(remainder.lo.lo.data[0], expected.data[0]); EXPECT_EQ(remainder.lo.lo.data[1], expected.data[1]); diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp index 086636797b0..7adf8861e95 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp @@ -22,12 +22,12 @@ void compute_monomial_and_coset_selector_forms(plonk::proving_key* circuit_provi // Compute monomial form of selector polynomial auto selector_poly_lagrange = circuit_proving_key->polynomial_store.get(selector_properties[i].name + "_lagrange"); - barretenberg::polynomial selector_poly(circuit_proving_key->circuit_size); - barretenberg::polynomial_arithmetic::ifft( + bb::polynomial selector_poly(circuit_proving_key->circuit_size); + bb::polynomial_arithmetic::ifft( &selector_poly_lagrange[0], &selector_poly[0], circuit_proving_key->small_domain); // Compute coset FFT of selector polynomial - barretenberg::polynomial selector_poly_fft(selector_poly, circuit_proving_key->circuit_size * 4 + 4); + bb::polynomial selector_poly_fft(selector_poly, circuit_proving_key->circuit_size * 4 + 4); selector_poly_fft.coset_fft(circuit_proving_key->large_domain); // Note: For Standard, the lagrange polynomials could be removed from the store at this point but this @@ -45,7 +45,7 @@ void compute_monomial_and_coset_selector_forms(plonk::proving_key* circuit_provi std::shared_ptr compute_verification_key_common( std::shared_ptr const& proving_key, // Here too - std::shared_ptr> const& vrs) + std::shared_ptr> const& vrs) { auto circuit_verification_key = std::make_shared( proving_key->circuit_size, proving_key->num_public_inputs, vrs, proving_key->circuit_type); diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp index 4958e940df7..74b060cfaeb 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp @@ -21,12 +21,11 @@ struct SelectorProperties { * in that case. * @return std::shared_ptr */ -std::shared_ptr initialize_proving_key( - const auto& circuit_constructor, - barretenberg::srs::factories::CrsFactory* crs_factory, - const size_t minimum_circuit_size, - const size_t num_randomized_gates, - CircuitType circuit_type) +std::shared_ptr initialize_proving_key(const auto& circuit_constructor, + bb::srs::factories::CrsFactory* crs_factory, + const size_t minimum_circuit_size, + const size_t num_randomized_gates, + CircuitType circuit_type) { const size_t num_gates = circuit_constructor.num_gates; @@ -80,6 +79,6 @@ void compute_monomial_and_coset_selector_forms(plonk::proving_key* key, std::shared_ptr compute_verification_key_common( std::shared_ptr const& proving_key, // silencing for now but need to figure out where to extract type of VerifierCrs from :-/ - std::shared_ptr> const& vrs); + std::shared_ptr> const& vrs); } // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp index b2da0704e9e..836da4eba12 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.hpp @@ -24,16 +24,16 @@ class StandardComposer { std::shared_ptr circuit_verification_key; // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; + std::shared_ptr> crs_factory_; bool computed_witness = false; - StandardComposer() { crs_factory_ = barretenberg::srs::get_crs_factory(); } - StandardComposer(std::shared_ptr> crs_factory) + StandardComposer() { crs_factory_ = bb::srs::get_crs_factory(); } + StandardComposer(std::shared_ptr> crs_factory) : crs_factory_(std::move(crs_factory)) {} - StandardComposer(std::unique_ptr>&& crs_factory) + StandardComposer(std::unique_ptr>&& crs_factory) : crs_factory_(std::move(crs_factory)) {} StandardComposer(std::shared_ptr p_key, std::shared_ptr v_key) diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp index 6b745b34c23..4e02ca4e689 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp @@ -5,7 +5,7 @@ #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system; using namespace proof_system::plonk; @@ -15,7 +15,7 @@ auto& engine = numeric::random::get_debug_engine(); class StandardPlonkComposer : public ::testing::Test { public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; TEST_F(StandardPlonkComposer, BaseCase) @@ -45,7 +45,7 @@ TEST_F(StandardPlonkComposer, ComposerFromSerializedKeys) auto pk_data = from_buffer(pk_buf); auto vk_data = from_buffer(vk_buf); - auto crs = std::make_unique>("../srs_db/ignition"); + auto crs = std::make_unique>("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); auto verification_key = std::make_shared(std::move(vk_data), crs->get_verifier_crs()); diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp index f5fd968ca36..81b6eabdcc3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp @@ -9,7 +9,7 @@ #include "barretenberg/proof_system/plookup_tables/sha256.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; using namespace proof_system::plonk; @@ -33,7 +33,7 @@ std::vector add_variables(UltraCircuitBuilder& builder, std::vector class ultra_plonk_composer : public ::testing::Test { public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } void prove_and_verify(UltraCircuitBuilder& builder, UltraComposer& composer, bool expected_result) { @@ -69,7 +69,7 @@ TYPED_TEST(ultra_plonk_composer, create_gates_from_plookup_accumulators) auto circuit_builder = proof_system::UltraCircuitBuilder(); auto composer = UltraComposer(); - barretenberg::fr input_value = fr::random_element(); + bb::fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -154,9 +154,9 @@ TYPED_TEST(ultra_plonk_composer, test_elliptic_gate) auto builder = UltraCircuitBuilder(); auto composer = UltraComposer(); - affine_element p1 = crypto::pedersen_commitment::commit_native({ barretenberg::fr(1) }, 0); + affine_element p1 = crypto::pedersen_commitment::commit_native({ bb::fr(1) }, 0); - affine_element p2 = crypto::pedersen_commitment::commit_native({ barretenberg::fr(1) }, 1); + affine_element p2 = crypto::pedersen_commitment::commit_native({ bb::fr(1) }, 1); ; affine_element p3(element(p1) + element(p2)); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp index 1d76401514e..d113e597f43 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.hpp @@ -9,7 +9,7 @@ namespace proof_system::plonk { class CommitmentScheme { public: - using fr = barretenberg::fr; + using fr = bb::fr; // Constructors for CommitmentScheme CommitmentScheme() {} diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp index 453fc6c5678..0ed872d19b3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp @@ -14,7 +14,7 @@ #include "barretenberg/ecc/curves/bn254/fq12.hpp" #include "barretenberg/ecc/curves/bn254/pairing.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; TEST(commitment_scheme, kate_open) @@ -35,9 +35,9 @@ TEST(commitment_scheme, kate_open) transcript::StandardTranscript inp_tx = transcript::StandardTranscript(transcript::Manifest()); plonk::KateCommitmentScheme newKate; - // std::shared_ptr> crs_factory = (new + // std::shared_ptr> crs_factory = (new // FileReferenceStringFactory("../srs_db/ignition")); - auto file_crs = std::make_shared>("../srs_db/ignition"); + auto file_crs = std::make_shared>("../srs_db/ignition"); auto crs = file_crs->get_prover_crs(n); auto circuit_proving_key = std::make_shared(n, 0, crs, CircuitType::STANDARD); work_queue queue(circuit_proving_key.get(), &inp_tx); @@ -94,7 +94,7 @@ TEST(commitment_scheme, kate_batch_open) transcript::StandardTranscript inp_tx = transcript::StandardTranscript(transcript::Manifest()); plonk::KateCommitmentScheme newKate; - auto file_crs = std::make_shared>("../srs_db/ignition"); + auto file_crs = std::make_shared>("../srs_db/ignition"); auto crs = file_crs->get_prover_crs(n); auto circuit_proving_key = std::make_shared(n, 0, crs, CircuitType::STANDARD); work_queue queue(circuit_proving_key.get(), &inp_tx); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/kate_commitment_scheme.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/kate_commitment_scheme.cpp index 46a0507a52d..4c905d4c0a3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/kate_commitment_scheme.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/kate_commitment_scheme.cpp @@ -322,7 +322,7 @@ void KateCommitmentScheme::batch_verify(const transcript::StandardTran } const auto zeta = transcript.get_challenge_field_element("z"); - barretenberg::fr quotient_challenge = transcript.get_challenge_field_element_from_map("nu", "t"); + bb::fr quotient_challenge = transcript.get_challenge_field_element_from_map("nu", "t"); // append the commitments to the parts of quotient polynomial and their scalar multiplicands fr z_pow_n = zeta.pow(input_key->circuit_size); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.cpp index 227a0679197..9a6588f2716 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.cpp @@ -7,7 +7,7 @@ #include "barretenberg/polynomials/polynomial_arithmetic.hpp" #include -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { @@ -303,8 +303,8 @@ template void ProverBase::execute_second_round() } // compute poly w_4 from w_4_lagrange and add it to the cache - barretenberg::polynomial w_4(key->circuit_size); - barretenberg::polynomial_arithmetic::copy_polynomial(&w_4_lagrange[0], &w_4[0], circuit_size, circuit_size); + bb::polynomial w_4(key->circuit_size); + bb::polynomial_arithmetic::copy_polynomial(&w_4_lagrange[0], &w_4[0], circuit_size, circuit_size); w_4.ifft(key->small_domain); key->polynomial_store.put(wire_tag, std::move(w_4)); key->polynomial_store.put(wire_tag + "_lagrange", std::move(w_4_lagrange)); @@ -346,7 +346,7 @@ template void ProverBase::execute_third_round() .work_type = work_queue::WorkType::FFT, .mul_scalars = nullptr, .tag = wire_tag, - .constant = barretenberg::fr(0), + .constant = bb::fr(0), .index = 0, }); } @@ -382,7 +382,7 @@ template void ProverBase::execute_fourth_round() quotient_poly_parts.push_back(&key->quotient_polynomial_parts[1][0]); quotient_poly_parts.push_back(&key->quotient_polynomial_parts[2][0]); quotient_poly_parts.push_back(&key->quotient_polynomial_parts[3][0]); - barretenberg::polynomial_arithmetic::divide_by_pseudo_vanishing_polynomial( + bb::polynomial_arithmetic::divide_by_pseudo_vanishing_polynomial( quotient_poly_parts, key->small_domain, key->large_domain); polynomial_arithmetic::coset_ifft(quotient_poly_parts, key->large_domain); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp index 6e504df5e89..a3737731055 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.hpp @@ -47,7 +47,7 @@ template class ProverBase { work_queue::work_item_info get_queued_work_item_info() const { return queue.get_queued_work_item_info(); } - std::shared_ptr get_scalar_multiplication_data(const size_t work_item_number) const + std::shared_ptr get_scalar_multiplication_data(const size_t work_item_number) const { return queue.get_scalar_multiplication_data(work_item_number); } @@ -67,7 +67,7 @@ template class ProverBase { return queue.get_fft_data(work_item_number); } - void put_scalar_multiplication_data(const barretenberg::g1::affine_element result, const size_t work_item_number) + void put_scalar_multiplication_data(const bb::g1::affine_element result, const size_t work_item_number) { queue.put_scalar_multiplication_data(result, work_item_number); } @@ -87,7 +87,7 @@ template class ProverBase { size_t circuit_size; std::vector> random_widgets; - std::vector>> transition_widgets; + std::vector>> transition_widgets; transcript::StandardTranscript transcript; std::shared_ptr key; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp index 23a5439649d..e7e4214cd12 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp @@ -65,7 +65,7 @@ sigma_2 = [21, 3, 2, 22, 17, 20, 34, 7, 38, 26, 27, 28, 29, 30, 31, 32] sigma_3 = [39, 23, 4, 40, 41, 25, 33, 36, 37, 42, 43, 44, 45, 46, 47, 48] ``` */ -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace prover_helpers { @@ -114,7 +114,7 @@ plonk::Prover generate_test_data(const size_t n) // even indices = mul gates, odd incides = add gates auto reference_string = - std::make_shared>(n + 1, "../srs_db/ignition"); + std::make_shared>(n + 1, "../srs_db/ignition"); std::shared_ptr key = std::make_shared(n, 0, reference_string, CircuitType::STANDARD); polynomial w_l(n); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp index b4c2d30c1a8..37785c62f6f 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.cpp @@ -24,7 +24,7 @@ namespace proof_system::plonk { * */ proving_key::proving_key(const size_t num_gates, const size_t num_inputs, - std::shared_ptr> const& crs, + std::shared_ptr> const& crs, CircuitType type) : circuit_type(type) , circuit_size(num_gates) @@ -45,7 +45,7 @@ proving_key::proving_key(const size_t num_gates, * @param crs */ proving_key::proving_key(proving_key_data&& data, - std::shared_ptr> const& crs) + std::shared_ptr> const& crs) : circuit_type(static_cast(data.circuit_type)) , circuit_size(data.circuit_size) , num_public_inputs(data.num_public_inputs) @@ -77,15 +77,15 @@ void proving_key::init() } // t_i for i = 1,2,3 have n+1 coefficients after blinding. t_4 has only n coefficients. - quotient_polynomial_parts[0] = barretenberg::polynomial(circuit_size + 1); - quotient_polynomial_parts[1] = barretenberg::polynomial(circuit_size + 1); - quotient_polynomial_parts[2] = barretenberg::polynomial(circuit_size + 1); - quotient_polynomial_parts[3] = barretenberg::polynomial(circuit_size); + quotient_polynomial_parts[0] = bb::polynomial(circuit_size + 1); + quotient_polynomial_parts[1] = bb::polynomial(circuit_size + 1); + quotient_polynomial_parts[2] = bb::polynomial(circuit_size + 1); + quotient_polynomial_parts[3] = bb::polynomial(circuit_size); - memset((void*)"ient_polynomial_parts[0][0], 0x00, sizeof(barretenberg::fr) * (circuit_size + 1)); - memset((void*)"ient_polynomial_parts[1][0], 0x00, sizeof(barretenberg::fr) * (circuit_size + 1)); - memset((void*)"ient_polynomial_parts[2][0], 0x00, sizeof(barretenberg::fr) * (circuit_size + 1)); - memset((void*)"ient_polynomial_parts[3][0], 0x00, sizeof(barretenberg::fr) * circuit_size); + memset((void*)"ient_polynomial_parts[0][0], 0x00, sizeof(bb::fr) * (circuit_size + 1)); + memset((void*)"ient_polynomial_parts[1][0], 0x00, sizeof(bb::fr) * (circuit_size + 1)); + memset((void*)"ient_polynomial_parts[2][0], 0x00, sizeof(bb::fr) * (circuit_size + 1)); + memset((void*)"ient_polynomial_parts[3][0], 0x00, sizeof(bb::fr) * circuit_size); } } // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp index a9868065846..1c851bd3386 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp @@ -29,9 +29,9 @@ struct proving_key_data { std::vector memory_write_records; #ifdef __wasm__ PolynomialStoreCache polynomial_store; - // PolynomialStoreWasm polynomial_store; + // PolynomialStoreWasm polynomial_store; #else - PolynomialStore polynomial_store; + PolynomialStore polynomial_store; #endif }; @@ -43,12 +43,11 @@ struct proving_key { RELATIVE_LOOKUP, }; - proving_key(proving_key_data&& data, - std::shared_ptr> const& crs); + proving_key(proving_key_data&& data, std::shared_ptr> const& crs); proving_key(const size_t num_gates, const size_t num_inputs, - std::shared_ptr> const& crs, + std::shared_ptr> const& crs, CircuitType type = CircuitType::UNDEFINED); proving_key(std::ostream& is, std::string const& crs_path); @@ -66,19 +65,19 @@ struct proving_key { #ifdef __wasm__ PolynomialStoreCache polynomial_store; - // PolynomialStoreWasm polynomial_store; + // PolynomialStoreWasm polynomial_store; #else - PolynomialStore polynomial_store; + PolynomialStore polynomial_store; #endif - barretenberg::evaluation_domain small_domain; - barretenberg::evaluation_domain large_domain; + bb::evaluation_domain small_domain; + bb::evaluation_domain large_domain; // The reference_string object contains the monomial SRS. We can access it using: // Monomial SRS: reference_string->get_monomial_points() - std::shared_ptr> reference_string; + std::shared_ptr> reference_string; - barretenberg::polynomial quotient_polynomial_parts[plonk::NUM_QUOTIENT_PARTS]; + bb::polynomial quotient_polynomial_parts[plonk::NUM_QUOTIENT_PARTS]; PolynomialManifest polynomial_manifest; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp index e9eb43581c8..47a2ba92eb3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp @@ -11,7 +11,7 @@ #include #endif -using namespace barretenberg; +using namespace bb; using namespace proof_system; using namespace proof_system::plonk; @@ -26,7 +26,7 @@ TEST(proving_key, proving_key_from_serialized_key) plonk::proving_key& p_key = *composer.compute_proving_key(builder); auto pk_buf = to_buffer(p_key); auto pk_data = from_buffer(pk_buf); - auto crs = std::make_unique>("../srs_db/ignition"); + auto crs = std::make_unique>("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); @@ -63,7 +63,7 @@ TEST(proving_key, proving_key_from_serialized_key_ultra) plonk::proving_key& p_key = *composer.compute_proving_key(builder); auto pk_buf = to_buffer(p_key); auto pk_data = from_buffer(pk_buf); - auto crs = std::make_unique>("../srs_db/ignition"); + auto crs = std::make_unique>("../srs_db/ignition"); auto proving_key = std::make_shared(std::move(pk_data), crs->get_prover_crs(pk_data.circuit_size + 1)); @@ -141,8 +141,8 @@ StandardComposer(); fr a = fr::one(); builder.add_public_variable(a); bool all_polys_are_equal{ true }; for (size_t i = 0; i < precomputed_poly_list.size(); ++i) { std::string poly_id = precomputed_poly_list[i]; - barretenberg::polynomial& input_poly = p_key.polynomial_store.get(poly_id); - barretenberg::polynomial& output_poly = pk_data.polynomial_store.get(poly_id); + bb::polynomial& input_poly = p_key.polynomial_store.get(poly_id); + bb::polynomial& output_poly = pk_data.polynomial_store.get(poly_id); all_polys_are_equal = all_polys_are_equal && (input_poly == output_poly); } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/serialize.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/serialize.hpp index a434d00deea..06ab405c168 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/serialize.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/serialize.hpp @@ -25,7 +25,7 @@ template inline void read(B& any, proving_key_data& key) for (size_t next = 0; next < amount; ++next) { std::string label; - barretenberg::polynomial value; + bb::polynomial value; read(any, label); read(any, value); @@ -54,7 +54,7 @@ template inline void write(B& buf, proving_key const& key) for (size_t i = 0; i < num_polys; ++i) { std::string poly_id = precomputed_poly_list[i]; - const barretenberg::polynomial& value = ((proving_key&)key).polynomial_store.get(poly_id); + const bb::polynomial& value = ((proving_key&)key).polynomial_store.get(poly_id); write(buf, poly_id); write(buf, value); } @@ -87,7 +87,7 @@ template inline void read_from_file(B& is, std::string const& path, } size_t file_size = (size_t)st.st_size; size_t num_fields = file_size / 32; - barretenberg::polynomial value(num_fields); + bb::polynomial value(num_fields); // Open the file and read the data directly into the polynomial memory. std::ifstream file(filepath, std::ios::binary); @@ -127,7 +127,7 @@ template inline void write_to_file(B& os, std::string const& path, auto value = key.polynomial_store.get(poly_id); auto size = value.size(); std::ofstream ofs(filename); - ofs.write((char*)value.data().get(), (std::streamsize)(size * sizeof(barretenberg::fr))); + ofs.write((char*)value.data().get(), (std::streamsize)(size * sizeof(bb::fr))); if (!ofs.good()) { throw_or_abort(format("Failed to write: ", filename)); } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp index abb62a778f8..01165997896 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/polynomials/evaluation_domain.hpp" #include -using namespace barretenberg; +using namespace bb; /* ``` @@ -60,7 +60,7 @@ sigma_2 = [21, 3, 2, 22, 17, 20, 34, 7, 38, 26, 27, 28, 29, 30, 31, 32] sigma_3 = [39, 23, 4, 40, 41, 25, 33, 36, 37, 42, 43, 44, 45, 46, 47, 48] ``` */ -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/program_settings.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/program_settings.hpp index 1b849b49a8d..190a1c28944 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/program_settings.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/program_settings.hpp @@ -17,8 +17,8 @@ namespace proof_system::plonk { class standard_verifier_settings : public standard_settings { public: - typedef barretenberg::fr fr; - typedef barretenberg::g1 g1; + typedef bb::fr fr; + typedef bb::g1 g1; typedef transcript::StandardTranscript Transcript; typedef VerifierArithmeticWidget ArithmeticWidget; typedef VerifierPermutationWidget PermutationWidget; @@ -37,18 +37,14 @@ class standard_verifier_settings : public standard_settings { return ArithmeticWidget::append_scalar_multiplication_inputs(key, updated_alpha, transcript, scalars); } - static barretenberg::fr compute_quotient_evaluation_contribution(verification_key* key, - const barretenberg::fr& alpha_base, - const transcript::StandardTranscript& transcript, - barretenberg::fr& quotient_numerator_eval) + static bb::fr compute_quotient_evaluation_contribution(verification_key* key, + const bb::fr& alpha_base, + const transcript::StandardTranscript& transcript, + bb::fr& quotient_numerator_eval) { - auto updated_alpha_base = VerifierPermutationWidget< - barretenberg::fr, - barretenberg::g1::affine_element, - transcript::StandardTranscript>::compute_quotient_evaluation_contribution(key, - alpha_base, - transcript, - quotient_numerator_eval); + auto updated_alpha_base = + VerifierPermutationWidget:: + compute_quotient_evaluation_contribution(key, alpha_base, transcript, quotient_numerator_eval); return ArithmeticWidget::compute_quotient_evaluation_contribution( key, updated_alpha_base, transcript, quotient_numerator_eval); @@ -57,8 +53,8 @@ class standard_verifier_settings : public standard_settings { class ultra_verifier_settings : public ultra_settings { public: - typedef barretenberg::fr fr; - typedef barretenberg::g1 g1; + typedef bb::fr fr; + typedef bb::g1 g1; typedef transcript::StandardTranscript Transcript; typedef VerifierPlookupArithmeticWidget PlookupArithmeticWidget; typedef VerifierGenPermSortWidget GenPermSortWidget; @@ -74,7 +70,7 @@ class ultra_verifier_settings : public ultra_settings { static fr append_scalar_multiplication_inputs(verification_key* key, const fr& alpha_base, const Transcript& transcript, - std::map& scalars) + std::map& scalars) { auto updated_alpha = PermutationWidget::append_scalar_multiplication_inputs(key, alpha_base, transcript); updated_alpha = PlookupWidget::append_scalar_multiplication_inputs(key, updated_alpha, transcript, scalars); @@ -88,10 +84,10 @@ class ultra_verifier_settings : public ultra_settings { return updated_alpha; } - static barretenberg::fr compute_quotient_evaluation_contribution(verification_key* key, - const barretenberg::fr& alpha_base, - const Transcript& transcript, - barretenberg::fr& quotient_numerator_eval) + static bb::fr compute_quotient_evaluation_contribution(verification_key* key, + const bb::fr& alpha_base, + const Transcript& transcript, + bb::fr& quotient_numerator_eval) { auto updated_alpha_base = PermutationWidget::compute_quotient_evaluation_contribution( key, alpha_base, transcript, quotient_numerator_eval, idpolys); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp index d24206f741e..c76edca4a37 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp @@ -12,7 +12,7 @@ class settings_base { class standard_settings : public settings_base { public: - using Arithmetization = arithmetization::Standard; + using Arithmetization = arithmetization::Standard; static constexpr size_t num_challenge_bytes = 16; static constexpr transcript::HashType hash_type = transcript::HashType::PedersenBlake3s; static constexpr size_t program_width = 3; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/generalized_permutation.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/generalized_permutation.hpp index 7741d113b06..22c54255323 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/generalized_permutation.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/generalized_permutation.hpp @@ -5,9 +5,9 @@ namespace proof_system::plonk { template -inline void compute_gen_permutation_lagrange_base_single(barretenberg::polynomial& output, +inline void compute_gen_permutation_lagrange_base_single(bb::polynomial& output, const std::vector& permutation, - const barretenberg::evaluation_domain& small_domain) + const bb::evaluation_domain& small_domain) { if (output.size() < permutation.size()) { throw_or_abort("Permutation polynomial size is insufficient to store permutations."); @@ -18,7 +18,7 @@ inline void compute_gen_permutation_lagrange_base_single(barretenberg::polynomia // 0 = left // 1 = right // 2 = output - const barretenberg::fr* roots = small_domain.get_round_roots()[small_domain.log2_size - 2]; + const bb::fr* roots = small_domain.get_round_roots()[small_domain.log2_size - 2]; const size_t root_size = small_domain.size >> 1UL; const size_t log2_root_size = static_cast(numeric::get_msb(root_size)); @@ -59,7 +59,7 @@ inline void compute_gen_permutation_lagrange_base_single(barretenberg::polynomia const uint32_t column_index = ((permutation[i] & program_settings::permutation_mask) >> program_settings::permutation_shift); if (column_index > 0) { - output[i] *= barretenberg::fr::coset_generator(column_index - 1); + output[i] *= bb::fr::coset_generator(column_index - 1); } ITERATE_OVER_DOMAIN_END; } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/permutation.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/permutation.hpp index 7d5565251b9..b947971dfba 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/permutation.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/utils/permutation.hpp @@ -19,9 +19,9 @@ struct permutation_subgroup_element { * instead of permutation_subgroup_element **/ template -inline void compute_permutation_lagrange_base_single(barretenberg::polynomial& output, +inline void compute_permutation_lagrange_base_single(bb::polynomial& output, const std::vector& permutation, - const barretenberg::evaluation_domain& small_domain) + const bb::evaluation_domain& small_domain) { std::vector subgroup_elements; for (const auto& permutation_element : permutation) { @@ -42,9 +42,9 @@ inline void compute_permutation_lagrange_base_single(barretenberg::polynomial& o * @tparam program_settings Program settings. * */ template -inline void compute_permutation_lagrange_base_single(barretenberg::polynomial& output, +inline void compute_permutation_lagrange_base_single(bb::polynomial& output, const std::vector& permutation, - const barretenberg::evaluation_domain& small_domain) + const bb::evaluation_domain& small_domain) { if (output.size() < permutation.size()) { throw_or_abort("Permutation polynomial size is insufficient to store permutations."); @@ -56,7 +56,7 @@ inline void compute_permutation_lagrange_base_single(barretenberg::polynomial& o // 1 = right // 2 = output ASSERT(small_domain.log2_size > 1); - const barretenberg::fr* roots = small_domain.get_round_roots()[small_domain.log2_size - 2]; + const bb::fr* roots = small_domain.get_round_roots()[small_domain.log2_size - 2]; const size_t root_size = small_domain.size >> 1UL; const size_t log2_root_size = static_cast(numeric::get_msb(root_size)); @@ -95,14 +95,14 @@ inline void compute_permutation_lagrange_base_single(barretenberg::polynomial& o // As per the paper which modifies plonk to include the public inputs in a permutation argument, the permutation // `σ` is modified to `σ'`, where `σ'` maps all public inputs to a set of l distinct ζ elements which are // disjoint from H ∪ k1·H ∪ k2·H. - output[i] *= barretenberg::fr::external_coset_generator(); + output[i] *= bb::fr::external_coset_generator(); } else if (permutation[i].is_tag) { - output[i] *= barretenberg::fr::tag_coset_generator(); + output[i] *= bb::fr::tag_coset_generator(); } else { { const uint32_t column_index = permutation[i].column_index; if (column_index > 0) { - output[i] *= barretenberg::fr::coset_generator(column_index - 1); + output[i] *= bb::fr::coset_generator(column_index - 1); } } } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp index 2f5822fec2b..3d23a3d7193 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/sol_gen.hpp @@ -8,13 +8,13 @@ inline void output_vk_sol_standard(std::ostream& os, std::shared_ptr const& key, std::string const& class_name) { - const auto print_u256 = [&](const std::string& offset, const barretenberg::fr& element, const std::string& name) { + const auto print_u256 = [&](const std::string& offset, const bb::fr& element, const std::string& name) { os << " mstore(add(_vk, " << offset << "), " << element << ") // " << name << std::endl; }; const auto print_g1 = [&](const std::string& offsetX, const std::string& offsetY, - const barretenberg::g1::affine_element& element, + const bb::g1::affine_element& element, const std::string& name) { os << " mstore(add(_vk, " << offsetX << "), " << element.x << ") // " << name << ".x" << std::endl; os << " mstore(add(_vk, " << offsetY << "), " << element.y << ") // " << name << ".y" << std::endl; @@ -67,13 +67,13 @@ inline void output_vk_sol_standard(std::ostream& os, **/ inline void output_vk_sol_ultra(std::ostream& os, std::shared_ptr const& key, std::string const& class_name) { - const auto print_u256 = [&](const std::string& offset, const barretenberg::fr& element, const std::string& name) { + const auto print_u256 = [&](const std::string& offset, const bb::fr& element, const std::string& name) { os << " mstore(add(_vk, " << offset << "), " << element << ") // " << name << std::endl; }; const auto print_g1 = [&](const std::string& offsetX, const std::string& offsetY, - const barretenberg::g1::affine_element& element, + const bb::g1::affine_element& element, const std::string& name) { os << " mstore(add(_vk, " << offsetX << "), " << element.x << ") // " << name << ".x" << std::endl; os << " mstore(add(_vk, " << offsetY << "), " << element.y << ") // " << name << ".y" << std::endl; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp index b5cc572ffb1..0f51ef4f087 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp @@ -10,16 +10,16 @@ namespace proof_system::plonk { * @brief Hashes the evaluation domain to match the 'circuit' approach taken in * stdlib/recursion/verification_key/verification_key.hpp. * @note: in that reference file, the circuit-equivalent of this function is a _method_ of the `evaluation_domain' - * struct. But we cannot do that with the native `barretenberg::evaluation_domain` type unfortunately, because it's + * struct. But we cannot do that with the native `bb::evaluation_domain` type unfortunately, because it's * defined in polynomials/evaluation_domain.hpp, and `polynomial` is a bberg library which does not depend on `crypto` * in its CMakeLists.txt file. (We'd need `crypto` to be able to call native pedersen functions). * * @param domain to hash - * @return barretenberg::fr hash of the evaluation domain as a field + * @return bb::fr hash of the evaluation domain as a field */ -barretenberg::fr hash_native_evaluation_domain(barretenberg::evaluation_domain const& domain) +bb::fr hash_native_evaluation_domain(bb::evaluation_domain const& domain) { - barretenberg::fr out = crypto::pedersen_hash::hash({ + bb::fr out = crypto::pedersen_hash::hash({ domain.root, domain.domain, domain.generator, @@ -38,9 +38,9 @@ barretenberg::fr hash_native_evaluation_domain(barretenberg::evaluation_domain c * @param hash_index generator index to use during pedersen hashing * @returns a field containing the hash */ -barretenberg::fr verification_key_data::hash_native(const size_t hash_index) const +bb::fr verification_key_data::hash_native(const size_t hash_index) const { - barretenberg::evaluation_domain eval_domain = barretenberg::evaluation_domain(circuit_size); + bb::evaluation_domain eval_domain = bb::evaluation_domain(circuit_size); std::vector preimage_data; @@ -69,7 +69,7 @@ barretenberg::fr verification_key_data::hash_native(const size_t hash_index) con verification_key::verification_key(const size_t num_gates, const size_t num_inputs, - std::shared_ptr> const& crs, + std::shared_ptr> const& crs, CircuitType circuit_type_) : circuit_type(circuit_type_) , circuit_size(num_gates) @@ -81,7 +81,7 @@ verification_key::verification_key(const size_t num_gates, {} verification_key::verification_key(verification_key_data&& data, - std::shared_ptr> const& crs) + std::shared_ptr> const& crs) : circuit_type(static_cast(data.circuit_type)) , circuit_size(data.circuit_size) , log_circuit_size(numeric::get_msb(data.circuit_size)) diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp index 8b431260b98..a9686b2f1a9 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp @@ -15,7 +15,7 @@ struct verification_key_data { uint32_t circuit_type; uint32_t circuit_size; uint32_t num_public_inputs; - std::map commitments; + std::map commitments; bool contains_recursive_proof = false; std::vector recursive_proof_public_input_indices; @@ -26,7 +26,7 @@ struct verification_key_data { commitments, contains_recursive_proof, recursive_proof_public_input_indices); - [[nodiscard]] barretenberg::fr hash_native(size_t hash_index = 0) const; + [[nodiscard]] bb::fr hash_native(size_t hash_index = 0) const; }; inline std::ostream& operator<<(std::ostream& os, verification_key_data const& key) @@ -49,10 +49,10 @@ struct verification_key { // default constructor needed for msgpack unpack verification_key() = default; verification_key(verification_key_data&& data, - std::shared_ptr> const& crs); + std::shared_ptr> const& crs); verification_key(size_t num_gates, size_t num_inputs, - std::shared_ptr> const& crs, + std::shared_ptr> const& crs, CircuitType circuit_type); verification_key(const verification_key& other); @@ -80,17 +80,17 @@ struct verification_key { size_t log_circuit_size; size_t num_public_inputs; - barretenberg::evaluation_domain domain; + bb::evaluation_domain domain; - std::shared_ptr> reference_string; + std::shared_ptr> reference_string; - std::map commitments; + std::map commitments; PolynomialManifest polynomial_manifest; // This is a member variable so as to avoid recomputing it in the different places of the verifier algorithm. // Note that recomputing would also have added constraints to the recursive verifier circuit. - barretenberg::fr z_pow_n; // ʓ^n (ʓ being the 'evaluation challenge') + bb::fr z_pow_n; // ʓ^n (ʓ being the 'evaluation challenge') bool contains_recursive_proof = false; std::vector recursive_proof_public_input_indices; @@ -110,7 +110,7 @@ struct verification_key { void msgpack_unpack(auto obj) { verification_key_data data = obj; - *this = verification_key{ std::move(data), barretenberg::srs::get_crs_factory()->get_verifier_crs() }; + *this = verification_key{ std::move(data), bb::srs::get_crs_factory()->get_verifier_crs() }; } // Alias verification_key as verification_key_data in the schema void msgpack_schema(auto& packer) const { packer.pack_schema(proof_system::plonk::verification_key_data{}); } @@ -121,7 +121,7 @@ template inline void read(B& buf, verification_key& key) using serialize::read; verification_key_data vk_data; read(buf, vk_data); - key = verification_key{ std::move(vk_data), barretenberg::srs::get_crs_factory()->get_verifier_crs() }; + key = verification_key{ std::move(vk_data), bb::srs::get_crs_factory()->get_verifier_crs() }; } template inline void read(B& buf, std::shared_ptr& key) @@ -129,8 +129,7 @@ template inline void read(B& buf, std::shared_ptr using serialize::read; verification_key_data vk_data; read(buf, vk_data); - key = std::make_shared(std::move(vk_data), - barretenberg::srs::get_crs_factory()->get_verifier_crs()); + key = std::make_shared(std::move(vk_data), bb::srs::get_crs_factory()->get_verifier_crs()); } template inline void write(B& buf, verification_key const& key) diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp index 3e0dc85aae0..4c181ca9506 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp @@ -7,7 +7,7 @@ namespace { auto& engine = numeric::random::get_debug_engine(); } // namespace -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace proof_system::plonk::test_verification_key { diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp index 0e909d8eba4..5e91f1be8a9 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp @@ -8,7 +8,7 @@ #include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/polynomials/polynomial_arithmetic.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { template @@ -86,7 +86,7 @@ template bool VerifierBase::verify // Here k = num_roots_cut_out_of_the_vanishing_polynomial and n is the size of the evaluation domain. /// TODO: can we add these lagrange evaluations to the transcript? They get recalcualted after this multiple times, // by each widget. - const auto lagrange_evals = barretenberg::polynomial_arithmetic::get_lagrange_evaluations(zeta, key->domain); + const auto lagrange_evals = bb::polynomial_arithmetic::get_lagrange_evaluations(zeta, key->domain); // Step 8: Compute quotient polynomial evaluation at zeta // r_eval − (a_eval + β.sigma1_eval + γ)(b_eval + β.sigma2_eval + γ)(c_eval + γ).z_eval_omega.α − @@ -176,13 +176,12 @@ template bool VerifierBase::verify size_t num_elements = elements.size(); elements.resize(num_elements * 2); - barretenberg::scalar_multiplication::generate_pippenger_point_table( - &elements[0], &elements[0], num_elements); + bb::scalar_multiplication::generate_pippenger_point_table(&elements[0], &elements[0], num_elements); scalar_multiplication::pippenger_runtime_state state(num_elements); g1::element P[2]; - P[0] = barretenberg::scalar_multiplication::pippenger(&scalars[0], &elements[0], num_elements, state); + P[0] = bb::scalar_multiplication::pippenger(&scalars[0], &elements[0], num_elements, state); P[1] = -(g1::element(PI_Z_OMEGA) * separator_challenge + PI_Z); if (key->contains_recursive_proof) { @@ -198,7 +197,7 @@ template bool VerifierBase::verify const uint256_t limb = l0 + (l1 << NUM_LIMB_BITS_IN_FIELD_SIMULATION) + (l2 << (NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2)) + (l3 << (NUM_LIMB_BITS_IN_FIELD_SIMULATION * 3)); - return barretenberg::fq(limb); + return bb::fq(limb); }; const auto recursion_separator_challenge = transcript.get_challenge_field_element("separator").sqr(); @@ -232,10 +231,10 @@ template bool VerifierBase::verify }; // The final pairing check of step 12. - barretenberg::fq12 result = barretenberg::pairing::reduced_ate_pairing_batch_precomputed( + bb::fq12 result = bb::pairing::reduced_ate_pairing_batch_precomputed( P_affine, key->reference_string->get_precomputed_g2_lines(), 2); - return (result == barretenberg::fq12::one()); + return (result == bb::fq12::one()); } template class VerifierBase; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.hpp index 6f32b1a49e7..9a8a0294c52 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.hpp @@ -23,8 +23,8 @@ template class VerifierBase { transcript::Manifest manifest; std::shared_ptr key; - std::map kate_g1_elements; - std::map kate_fr_elements; + std::map kate_g1_elements; + std::map kate_fr_elements; std::unique_ptr commitment_scheme; }; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp index 4885e7f8788..c0596b86351 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp @@ -13,7 +13,7 @@ namespace verifier_helpers { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_key) @@ -28,7 +28,7 @@ plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_k poly_coefficients[6] = circuit_proving_key->polynomial_store.get("sigma_2").data(); poly_coefficients[7] = circuit_proving_key->polynomial_store.get("sigma_3").data(); - std::vector commitments; + std::vector commitments; scalar_multiplication::pippenger_runtime_state state(circuit_proving_key->circuit_size); commitments.resize(8); @@ -40,7 +40,7 @@ plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_k state)); } - auto crs = std::make_shared>("../srs_db/ignition"); + auto crs = std::make_shared>("../srs_db/ignition"); std::shared_ptr circuit_verification_key = std::make_shared(circuit_proving_key->circuit_size, circuit_proving_key->num_public_inputs, @@ -76,7 +76,7 @@ plonk::Prover generate_test_data(const size_t n) // even indices = mul gates, odd incides = add gates - auto crs = std::make_shared>(n + 1, "../srs_db/ignition"); + auto crs = std::make_shared>(n + 1, "../srs_db/ignition"); std::shared_ptr key = std::make_shared(n, 0, crs, CircuitType::STANDARD); polynomial w_l(n); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget.hpp index 4f09ef89d69..56bd11e83f5 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget.hpp @@ -34,8 +34,8 @@ class ProverPermutationWidget : public ProverRandomWidget { const size_t round_number, work_queue& queue) override; - barretenberg::fr compute_quotient_contribution(const barretenberg::fr& alpha_base, - const transcript::StandardTranscript& transcript) override; + bb::fr compute_quotient_contribution(const bb::fr& alpha_base, + const transcript::StandardTranscript& transcript) override; }; } // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget_impl.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget_impl.hpp index 2b186df01f5..d9d2e762579 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/permutation_widget_impl.hpp @@ -75,8 +75,8 @@ void ProverPermutationWidget, program_width> lagrange_base_wires_ptr; std::array, program_width> lagrange_base_sigmas_ptr; @@ -149,11 +149,11 @@ void ProverPermutationWidgetsmall_domain.num_threads, [&](size_t j) { - barretenberg::fr thread_root = key->small_domain.root.pow( - static_cast(j * key->small_domain.thread_size)); // effectively ω^{i} in inner loop - [[maybe_unused]] barretenberg::fr cur_root_times_beta = thread_root * beta; // β.ω^{i} - barretenberg::fr T0; - barretenberg::fr wire_plus_gamma; + bb::fr thread_root = key->small_domain.root.pow( + static_cast(j * key->small_domain.thread_size)); // effectively ω^{i} in inner loop + [[maybe_unused]] bb::fr cur_root_times_beta = thread_root * beta; // β.ω^{i} + bb::fr T0; + bb::fr wire_plus_gamma; size_t start = j * key->small_domain.thread_size; size_t end = (j + 1) * key->small_domain.thread_size; for (size_t i = start; i < end; ++i) { @@ -236,7 +236,7 @@ void ProverPermutationWidgetsmall_domain.thread_size; const size_t end = ((j + 1) * key->small_domain.thread_size) - ((j == key->small_domain.num_threads - 1) ? 1 : 0); - barretenberg::fr inversion_accumulator = fr::one(); + bb::fr inversion_accumulator = fr::one(); constexpr size_t inversion_index = (program_width == 1) ? 2 : program_width * 2 - 1; fr* inversion_coefficients = &accumulators[inversion_index][0]; for (size_t i = start; i < end; ++i) { @@ -262,7 +262,7 @@ void ProverPermutationWidgetcircuit_size); z_perm[0] = fr::one(); - barretenberg::polynomial_arithmetic::copy_polynomial( + bb::polynomial_arithmetic::copy_polynomial( accumulators[0], &z_perm[1], key->circuit_size - 1, key->circuit_size - 1); /* @@ -329,7 +329,7 @@ void ProverPermutationWidget -barretenberg::fr ProverPermutationWidget:: +bb::fr ProverPermutationWidget:: compute_quotient_contribution(const fr& alpha_base, const transcript::StandardTranscript& transcript) { const polynomial& z_perm_fft = key->polynomial_store.get("z_perm_fft"); - barretenberg::fr alpha_squared = alpha_base.sqr(); - barretenberg::fr beta = fr::serialize_from_buffer(transcript.get_challenge("beta").begin()); - barretenberg::fr gamma = fr::serialize_from_buffer(transcript.get_challenge("beta", 1).begin()); + bb::fr alpha_squared = alpha_base.sqr(); + bb::fr beta = fr::serialize_from_buffer(transcript.get_challenge("beta").begin()); + bb::fr gamma = fr::serialize_from_buffer(transcript.get_challenge("beta", 1).begin()); // Initialize the (n + 1)th coefficients of quotient parts so that reuse of proving // keys does not use some residual data from another proof. @@ -399,10 +399,9 @@ barretenberg::fr ProverPermutationWidgetpolynomial_store.get("lagrange_1_fft"); // Compute our public input component - std::vector public_inputs = many_from_buffer(transcript.get_element("public_inputs")); + std::vector public_inputs = many_from_buffer(transcript.get_element("public_inputs")); - barretenberg::fr public_input_delta = - compute_public_input_delta(public_inputs, beta, gamma, key->small_domain.root); + bb::fr public_input_delta = compute_public_input_delta(public_inputs, beta, gamma, key->small_domain.root); const size_t block_mask = key->large_domain.size - 1; // Step 4: Set the quotient polynomial to be equal to @@ -415,15 +414,15 @@ barretenberg::fr ProverPermutationWidgetlarge_domain.root.pow(static_cast(j * key->large_domain.thread_size)); cur_root_times_beta *= key->small_domain.generator; cur_root_times_beta *= beta; - barretenberg::fr wire_plus_gamma; - barretenberg::fr T0; - barretenberg::fr denominator; - barretenberg::fr numerator; + bb::fr wire_plus_gamma; + bb::fr T0; + bb::fr denominator; + bb::fr numerator; for (size_t i = start; i < end; ++i) { wire_plus_gamma = gamma + wire_ffts[0][i]; @@ -785,8 +784,6 @@ Field VerifierPermutationWidget; +template class VerifierPermutationWidget; } // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget.hpp index 64d34ce871f..a54907ed17f 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget.hpp @@ -38,8 +38,8 @@ class ProverPlookupWidget : public ProverRandomWidget { const size_t round_number, work_queue& queue) override; - inline barretenberg::fr compute_quotient_contribution(const barretenberg::fr& alpha_base, - const transcript::StandardTranscript& transcript) override; + inline bb::fr compute_quotient_contribution(const bb::fr& alpha_base, + const transcript::StandardTranscript& transcript) override; }; } // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget_impl.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget_impl.hpp index c88e641fc96..66a59de7c55 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget_impl.hpp @@ -362,7 +362,7 @@ void ProverPlookupWidget::compute_rou .work_type = work_queue::WorkType::FFT, .mul_scalars = nullptr, .tag = "s", - .constant = barretenberg::fr(0), + .constant = bb::fr(0), .index = 0, }); @@ -386,7 +386,7 @@ void ProverPlookupWidget::compute_rou .work_type = work_queue::WorkType::FFT, .mul_scalars = nullptr, .tag = "z_lookup", - .constant = barretenberg::fr(0), + .constant = bb::fr(0), .index = 0, }); @@ -400,7 +400,7 @@ void ProverPlookupWidget::compute_rou * @tparam num_roots_cut_out_of_vanishing_polynomial * @param alpha_base * @param transcript - * @return barretenberg::fr + * @return bb::fr * * @details The terms associated with the z_lookup grand product polynomial that must be added * to the quotient polynomial are as follows: @@ -417,7 +417,7 @@ void ProverPlookupWidget::compute_rou * */ template -barretenberg::fr ProverPlookupWidget::compute_quotient_contribution( +bb::fr ProverPlookupWidget::compute_quotient_contribution( const fr& alpha_base, const transcript::StandardTranscript& transcript) { auto z_lookup_fft = key->polynomial_store.get("z_lookup_fft"); @@ -746,8 +746,6 @@ Field VerifierPlookupWidget; +template class VerifierPlookupWidget; } // namespace proof_system::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/random_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/random_widget.hpp index b055ed23023..9d4f764e4e2 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/random_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/random_widgets/random_widget.hpp @@ -15,8 +15,8 @@ class ReferenceString; class ProverRandomWidget { protected: - typedef barretenberg::fr fr; - typedef barretenberg::polynomial polynomial; + typedef bb::fr fr; + typedef bb::polynomial polynomial; public: ProverRandomWidget(proving_key* input_key) @@ -45,8 +45,8 @@ class ProverRandomWidget { virtual void compute_round_commitments(transcript::StandardTranscript&, const size_t, work_queue&){}; - virtual barretenberg::fr compute_quotient_contribution(const barretenberg::fr& alpha_base, - const transcript::StandardTranscript& transcript) = 0; + virtual bb::fr compute_quotient_contribution(const bb::fr& alpha_base, + const transcript::StandardTranscript& transcript) = 0; proving_key* key; }; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/arithmetic_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/arithmetic_widget.hpp index 125b5157f2f..fae8785cdc6 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/arithmetic_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/arithmetic_widget.hpp @@ -93,7 +93,7 @@ template class ArithmeticKe * @tparam Settings */ template -using ProverArithmeticWidget = widget::TransitionWidget; +using ProverArithmeticWidget = widget::TransitionWidget; /** * @brief Standard plonk arithmetic widget for the verifier. Provides standard plonk gate transition diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/elliptic_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/elliptic_widget.hpp index 71eb808eb1c..a03f1a3772a 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/elliptic_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/elliptic_widget.hpp @@ -149,7 +149,7 @@ template class EllipticKern } // namespace widget template -using ProverEllipticWidget = widget::TransitionWidget; +using ProverEllipticWidget = widget::TransitionWidget; template using VerifierEllipticWidget = widget::GenericVerifierWidget; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/genperm_sort_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/genperm_sort_widget.hpp index eda0f942b08..24cba31b689 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/genperm_sort_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/genperm_sort_widget.hpp @@ -31,8 +31,8 @@ template class GenPermSortK Field& quotient, const size_t i = 0) { - constexpr barretenberg::fr minus_two(-2); - constexpr barretenberg::fr minus_three(-3); + constexpr bb::fr minus_two(-2); + constexpr bb::fr minus_three(-3); const Field& alpha_base = challenges.alpha_powers[0]; const Field& alpha = challenges.elements[ChallengeIndex::ALPHA]; @@ -102,7 +102,7 @@ template class GenPermSortK } // namespace widget template -using ProverGenPermSortWidget = widget::TransitionWidget; +using ProverGenPermSortWidget = widget::TransitionWidget; template using VerifierGenPermSortWidget = widget::GenericVerifierWidget; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_arithmetic_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_arithmetic_widget.hpp index 61323ab4619..9ee609bb5d0 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_arithmetic_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_arithmetic_widget.hpp @@ -125,8 +125,8 @@ template class PlookupArith arithmetic_gate_identity *= (q_arith - 3); // TODO: if we multiply all q_m values by `-1/2` we can remove the need for this extra multiplication - if constexpr (std::is_same::value) { - static constexpr barretenberg::fr neg_half = barretenberg::fr(-2).invert(); + if constexpr (std::is_same::value) { + static constexpr bb::fr neg_half = bb::fr(-2).invert(); arithmetic_gate_identity *= neg_half; } else { static const Field neg_half = Field(-2).invert(); @@ -168,8 +168,7 @@ template class PlookupArith * @tparam Settings */ template -using ProverPlookupArithmeticWidget = - widget::TransitionWidget; +using ProverPlookupArithmeticWidget = widget::TransitionWidget; /** * @brief Ultra plonk arithmetic widget for the verifier. It's quite complex, so for details better look at the kernel diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp index c582d6b1a7d..636f61a6364 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/plookup_auxiliary_widget.hpp @@ -66,8 +66,8 @@ template class PlookupAuxil Field& quotient, const size_t i = 0) { - constexpr barretenberg::fr LIMB_SIZE(uint256_t(1) << 68); - constexpr barretenberg::fr SUBLIMB_SHIFT(uint256_t(1) << 14); + constexpr bb::fr LIMB_SIZE(uint256_t(1) << 68); + constexpr bb::fr SUBLIMB_SHIFT(uint256_t(1) << 14); const Field& w_1 = Getters::template get_value(polynomials, i); @@ -324,8 +324,7 @@ template class PlookupAuxil } // namespace widget template -using ProverPlookupAuxiliaryWidget = - widget::TransitionWidget; +using ProverPlookupAuxiliaryWidget = widget::TransitionWidget; template using VerifierPlookupAuxiliaryWidget = diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp index 9f3cc1cb2b5..b00dccfc249 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/widgets/transition_widgets/transition_widget.hpp @@ -116,7 +116,7 @@ template ; + using Fr = bb::fr; + using Univariate = bb::Univariate; using Transcript = transcript::StandardTranscript; std::vector g1_vector(64); diff --git a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.cpp b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.cpp index a95943199da..8daee814934 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.cpp @@ -3,35 +3,34 @@ #include namespace transcript { -void StandardTranscript::add_field_element(const std::string& element_name, const barretenberg::fr& element) +void StandardTranscript::add_field_element(const std::string& element_name, const bb::fr& element) { add_element(element_name, element.to_buffer()); } -barretenberg::fr StandardTranscript::get_field_element(const std::string& element_name) const +bb::fr StandardTranscript::get_field_element(const std::string& element_name) const { - return barretenberg::fr::serialize_from_buffer(&(get_element(element_name))[0]); + return bb::fr::serialize_from_buffer(&(get_element(element_name))[0]); } -barretenberg::g1::affine_element StandardTranscript::get_group_element(const std::string& element_name) const +bb::g1::affine_element StandardTranscript::get_group_element(const std::string& element_name) const { - return barretenberg::g1::affine_element::serialize_from_buffer(&(get_element(element_name))[0]); + return bb::g1::affine_element::serialize_from_buffer(&(get_element(element_name))[0]); } -std::vector StandardTranscript::get_field_element_vector(const std::string& element_name) const +std::vector StandardTranscript::get_field_element_vector(const std::string& element_name) const { - return many_from_buffer(get_element(element_name)); + return many_from_buffer(get_element(element_name)); } -barretenberg::fr StandardTranscript::get_challenge_field_element(const std::string& challenge_name, - const size_t idx) const +bb::fr StandardTranscript::get_challenge_field_element(const std::string& challenge_name, const size_t idx) const { - return barretenberg::fr::serialize_from_buffer(&(get_challenge(challenge_name, idx))[0]); + return bb::fr::serialize_from_buffer(&(get_challenge(challenge_name, idx))[0]); } -barretenberg::fr StandardTranscript::get_challenge_field_element_from_map(const std::string& challenge_name, - const std::string& challenge_map_name) const +bb::fr StandardTranscript::get_challenge_field_element_from_map(const std::string& challenge_name, + const std::string& challenge_map_name) const { - return barretenberg::fr::serialize_from_buffer(&(get_challenge_from_map(challenge_name, challenge_map_name))[0]); + return bb::fr::serialize_from_buffer(&(get_challenge_from_map(challenge_name, challenge_map_name))[0]); } } // namespace transcript diff --git a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.hpp b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.hpp index bd33eff8008..b5938eccd16 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript_wrappers.hpp @@ -41,21 +41,21 @@ class StandardTranscript : public Transcript { const size_t challenge_bytes = 32) : Transcript(input_transcript, input_manifest, hash_type, challenge_bytes){}; - void add_field_element(const std::string& element_name, const barretenberg::fr& element); + void add_field_element(const std::string& element_name, const bb::fr& element); - barretenberg::fr get_field_element(const std::string& element_name) const; - barretenberg::g1::affine_element get_group_element(const std::string& element_name) const; + bb::fr get_field_element(const std::string& element_name) const; + bb::g1::affine_element get_group_element(const std::string& element_name) const; - std::vector get_field_element_vector(const std::string& element_name) const; + std::vector get_field_element_vector(const std::string& element_name) const; - barretenberg::fr get_challenge_field_element(const std::string& challenge_name, const size_t idx = 0) const; - barretenberg::fr get_challenge_field_element_from_map(const std::string& challenge_name, - const std::string& challenge_map_name) const; + bb::fr get_challenge_field_element(const std::string& challenge_name, const size_t idx = 0) const; + bb::fr get_challenge_field_element_from_map(const std::string& challenge_name, + const std::string& challenge_map_name) const; std::vector export_transcript() const { return Transcript::export_transcript(); } // TODO(luke): temporary function for debugging - barretenberg::fr get_mock_challenge() { return barretenberg::fr::random_element(); }; + bb::fr get_mock_challenge() { return bb::fr::random_element(); }; }; } // namespace transcript diff --git a/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp b/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp index 6b1f15f4680..421ec273614 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp @@ -5,7 +5,7 @@ namespace proof_system::plonk { -using namespace barretenberg; +using namespace bb; work_queue::work_queue(proving_key* prover_key, transcript::StandardTranscript* prover_transcript) : key(prover_key) @@ -82,8 +82,8 @@ void work_queue::put_ifft_data(std::shared_ptr result, const size_t work_i for (const auto& item : work_item_queue) { if (item.work_type == WorkType::IFFT) { if (count == work_item_number) { - barretenberg::polynomial wire(key->circuit_size); - memcpy(wire.data().get(), result.get(), key->circuit_size * sizeof(barretenberg::fr)); + bb::polynomial wire(key->circuit_size); + memcpy(wire.data().get(), result.get(), key->circuit_size * sizeof(bb::fr)); key->polynomial_store.put(item.tag, std::move(wire)); return; } @@ -106,7 +106,7 @@ work_queue::queued_fft_inputs work_queue::get_fft_data(const size_t work_item_nu ++count; } } - return { nullptr, barretenberg::fr(0) }; + return { nullptr, bb::fr(0) }; } void work_queue::put_fft_data(std::shared_ptr result, const size_t work_item_number) @@ -116,7 +116,7 @@ void work_queue::put_fft_data(std::shared_ptr result, const size_t work_it if (item.work_type == WorkType::SMALL_FFT) { if (count == work_item_number) { const size_t n = key->circuit_size; - barretenberg::polynomial wire_fft(4 * n + 4); + bb::polynomial wire_fft(4 * n + 4); for (size_t i = 0; i < n; ++i) { wire_fft[4 * i + item.index] = result.get()[i]; @@ -132,8 +132,7 @@ void work_queue::put_fft_data(std::shared_ptr result, const size_t work_it } } -void work_queue::put_scalar_multiplication_data(const barretenberg::g1::affine_element result, - const size_t work_item_number) +void work_queue::put_scalar_multiplication_data(const bb::g1::affine_element result, const size_t work_item_number) { size_t count = 0; for (const auto& item : work_item_queue) { @@ -160,8 +159,8 @@ void work_queue::add_to_queue(const work_item& item) // #if 1 // if (item.work_type == WorkType::FFT) { // const auto large_root = key->large_domain.root; - // barretenberg::fr coset_shifts[4]{ - // barretenberg::fr(1), large_root, large_root.sqr(), large_root.sqr() * large_root + // bb::fr coset_shifts[4]{ + // bb::fr(1), large_root, large_root.sqr(), large_root.sqr() * large_root // }; // work_item_queue.push_back({ // WorkType::SMALL_FFT, @@ -210,11 +209,11 @@ void work_queue::process_queue() ASSERT(msm_size <= key->reference_string->get_monomial_size()); - barretenberg::g1::affine_element* srs_points = key->reference_string->get_monomial_points(); + bb::g1::affine_element* srs_points = key->reference_string->get_monomial_points(); // Run pippenger multi-scalar multiplication. - auto runtime_state = barretenberg::scalar_multiplication::pippenger_runtime_state(msm_size); - barretenberg::g1::affine_element result(barretenberg::scalar_multiplication::pippenger_unsafe( + auto runtime_state = bb::scalar_multiplication::pippenger_runtime_state(msm_size); + bb::g1::affine_element result(bb::scalar_multiplication::pippenger_unsafe( item.mul_scalars.get(), srs_points, msm_size, runtime_state)); transcript->add_element(item.tag, result.to_buffer()); @@ -225,7 +224,7 @@ void work_queue::process_queue() // About 20% of the cost of a scalar multiplication. For WASM, might be a bit more expensive // due to the need to copy memory between web workers // case WorkType::SMALL_FFT: { - // using namespace barretenberg; + // using namespace bb; // const size_t n = key->circuit_size; // auto wire = key->polynomial_store.get(item.tag); @@ -249,7 +248,7 @@ void work_queue::process_queue() // break; // } case WorkType::FFT: { - using namespace barretenberg; + using namespace bb; auto wire = key->polynomial_store.get(item.tag); polynomial wire_fft(wire, 4 * key->circuit_size + 4); @@ -264,7 +263,7 @@ void work_queue::process_queue() } // 1/4 the cost of an fft (each fft has 1/4 the number of elements) case WorkType::IFFT: { - using namespace barretenberg; + using namespace bb; // retrieve wire in lagrange form auto wire_lagrange = key->polynomial_store.get(item.tag + "_lagrange"); diff --git a/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.hpp b/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.hpp index 707f5ba3376..4a92dc598b7 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.hpp @@ -5,7 +5,7 @@ namespace proof_system::plonk { -using namespace barretenberg; +using namespace bb; // TODO(Cody): Template by flavor? class work_queue { @@ -23,13 +23,13 @@ class work_queue { WorkType work_type; mutable std::shared_ptr mul_scalars; std::string tag; - barretenberg::fr constant; + bb::fr constant; const size_t index; }; struct queued_fft_inputs { std::shared_ptr data; - barretenberg::fr shift_factor; + bb::fr shift_factor; }; work_queue(proving_key* prover_key = nullptr, transcript::StandardTranscript* prover_transcript = nullptr); @@ -53,7 +53,7 @@ class work_queue { void put_fft_data(std::shared_ptr result, const size_t work_item_number); - void put_scalar_multiplication_data(const barretenberg::g1::affine_element result, const size_t work_item_number); + void put_scalar_multiplication_data(const bb::g1::affine_element result, const size_t work_item_number); void flush_queue(); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.hpp b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.hpp index 27cd1c8631b..dbad8cb56f0 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.hpp @@ -16,7 +16,7 @@ 3) There should be more thorough testing of this class in isolation. */ -namespace barretenberg { +namespace bb { /** * @todo: TODO(https://github.com/AztecProtocol/barretenberg/issues/713) Optimize with lookup tables? @@ -238,7 +238,7 @@ template struct is_field_type { static constexpr bool value = false; }; -template struct is_field_type> { +template struct is_field_type> { static constexpr bool value = true; }; @@ -256,4 +256,4 @@ using BarycentricData = std::conditional_t, BarycentricDataCompileTime, BarycentricDataRunTime>; -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp index 1f34e59843f..10efc3916d7 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp @@ -2,11 +2,11 @@ #include "univariate.hpp" #include -namespace barretenberg::test_barycentric { +namespace bb::test_barycentric { template class BarycentricDataTests : public testing::Test {}; -using FieldTypes = testing::Types; +using FieldTypes = testing::Types; TYPED_TEST_SUITE(BarycentricDataTests, FieldTypes); #define BARYCENTIC_DATA_TESTS_TYPE_ALIASES using FF = TypeParam; @@ -87,4 +87,4 @@ TYPED_TEST(BarycentricDataTests, BarycentricData5to6) EXPECT_EQ(ext1, expected); } -} // namespace barretenberg::test_barycentric +} // namespace bb::test_barycentric diff --git a/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.cpp b/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.cpp index 2bd2f040d5b..0a838af2caf 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.cpp @@ -9,7 +9,7 @@ #include #include -namespace barretenberg { +namespace bb { namespace { constexpr size_t MIN_GROUP_PER_THREAD = 4; @@ -177,7 +177,7 @@ template void EvaluationDomain::compute_lookup_table() } // explicitly instantiate both EvaluationDomain -template class EvaluationDomain; +template class EvaluationDomain; template class EvaluationDomain; -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.hpp b/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.hpp index 49dd70ae640..1aa5cd97e18 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/evaluation_domain.hpp @@ -3,7 +3,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include -namespace barretenberg { +namespace bb { template class EvaluationDomain { public: @@ -67,5 +67,5 @@ template class EvaluationDomain { }; // add alias for compatibility -using evaluation_domain = EvaluationDomain; -} // namespace barretenberg +using evaluation_domain = EvaluationDomain; +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.cpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.cpp index b5427deeee1..1c77dfa083e 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.cpp @@ -14,7 +14,7 @@ #include #include -namespace barretenberg { +namespace bb { // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays) template std::shared_ptr _allocate_aligned_memory(const size_t n_elements) @@ -521,7 +521,7 @@ template Polynomial Polynomial::partial_evaluate_mle(std:: return result; } -template class Polynomial; +template class Polynomial; template class Polynomial; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index f60e24ecad7..70e080bdfa4 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -6,7 +6,7 @@ #include "polynomial_arithmetic.hpp" #include -namespace barretenberg { +namespace bb { enum class DontZeroMemory { FLAG }; template class Polynomial { @@ -273,9 +273,9 @@ template inline std::ostream& operator<<(std::ostream& os, Polynom << "]"; } -using polynomial = Polynomial; +using polynomial = Polynomial; -} // namespace barretenberg +} // namespace bb /** * The static_assert below ensure that that our Polynomial class correctly models an `std::ranges::contiguous_range`, @@ -284,11 +284,11 @@ using polynomial = Polynomial; * This also means we can now iterate over the elements in the vector using a `for(auto ...)` loop, and use various std * algorithms. * - * static_assert(std::ranges::contiguous_range); - * static_assert(std::ranges::sized_range); - * static_assert(std::convertible_to>); - * static_assert(std::convertible_to>); + * static_assert(std::ranges::contiguous_range); + * static_assert(std::ranges::sized_range); + * static_assert(std::convertible_to>); + * static_assert(std::convertible_to>); * // cannot convert a const polynomial to a non-const span - * static_assert(!std::convertible_to>); - * static_assert(std::convertible_to>); + * static_assert(!std::convertible_to>); + * static_assert(std::convertible_to>); */ diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.cpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.cpp index 0fa9083bd90..3530b816f3b 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.cpp @@ -9,7 +9,7 @@ #include #include -namespace barretenberg::polynomial_arithmetic { +namespace bb::polynomial_arithmetic { namespace { @@ -1040,7 +1040,7 @@ Fr compute_kate_opening_coefficients(const Fr* src, Fr* dest, const Fr& z, const */ template requires SupportsFFT -barretenberg::polynomial_arithmetic::LagrangeEvaluations get_lagrange_evaluations( +bb::polynomial_arithmetic::LagrangeEvaluations get_lagrange_evaluations( const Fr& zeta, const EvaluationDomain& domain, const size_t num_roots_cut_out_of_vanishing_polynomial) { // Compute Z_H*(ʓ), l_start(ʓ), l_{end}(ʓ) @@ -1101,7 +1101,7 @@ barretenberg::polynomial_arithmetic::LagrangeEvaluations get_lagrange_evalua denominators[2] = (zeta * l_end_root) - Fr::one(); Fr::batch_invert(denominators, 3); - barretenberg::polynomial_arithmetic::LagrangeEvaluations result; + bb::polynomial_arithmetic::LagrangeEvaluations result; result.vanishing_poly = numerator * denominators[0]; // (ʓ^n - 1) / (ʓ-ω^{-1}).(ʓ-ω^{-2})...(ʓ-ω^{-k}) =: Z_H*(ʓ) numerator = numerator * domain.domain_inverse; // (ʓ^n - 1) / n result.l_start = numerator * denominators[1]; // (ʓ^n - 1) / (n.(ʓ - 1)) =: L_1(ʓ) @@ -1441,4 +1441,4 @@ template void compute_efficient_interpolation(const grumpkin::fr*, const grumpkin::fr*, const size_t); -} // namespace barretenberg::polynomial_arithmetic +} // namespace bb::polynomial_arithmetic diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.hpp index 6ebe2a2d474..0cb5d3fd998 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.hpp @@ -1,7 +1,7 @@ #pragma once #include "evaluation_domain.hpp" -namespace barretenberg { +namespace bb { namespace polynomial_arithmetic { template @@ -361,4 +361,4 @@ template void factor_roots(std::span polynomial, std::span #include -using namespace barretenberg; +using namespace bb; /** * @brief Ensure evaluate() gives consistent result for polynomials of different size but same non-zero coefficients. @@ -913,7 +913,7 @@ TEST(polynomials, fft_linear_poly_product) template class PolynomialTests : public ::testing::Test {}; -using FieldTypes = ::testing::Types; +using FieldTypes = ::testing::Types; TYPED_TEST_SUITE(PolynomialTests, FieldTypes); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomials.bench.cpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomials.bench.cpp index 8d5ff0b0107..5a3ead7a0d3 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomials.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomials.bench.cpp @@ -12,7 +12,7 @@ #include using namespace benchmark; -using namespace barretenberg; +using namespace bb; constexpr size_t MAX_GATES = 1 << 20; constexpr size_t START = (1 << 20) >> 7; @@ -33,13 +33,11 @@ struct global_vars { global_vars globals; -barretenberg::evaluation_domain evaluation_domains[10]{ - barretenberg::evaluation_domain(START), barretenberg::evaluation_domain(START * 2), - barretenberg::evaluation_domain(START * 4), barretenberg::evaluation_domain(START * 8), - barretenberg::evaluation_domain(START * 16), barretenberg::evaluation_domain(START * 32), - barretenberg::evaluation_domain(START * 64), barretenberg::evaluation_domain(START * 128), - barretenberg::evaluation_domain(START * 256), barretenberg::evaluation_domain(START * 512) -}; +bb::evaluation_domain evaluation_domains[10]{ bb::evaluation_domain(START), bb::evaluation_domain(START * 2), + bb::evaluation_domain(START * 4), bb::evaluation_domain(START * 8), + bb::evaluation_domain(START * 16), bb::evaluation_domain(START * 32), + bb::evaluation_domain(START * 64), bb::evaluation_domain(START * 128), + bb::evaluation_domain(START * 256), bb::evaluation_domain(START * 512) }; void generate_scalars(fr* scalars) { @@ -214,7 +212,7 @@ void coset_fft_bench_parallel(State& state) noexcept { for (auto _ : state) { size_t idx = (size_t)numeric::get_msb((uint64_t)state.range(0)) - (size_t)numeric::get_msb(START); - barretenberg::polynomial_arithmetic::coset_fft(globals.data, evaluation_domains[idx]); + bb::polynomial_arithmetic::coset_fft(globals.data, evaluation_domains[idx]); } } BENCHMARK(coset_fft_bench_parallel)->RangeMultiplier(2)->Range(START * 4, MAX_GATES * 4)->Unit(benchmark::kMicrosecond); @@ -223,8 +221,7 @@ void alternate_coset_fft_bench_parallel(State& state) noexcept { for (auto _ : state) { size_t idx = (size_t)numeric::get_msb((uint64_t)state.range(0)) - (size_t)numeric::get_msb(START); - barretenberg::polynomial_arithmetic::coset_fft( - globals.data, evaluation_domains[idx - 2], evaluation_domains[idx - 2], 4); + bb::polynomial_arithmetic::coset_fft(globals.data, evaluation_domains[idx - 2], evaluation_domains[idx - 2], 4); } } BENCHMARK(alternate_coset_fft_bench_parallel) @@ -236,7 +233,7 @@ void fft_bench_parallel(State& state) noexcept { for (auto _ : state) { size_t idx = (size_t)numeric::get_msb((uint64_t)state.range(0)) - (size_t)numeric::get_msb(START); - barretenberg::polynomial_arithmetic::fft(globals.data, evaluation_domains[idx]); + bb::polynomial_arithmetic::fft(globals.data, evaluation_domains[idx]); } } BENCHMARK(fft_bench_parallel)->RangeMultiplier(2)->Range(START * 4, MAX_GATES * 4)->Unit(benchmark::kMicrosecond); @@ -245,7 +242,7 @@ void fft_bench_serial(State& state) noexcept { for (auto _ : state) { size_t idx = (size_t)numeric::get_msb((uint64_t)state.range(0)) - (size_t)numeric::get_msb(START); - barretenberg::polynomial_arithmetic::fft_inner_serial( + bb::polynomial_arithmetic::fft_inner_serial( { globals.data }, evaluation_domains[idx].thread_size, evaluation_domains[idx].get_round_roots()); } } diff --git a/barretenberg/cpp/src/barretenberg/polynomials/pow.hpp b/barretenberg/cpp/src/barretenberg/polynomials/pow.hpp index a61bc21ba85..2efeef68588 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/pow.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/pow.hpp @@ -3,7 +3,7 @@ #include "barretenberg/common/thread_utils.hpp" #include #include -namespace barretenberg { +namespace bb { /** * @brief Succinct representation of the `pow` polynomial that can be partially evaluated variable-by-variable. @@ -151,4 +151,4 @@ template struct PowPolynomial { }); } }; -} // namespace barretenberg \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp index f73edfeea0d..b6aeff91265 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp @@ -2,9 +2,9 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -namespace barretenberg::test_pow { +namespace bb::test_pow { -using FF = barretenberg::fr; +using FF = bb::fr; TEST(PowPolynomial, FullPowConsistency) { @@ -39,4 +39,4 @@ TEST(PowPolynomial, PowPolynomialsOnPowers) auto expected_values = std::vector{ 1, 2, 4, 8, 16, 32, 64, 128 }; EXPECT_EQ(expected_values, pow.pow_betas); } -} // namespace barretenberg::test_pow +} // namespace bb::test_pow diff --git a/barretenberg/cpp/src/barretenberg/polynomials/serialize.hpp b/barretenberg/cpp/src/barretenberg/polynomials/serialize.hpp index ac6d400fc58..afbd340e025 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/serialize.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/serialize.hpp @@ -1,7 +1,7 @@ #pragma once #include "polynomial.hpp" -namespace barretenberg { +namespace bb { // Highly optimized read / write of polynomials in little endian montgomery form. template inline void read(B& buf, polynomial& p) @@ -67,4 +67,4 @@ inline void write(std::ostream& os, polynomial const& p) os.write((char*)&p[0], (std::streamsize)len); } -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/polynomials/univariate.hpp b/barretenberg/cpp/src/barretenberg/polynomials/univariate.hpp index a3770cad6b9..188c0bed3c4 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/univariate.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/univariate.hpp @@ -4,7 +4,7 @@ #include "barretenberg/polynomials/barycentric.hpp" #include -namespace barretenberg { +namespace bb { /** * @brief A view of a univariate, also used to truncate univariates. @@ -496,4 +496,4 @@ template std::array array_to_array return array_to_array_aux(elements, std::make_index_sequence()); }; -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp index 238470370a3..5b35de5e68a 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp @@ -2,14 +2,14 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -namespace barretenberg::test_univariate { +namespace bb::test_univariate { template class UnivariateTest : public testing::Test { public: template using UnivariateView = UnivariateView; }; -using FieldTypes = testing::Types; +using FieldTypes = testing::Types; TYPED_TEST_SUITE(UnivariateTest, FieldTypes); #define UNIVARIATE_TESTS_ALIASES using FF = TypeParam; @@ -173,4 +173,4 @@ TYPED_TEST(UnivariateTest, EvaluationCustomDomain) }(); } -} // namespace barretenberg::test_univariate +} // namespace bb::test_univariate diff --git a/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp b/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp index df0cd534a5f..0a5c4ec1089 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp @@ -37,7 +37,7 @@ template class Standard { static constexpr size_t NUM_WIRES = 3; static constexpr size_t NUM_SELECTORS = 5; using FF = FF_; - using SelectorType = std::vector>; + using SelectorType = std::vector>; std::vector selectors; @@ -75,7 +75,7 @@ template class Ultra { static constexpr size_t NUM_WIRES = 4; static constexpr size_t NUM_SELECTORS = 11; using FF = FF_; - using SelectorType = std::vector>; + using SelectorType = std::vector>; private: std::array selectors; @@ -138,7 +138,7 @@ template class UltraHonk { static constexpr size_t NUM_WIRES = 4; static constexpr size_t NUM_SELECTORS = 14; using FF = FF_; - using SelectorType = std::vector>; + using SelectorType = std::vector>; private: std::array selectors; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/gate_data.hpp b/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/gate_data.hpp index 1efca4931e7..d13bee687bb 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/gate_data.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/gate_data.hpp @@ -60,7 +60,7 @@ template struct poly_triple_ { friend bool operator==(poly_triple_ const& lhs, poly_triple_ const& rhs) = default; }; -using poly_triple = poly_triple_; +using poly_triple = poly_triple_; struct ecc_op_tuple { uint32_t op; uint32_t x_lo; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.cpp index 0b469a3b08d..11b6193d2e5 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.cpp @@ -43,6 +43,6 @@ void CircuitBuilderBase::assert_equal(const uint32_t a_variable_idx, real_variable_tags[a_real_idx] = real_variable_tags[b_real_idx]; } // Standard honk/ plonk instantiation -template class CircuitBuilderBase; +template class CircuitBuilderBase; template class CircuitBuilderBase; } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp index 12bbc8be31a..f93ae3806df 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp @@ -14,8 +14,7 @@ static constexpr uint32_t DUMMY_TAG = 0; template class CircuitBuilderBase { public: using FF = FF_; - using EmbeddedCurve = - std::conditional_t, curve::BN254, curve::Grumpkin>; + using EmbeddedCurve = std::conditional_t, curve::BN254, curve::Grumpkin>; size_t num_gates = 0; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp index ab05d63811c..b7619c73333 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp index bbc5836c221..a071695d1e9 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp @@ -15,7 +15,7 @@ #include "barretenberg/relations/generated/AvmMini/avm_mini.hpp" #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp index c43b7de5146..def07fd86c7 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp @@ -16,7 +16,7 @@ #include "barretenberg/relations/generated/Toy/toy_avm.hpp" #include "barretenberg/relations/generated/Toy/two_column_perm.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.cpp index ee95fd30105..70e3398e615 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.cpp @@ -552,7 +552,7 @@ void GoblinTranslatorCircuitBuilder::create_accumulation_gate(const Accumulation num_gates += 2; // Check that all the wires are filled equally - barretenberg::constexpr_for<0, TOTAL_COUNT, 1>([&]() { ASSERT(std::get(wires).size() == num_gates); }); + bb::constexpr_for<0, TOTAL_COUNT, 1>([&]() { ASSERT(std::get(wires).size() == num_gates); }); } /** @@ -568,7 +568,7 @@ GoblinTranslatorCircuitBuilder::AccumulationInput compute_witness_values_for_one Fq batching_challenge_v, Fq evaluation_input_x) { - using Fr = barretenberg::fr; + using Fr = bb::fr; // Get the Opcode value Fr op(ecc_op.get_opcode_value()); @@ -601,7 +601,7 @@ GoblinTranslatorCircuitBuilder::AccumulationInput compute_witness_values_for_one } void GoblinTranslatorCircuitBuilder::feed_ecc_op_queue_into_circuit(std::shared_ptr ecc_op_queue) { - using Fq = barretenberg::fq; + using Fq = bb::fq; std::vector accumulator_trace; Fq current_accumulator(0); if (ecc_op_queue->raw_ops.empty()) { @@ -1065,14 +1065,6 @@ bool GoblinTranslatorCircuitBuilder::check_circuit() } return true; }; -template GoblinTranslatorCircuitBuilder::AccumulationInput generate_witness_values(barretenberg::fr, - barretenberg::fr, - barretenberg::fr, - barretenberg::fr, - barretenberg::fr, - barretenberg::fr, - barretenberg::fr, - barretenberg::fq, - barretenberg::fq, - barretenberg::fq); +template GoblinTranslatorCircuitBuilder::AccumulationInput generate_witness_values( + bb::fr, bb::fr, bb::fr, bb::fr, bb::fr, bb::fr, bb::fr, bb::fq, bb::fq, bb::fq); } // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp index e386fc8f11e..6fd3c9be5bc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp @@ -73,10 +73,10 @@ namespace proof_system { * microlimb. * */ -class GoblinTranslatorCircuitBuilder : public CircuitBuilderBase { +class GoblinTranslatorCircuitBuilder : public CircuitBuilderBase { // We don't need templating for Goblin - using Fr = barretenberg::fr; - using Fq = barretenberg::fq; + using Fr = bb::fr; + using Fq = bb::fq; using Arithmetization = arithmetization::GoblinTranslator; public: @@ -326,7 +326,7 @@ class GoblinTranslatorCircuitBuilder : public CircuitBuilderBase>, NUM_WIRES> wires; + std::array>, NUM_WIRES> wires; /** * @brief Construct a new Goblin Translator Circuit Builder object @@ -432,9 +432,9 @@ class GoblinTranslatorCircuitBuilder : public CircuitBuilderBase RESULT_ROW); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp index cd019284069..eedc47e69bd 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp @@ -5,7 +5,7 @@ #include #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); } @@ -78,9 +78,9 @@ TEST(GoblinTranslatorCircuitBuilder, CircuitBuilderBaseCase) */ TEST(GoblinTranslatorCircuitBuilder, SeveralOperationCorrectness) { - using point = barretenberg::g1::affine_element; - using scalar = barretenberg::fr; - using Fq = barretenberg::fq; + using point = bb::g1::affine_element; + using scalar = bb::fr; + using Fq = bb::fq; auto P1 = point::random_element(); auto P2 = point::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp index 6c3911f6d05..089521b36fb 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp @@ -5,7 +5,7 @@ #include #include -using namespace barretenberg; +using namespace bb; using namespace crypto; namespace proof_system { @@ -92,7 +92,7 @@ template void GoblinUltraCircuitBuilder_::add_gates_to_ensure_ * @param point Point to be added into the accumulator */ template -ecc_op_tuple GoblinUltraCircuitBuilder_::queue_ecc_add_accum(const barretenberg::g1::affine_element& point) +ecc_op_tuple GoblinUltraCircuitBuilder_::queue_ecc_add_accum(const bb::g1::affine_element& point) { // Add raw op to queue op_queue->add_accumulate(point); @@ -113,8 +113,7 @@ ecc_op_tuple GoblinUltraCircuitBuilder_::queue_ecc_add_accum(const barretenb * @return ecc_op_tuple encoding the point and scalar inputs to the mul accum */ template -ecc_op_tuple GoblinUltraCircuitBuilder_::queue_ecc_mul_accum(const barretenberg::g1::affine_element& point, - const FF& scalar) +ecc_op_tuple GoblinUltraCircuitBuilder_::queue_ecc_mul_accum(const bb::g1::affine_element& point, const FF& scalar) { // Add raw op to op queue op_queue->mul_accumulate(point, scalar); @@ -540,5 +539,5 @@ template bool GoblinUltraCircuitBuilder_::check_circuit() return result; } -template class GoblinUltraCircuitBuilder_; +template class GoblinUltraCircuitBuilder_; } // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp index 214d16dde80..75813993f5a 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp @@ -5,7 +5,7 @@ namespace proof_system { -using namespace barretenberg; +using namespace bb; template class GoblinUltraCircuitBuilder_ : public UltraCircuitBuilder_> { public: @@ -194,5 +194,5 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui bool check_circuit(); }; -using GoblinUltraCircuitBuilder = GoblinUltraCircuitBuilder_; +using GoblinUltraCircuitBuilder = GoblinUltraCircuitBuilder_; } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp index 87529305ecf..2225fe5e9ed 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp @@ -1,7 +1,7 @@ #include "goblin_ultra_circuit_builder.hpp" #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp index 3f930ec331e..78766044dc6 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp @@ -7,7 +7,7 @@ #include "barretenberg/serialize/cbind.hpp" #include "barretenberg/serialize/msgpack.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system { @@ -558,7 +558,7 @@ template msgpack::sbuffer StandardCircuitBuilder_::export_circ return buffer; } -template class StandardCircuitBuilder_; +template class StandardCircuitBuilder_; template class StandardCircuitBuilder_; } // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp index 90b891bb936..27676ace478 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp @@ -23,11 +23,11 @@ template class StandardCircuitBuilder_ : public CircuitBuilderBase static constexpr merkle::HashType merkle_hash_type = merkle::HashType::FIXED_BASE_PEDERSEN; static constexpr pedersen::CommitmentType commitment_type = pedersen::CommitmentType::FIXED_BASE_PEDERSEN; - std::array>, NUM_WIRES> wires; + std::array>, NUM_WIRES> wires; Arithmetization selectors; - using WireVector = std::vector>; - using SelectorVector = std::vector>; + using WireVector = std::vector>; + using SelectorVector = std::vector>; WireVector& w_l() { return std::get<0>(wires); }; WireVector& w_r() { return std::get<1>(wires); }; @@ -146,6 +146,6 @@ template class StandardCircuitBuilder_ : public CircuitBuilderBase } circuit_schema; }; -using StandardCircuitBuilder = StandardCircuitBuilder_; +using StandardCircuitBuilder = StandardCircuitBuilder_; using StandardGrumpkinCircuitBuilder = StandardCircuitBuilder_; } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp index 5080fc3bcf5..ac14ff7a554 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp index addf8df4d2f..bb34be27fd5 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp @@ -5,7 +5,7 @@ #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp index d3d9767bb74..cb764ccd454 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp @@ -10,7 +10,7 @@ #include #include -using namespace barretenberg; +using namespace bb; namespace proof_system { @@ -3484,8 +3484,8 @@ template bool UltraCircuitBuilder_:: circuit_backup.restore_prefinilized_state(this); return result; } -template class UltraCircuitBuilder_>; -template class UltraCircuitBuilder_>; +template class UltraCircuitBuilder_>; +template class UltraCircuitBuilder_>; // To enable this we need to template plookup // template class UltraCircuitBuilder_; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp index 63f65ed23d8..50d2defb137 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp @@ -25,7 +25,7 @@ template struct non_native_field_witnesses { FF modulus; }; -using namespace barretenberg; +using namespace bb; template class UltraCircuitBuilder_ : public CircuitBuilderBase { @@ -279,8 +279,8 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase>; - using SelectorVector = std::vector>; + using WireVector = std::vector>; + using SelectorVector = std::vector>; std::vector public_inputs; std::vector variables; @@ -569,7 +569,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase>, NUM_WIRES> wires; + std::array>, NUM_WIRES> wires; Arithmetization selectors; using WireVector = std::vector>; @@ -992,7 +992,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase&, std::vector&, std::vector&), std::array (*get_values_from_key)(const std::array)); @@ -1166,5 +1166,5 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase>; +using UltraCircuitBuilder = UltraCircuitBuilder_>; } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp index 6af8c8ad259..b1c3bae14f5 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include -using namespace barretenberg; +using namespace bb; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -44,7 +44,7 @@ TEST(ultra_circuit_constructor, create_gates_from_plookup_accumulators) UltraCircuitBuilder circuit_builder = UltraCircuitBuilder(); - barretenberg::fr input_value = fr::random_element(); + bb::fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -140,9 +140,9 @@ TEST(ultra_circuit_constructor, test_elliptic_gate) typedef grumpkin::g1::element element; UltraCircuitBuilder circuit_constructor = UltraCircuitBuilder(); - affine_element p1 = crypto::pedersen_commitment::commit_native({ barretenberg::fr(1) }, 0); + affine_element p1 = crypto::pedersen_commitment::commit_native({ bb::fr(1) }, 0); - affine_element p2 = crypto::pedersen_commitment::commit_native({ barretenberg::fr(1) }, 1); + affine_element p2 = crypto::pedersen_commitment::commit_native({ bb::fr(1) }, 1); affine_element p3(element(p1) + element(p2)); uint32_t x1 = circuit_constructor.add_variable(p1.x); @@ -171,7 +171,7 @@ TEST(ultra_circuit_constructor, test_elliptic_double_gate) typedef grumpkin::g1::element element; UltraCircuitBuilder circuit_constructor = UltraCircuitBuilder(); - affine_element p1 = crypto::pedersen_commitment::commit_native({ barretenberg::fr(1) }, 0); + affine_element p1 = crypto::pedersen_commitment::commit_native({ bb::fr(1) }, 0); affine_element p3(element(p1).dbl()); uint32_t x1 = circuit_constructor.add_variable(p1.x); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp index ee3cbcef0a3..dbfaf588821 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.hpp @@ -31,7 +31,7 @@ void construct_selector_polynomials(const typename Flavor::CircuitBuilder& circu gate_offset += num_ecc_op_gates; const size_t op_gate_offset = zero_row_offset; // The op gate selector is simply the indicator on the domain [offset, num_ecc_op_gates + offset - 1] - barretenberg::polynomial ecc_op_selector(proving_key->circuit_size); + bb::polynomial ecc_op_selector(proving_key->circuit_size); for (size_t i = 0; i < num_ecc_op_gates; ++i) { ecc_op_selector[i + op_gate_offset] = 1; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp index 0b5788b8ff7..be9d251a123 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp @@ -14,7 +14,7 @@ class ComposerLibTests : public ::testing::Test { using FF = typename Flavor::FF; Flavor::CircuitBuilder circuit_constructor; Flavor::ProvingKey proving_key = []() { - auto crs_factory = barretenberg::srs::factories::CrsFactory(); + auto crs_factory = bb::srs::factories::CrsFactory(); auto crs = crs_factory.get_prover_crs(4); return Flavor::ProvingKey(/*circuit_size=*/8, /*num_public_inputs=*/0); }(); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp index 8383586d3cb..3e89a8cd20b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp @@ -65,7 +65,7 @@ namespace { * @brief Compute all CyclicPermutations of the circuit. Each CyclicPermutation represents the indices of the values in * the witness wires that must have the same value. using Curve = curve::BN254; using FF = Curve::ScalarField; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; * * @tparam program_width Program width * @@ -324,9 +324,9 @@ void compute_honk_style_permutation_lagrange_polynomials_from_mapping( * @param small_domain The domain we base our polynomial in. * * */ -inline void compute_standard_plonk_lagrange_polynomial(barretenberg::polynomial& output, +inline void compute_standard_plonk_lagrange_polynomial(bb::polynomial& output, const std::vector& permutation, - const barretenberg::evaluation_domain& small_domain) + const bb::evaluation_domain& small_domain) { if (output.size() < permutation.size()) { throw_or_abort("Permutation polynomial size is insufficient to store permutations."); @@ -338,7 +338,7 @@ inline void compute_standard_plonk_lagrange_polynomial(barretenberg::polynomial& // 1 = right // 2 = output ASSERT(small_domain.log2_size > 1); - const barretenberg::fr* roots = small_domain.get_round_roots()[small_domain.log2_size - 2]; + const bb::fr* roots = small_domain.get_round_roots()[small_domain.log2_size - 2]; const size_t root_size = small_domain.size >> 1UL; const size_t log2_root_size = static_cast(numeric::get_msb(root_size)); @@ -377,14 +377,14 @@ inline void compute_standard_plonk_lagrange_polynomial(barretenberg::polynomial& // As per the paper which modifies plonk to include the public inputs in a permutation argument, the permutation // `σ` is modified to `σ'`, where `σ'` maps all public inputs to a set of l distinct ζ elements which are // disjoint from H ∪ k1·H ∪ k2·H. - output[i] *= barretenberg::fr::external_coset_generator(); + output[i] *= bb::fr::external_coset_generator(); } else if (permutation[i].is_tag) { - output[i] *= barretenberg::fr::tag_coset_generator(); + output[i] *= bb::fr::tag_coset_generator(); } else { { const uint32_t column_index = permutation[i].column_index; if (column_index > 0) { - output[i] *= barretenberg::fr::coset_generator(column_index - 1); + output[i] *= bb::fr::coset_generator(column_index - 1); } } } @@ -407,7 +407,7 @@ void compute_plonk_permutation_lagrange_polynomials_from_mapping( { for (size_t i = 0; i < program_width; i++) { std::string index = std::to_string(i + 1); - barretenberg::polynomial polynomial_lagrange(key->circuit_size); + bb::polynomial polynomial_lagrange(key->circuit_size); compute_standard_plonk_lagrange_polynomial(polynomial_lagrange, mappings[i], key->small_domain); key->polynomial_store.put(label + "_" + index + "_lagrange", polynomial_lagrange.share()); } @@ -432,12 +432,12 @@ void compute_monomial_and_coset_fft_polynomials_from_lagrange(std::string label, // Construct permutation polynomials in lagrange base auto sigma_polynomial_lagrange = key->polynomial_store.get(prefix + "_lagrange"); // Compute permutation polynomial monomial form - barretenberg::polynomial sigma_polynomial(key->circuit_size); - barretenberg::polynomial_arithmetic::ifft( - (barretenberg::fr*)&sigma_polynomial_lagrange[0], &sigma_polynomial[0], key->small_domain); + bb::polynomial sigma_polynomial(key->circuit_size); + bb::polynomial_arithmetic::ifft( + (bb::fr*)&sigma_polynomial_lagrange[0], &sigma_polynomial[0], key->small_domain); // Compute permutation polynomial coset FFT form - barretenberg::polynomial sigma_fft(sigma_polynomial, key->large_domain.size); + bb::polynomial sigma_fft(sigma_polynomial, key->large_domain.size); sigma_fft.coset_fft(key->large_domain); key->polynomial_store.put(prefix, sigma_polynomial.share()); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp index cdd8d362c06..b03fd49ee06 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp @@ -14,8 +14,7 @@ class PermutationHelperTests : public ::testing::Test { using FF = typename Flavor::FF; using ProvingKey = Flavor::ProvingKey; Flavor::CircuitBuilder circuit_constructor; - barretenberg::srs::factories::CrsFactory crs_factory = - barretenberg::srs::factories::CrsFactory(); + bb::srs::factories::CrsFactory crs_factory = bb::srs::factories::CrsFactory(); std::shared_ptr proving_key; virtual void SetUp() diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp index 0f8b46dbcf3..93f0cf5b9cf 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp @@ -150,19 +150,18 @@ void compute_grand_products(std::shared_ptr& key, using FF = typename Flavor::FF; constexpr size_t NUM_RELATIONS = std::tuple_size{}; - barretenberg::constexpr_for<0, NUM_RELATIONS, 1>([&]() { + bb::constexpr_for<0, NUM_RELATIONS, 1>([&]() { using GrandProdRelation = typename std::tuple_element::type; // Assign the grand product polynomial to the relevant std::span member of `full_polynomials` (and its shift) // For example, for UltraPermutationRelation, this will be `full_polynomials.z_perm` // For example, for LookupRelation, this will be `full_polynomials.z_lookup` - barretenberg::Polynomial& full_polynomial = - GrandProdRelation::get_grand_product_polynomial(full_polynomials); + bb::Polynomial& full_polynomial = GrandProdRelation::get_grand_product_polynomial(full_polynomials); auto& key_polynomial = GrandProdRelation::get_grand_product_polynomial(*key); full_polynomial = key_polynomial.share(); compute_grand_product(key->circuit_size, full_polynomials, relation_parameters); - barretenberg::Polynomial& full_polynomial_shift = + bb::Polynomial& full_polynomial_shift = GrandProdRelation::get_shifted_grand_product_polynomial(full_polynomials); full_polynomial_shift = key_polynomial.shifted(); }); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index da0d6b3a203..8b40faff394 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -12,7 +12,7 @@ namespace grand_product_library_tests { template class GrandProductTests : public testing::Test { - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; public: /** @@ -339,7 +339,7 @@ template class GrandProductTests : public testing::Test { }; }; -using FieldTypes = testing::Types; +using FieldTypes = testing::Types; TYPED_TEST_SUITE(GrandProductTests, FieldTypes); TYPED_TEST(GrandProductTests, GrandProductPermutation) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp index 2b41923ecd9..89f70c93711 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp @@ -5,16 +5,16 @@ namespace proof_system::test_flavor { TEST(ECCOpQueueTest, Basic) { ECCOpQueue op_queue; - op_queue.add_accumulate(barretenberg::g1::affine_one); - EXPECT_EQ(op_queue.raw_ops[0].base_point, barretenberg::g1::affine_one); + op_queue.add_accumulate(bb::g1::affine_one); + EXPECT_EQ(op_queue.raw_ops[0].base_point, bb::g1::affine_one); op_queue.empty_row(); EXPECT_EQ(op_queue.raw_ops[1].add, false); } TEST(ECCOpQueueTest, InternalAccumulatorCorrectness) { - using point = barretenberg::g1::affine_element; - using scalar = barretenberg::fr; + using point = bb::g1::affine_element; + using scalar = bb::fr; // Compute a simple point accumulation natively auto P1 = point::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp index 7c714effd43..3306338e9b9 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp @@ -15,10 +15,10 @@ static constexpr uint64_t aes_normalization_table[AES_BASE]{ 1, 0, 0, 0, 0, 0, 0, 0, 0, }; -inline std::array get_aes_sparse_values_from_key(const std::array key) +inline std::array get_aes_sparse_values_from_key(const std::array key) { const auto sparse = numeric::map_into_sparse_form(uint64_t(key[0])); - return { barretenberg::fr(sparse), barretenberg::fr(0) }; + return { bb::fr(sparse), bb::fr(0) }; } inline BasicTable generate_aes_sparse_table(BasicTableId id, const size_t table_index) @@ -31,22 +31,22 @@ inline BasicTable generate_aes_sparse_table(BasicTableId id, const size_t table_ for (uint64_t i = 0; i < table.size; ++i) { uint64_t left = i; const auto right = numeric::map_into_sparse_form((uint8_t)i); - table.column_1.emplace_back(barretenberg::fr(left)); - table.column_2.emplace_back(barretenberg::fr(0)); - table.column_3.emplace_back(barretenberg::fr(right)); + table.column_1.emplace_back(bb::fr(left)); + table.column_2.emplace_back(bb::fr(0)); + table.column_3.emplace_back(bb::fr(right)); } table.get_values_from_key = &get_aes_sparse_values_from_key; - table.column_1_step_size = barretenberg::fr(256); - table.column_2_step_size = barretenberg::fr(0); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(256); + table.column_2_step_size = bb::fr(0); + table.column_3_step_size = bb::fr(0); return table; } -inline std::array get_aes_sparse_normalization_values_from_key(const std::array key) +inline std::array get_aes_sparse_normalization_values_from_key(const std::array key) { const auto byte = numeric::map_from_sparse_form(key[0]); - return { barretenberg::fr(numeric::map_into_sparse_form(byte)), barretenberg::fr(0) }; + return { bb::fr(numeric::map_into_sparse_form(byte)), bb::fr(0) }; } inline BasicTable generate_aes_sparse_normalization_table(BasicTableId id, const size_t table_index) @@ -70,7 +70,7 @@ inline BasicTable generate_aes_sparse_normalization_table(BasicTableId id, const uint64_t right = i_normalized + j_normalized + k_normalized + m_normalized; table.column_1.emplace_back(left); table.column_2.emplace_back(right); - table.column_3.emplace_back(barretenberg::fr(0)); + table.column_3.emplace_back(bb::fr(0)); } } } @@ -79,22 +79,22 @@ inline BasicTable generate_aes_sparse_normalization_table(BasicTableId id, const table.use_twin_keys = false; table.get_values_from_key = &get_aes_sparse_normalization_values_from_key; - table.column_1_step_size = barretenberg::fr(6561); - table.column_2_step_size = barretenberg::fr(6561); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(6561); + table.column_2_step_size = bb::fr(6561); + table.column_3_step_size = bb::fr(0); return table; } inline MultiTable get_aes_normalization_table(const MultiTableId id = AES_NORMALIZE) { const size_t num_entries = 2; - std::vector column_1_coefficients; - std::vector column_2_coefficients; - std::vector column_3_coefficients; + std::vector column_1_coefficients; + std::vector column_2_coefficients; + std::vector column_3_coefficients; for (size_t i = 0; i < num_entries; ++i) { - column_1_coefficients.emplace_back(barretenberg::fr(AES_BASE).pow(4 * i)); - column_2_coefficients.emplace_back(barretenberg::fr(AES_BASE).pow(4 * i)); + column_1_coefficients.emplace_back(bb::fr(AES_BASE).pow(4 * i)); + column_2_coefficients.emplace_back(bb::fr(AES_BASE).pow(4 * i)); column_3_coefficients.emplace_back(0); } @@ -124,13 +124,13 @@ inline MultiTable get_aes_input_table(const MultiTableId id = AES_INPUT) return table; } -inline std::array get_aes_sbox_values_from_key(const std::array key) +inline std::array get_aes_sbox_values_from_key(const std::array key) { const auto byte = numeric::map_from_sparse_form(key[0]); uint8_t sbox_value = crypto::aes128::sbox[(uint8_t)byte]; uint8_t swizzled = ((uint8_t)(sbox_value << 1) ^ (uint8_t)(((sbox_value >> 7) & 1) * 0x1b)); - return { barretenberg::fr(numeric::map_into_sparse_form(sbox_value)), - barretenberg::fr(numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled))) }; + return { bb::fr(numeric::map_into_sparse_form(sbox_value)), + bb::fr(numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled))) }; } inline BasicTable generate_aes_sbox_table(BasicTableId id, const size_t table_index) @@ -147,15 +147,15 @@ inline BasicTable generate_aes_sbox_table(BasicTableId id, const size_t table_in const auto second = numeric::map_into_sparse_form(sbox_value); const auto third = numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled)); - table.column_1.emplace_back(barretenberg::fr(first)); - table.column_2.emplace_back(barretenberg::fr(second)); - table.column_3.emplace_back(barretenberg::fr(third)); + table.column_1.emplace_back(bb::fr(first)); + table.column_2.emplace_back(bb::fr(second)); + table.column_3.emplace_back(bb::fr(third)); } table.get_values_from_key = get_aes_sbox_values_from_key; - table.column_1_step_size = barretenberg::fr(0); - table.column_2_step_size = barretenberg::fr(0); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(0); + table.column_2_step_size = bb::fr(0); + table.column_3_step_size = bb::fr(0); return table; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp index 39df081ca01..4cea760b45e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp @@ -17,7 +17,7 @@ static constexpr size_t SIZE_OF_LAST_SLICE = (1UL << BITS_IN_LAST_SLICE); * that the XOR operation works only on the two least significant bits. */ template -inline std::array get_xor_rotate_values_from_key(const std::array key) +inline std::array get_xor_rotate_values_from_key(const std::array key) { uint64_t filtered_key0 = filter ? key[0] & 3ULL : key[0]; uint64_t filtered_key1 = filter ? key[1] & 3ULL : key[1]; @@ -113,18 +113,17 @@ inline MultiTable get_blake2s_xor_table(const MultiTableId id = BLAKE_XOR) inline MultiTable get_blake2s_xor_rotate_16_table(const MultiTableId id = BLAKE_XOR_ROTATE_16) { const uint64_t base = 1 << 6; - constexpr barretenberg::fr coefficient_16 = barretenberg::fr(1) / barretenberg::fr(1 << 16); + constexpr bb::fr coefficient_16 = bb::fr(1) / bb::fr(1 << 16); - std::vector column_1_coefficients{ barretenberg::fr(1), barretenberg::fr(1 << 6), - barretenberg::fr(1 << 12), barretenberg::fr(1 << 18), - barretenberg::fr(1 << 24), barretenberg::fr(1 << 30) }; + std::vector column_1_coefficients{ bb::fr(1), bb::fr(1 << 6), bb::fr(1 << 12), + bb::fr(1 << 18), bb::fr(1 << 24), bb::fr(1 << 30) }; - std::vector column_3_coefficients{ barretenberg::fr(1), - barretenberg::fr(1 << 6), - coefficient_16, - coefficient_16 * barretenberg::fr(1 << 2), - coefficient_16 * barretenberg::fr(1 << 8), - coefficient_16 * barretenberg::fr(1 << 14) }; + std::vector column_3_coefficients{ bb::fr(1), + bb::fr(1 << 6), + coefficient_16, + coefficient_16 * bb::fr(1 << 2), + coefficient_16 * bb::fr(1 << 8), + coefficient_16 * bb::fr(1 << 14) }; MultiTable table(column_1_coefficients, column_1_coefficients, column_3_coefficients); @@ -149,18 +148,17 @@ inline MultiTable get_blake2s_xor_rotate_16_table(const MultiTableId id = BLAKE_ inline MultiTable get_blake2s_xor_rotate_8_table(const MultiTableId id = BLAKE_XOR_ROTATE_8) { const uint64_t base = 1 << 6; - constexpr barretenberg::fr coefficient_24 = barretenberg::fr(1) / barretenberg::fr(1 << 24); + constexpr bb::fr coefficient_24 = bb::fr(1) / bb::fr(1 << 24); - std::vector column_1_coefficients{ barretenberg::fr(1), barretenberg::fr(1 << 6), - barretenberg::fr(1 << 12), barretenberg::fr(1 << 18), - barretenberg::fr(1 << 24), barretenberg::fr(1 << 30) }; + std::vector column_1_coefficients{ bb::fr(1), bb::fr(1 << 6), bb::fr(1 << 12), + bb::fr(1 << 18), bb::fr(1 << 24), bb::fr(1 << 30) }; - std::vector column_3_coefficients{ barretenberg::fr(1), - coefficient_24, - coefficient_24 * barretenberg::fr(1 << 4), - coefficient_24 * barretenberg::fr(1 << (4 + 6)), - coefficient_24 * barretenberg::fr(1 << (4 + 12)), - coefficient_24 * barretenberg::fr(1 << (4 + 18)) }; + std::vector column_3_coefficients{ bb::fr(1), + coefficient_24, + coefficient_24 * bb::fr(1 << 4), + coefficient_24 * bb::fr(1 << (4 + 6)), + coefficient_24 * bb::fr(1 << (4 + 12)), + coefficient_24 * bb::fr(1 << (4 + 18)) }; MultiTable table(column_1_coefficients, column_1_coefficients, column_3_coefficients); @@ -185,18 +183,17 @@ inline MultiTable get_blake2s_xor_rotate_8_table(const MultiTableId id = BLAKE_X inline MultiTable get_blake2s_xor_rotate_7_table(const MultiTableId id = BLAKE_XOR_ROTATE_7) { const uint64_t base = 1 << 6; - constexpr barretenberg::fr coefficient_25 = barretenberg::fr(1) / barretenberg::fr(1 << 25); - - std::vector column_1_coefficients{ barretenberg::fr(1), barretenberg::fr(1 << 6), - barretenberg::fr(1 << 12), barretenberg::fr(1 << 18), - barretenberg::fr(1 << 24), barretenberg::fr(1 << 30) }; - - std::vector column_3_coefficients{ barretenberg::fr(1), - coefficient_25, - coefficient_25 * barretenberg::fr(1 << 5), - coefficient_25 * barretenberg::fr(1 << (5 + 6)), - coefficient_25 * barretenberg::fr(1 << (5 + 12)), - coefficient_25 * barretenberg::fr(1 << (5 + 18)) }; + constexpr bb::fr coefficient_25 = bb::fr(1) / bb::fr(1 << 25); + + std::vector column_1_coefficients{ bb::fr(1), bb::fr(1 << 6), bb::fr(1 << 12), + bb::fr(1 << 18), bb::fr(1 << 24), bb::fr(1 << 30) }; + + std::vector column_3_coefficients{ bb::fr(1), + coefficient_25, + coefficient_25 * bb::fr(1 << 5), + coefficient_25 * bb::fr(1 << (5 + 6)), + coefficient_25 * bb::fr(1 << (5 + 12)), + coefficient_25 * bb::fr(1 << (5 + 18)) }; MultiTable table(column_1_coefficients, column_1_coefficients, column_3_coefficients); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp index e44ea72e8fb..50ba5fa83f8 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp @@ -21,9 +21,9 @@ namespace dummy_tables { * * @tparam id The id of the basic table used to parametrize the values for 2 fake tables * @param key The key that we are looking up - * @return std::array + * @return std::array */ -template inline std::array get_value_from_key(const std::array key) +template inline std::array get_value_from_key(const std::array key) { return { key[0] * 3 + key[1] * 4 + id * 0x1337ULL, 0ULL }; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp index a3afa36a7fc..1309aafb5d5 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp @@ -152,7 +152,7 @@ std::optional table::get_generator_offset_for_tabl return std::nullopt; } -using function_ptr = std::array (*)(const std::array); +using function_ptr = std::array (*)(const std::array); using function_ptr_table = std::array, table::NUM_FIXED_BASE_MULTI_TABLES>; /** @@ -165,8 +165,8 @@ using function_ptr_table = constexpr function_ptr_table make_function_pointer_table() { function_ptr_table table; - barretenberg::constexpr_for<0, table::NUM_FIXED_BASE_MULTI_TABLES, 1>([&]() { - barretenberg::constexpr_for<0, table::MAX_NUM_TABLES_IN_MULTITABLE, 1>( + bb::constexpr_for<0, table::NUM_FIXED_BASE_MULTI_TABLES, 1>([&]() { + bb::constexpr_for<0, table::MAX_NUM_TABLES_IN_MULTITABLE, 1>( [&]() { table[i][j] = &table::get_basic_fixed_base_table_values; }); }); return table; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp index 4b4876b8f31..d147b3e9074 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp @@ -74,7 +74,7 @@ class table : public FixedBaseParams { template static MultiTable get_fixed_base_table(MultiTableId id); template - static std::array get_basic_fixed_base_table_values(const std::array key) + static std::array get_basic_fixed_base_table_values(const std::array key) { static_assert(multitable_index < NUM_FIXED_BASE_MULTI_TABLES); static_assert(table_index < get_num_bits_of_multi_table(multitable_index)); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp index 5db06fc8e78..f1a75bd3150 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp @@ -79,9 +79,9 @@ class Chi { * Used by the Plookup code to precompute lookup tables and generate witness values * * @param key (first element = table input. Second element is unused as this lookup does not have 2 keys per value) - * @return std::array table output (normalized input and normalized input / 11^8) + * @return std::array table output (normalized input and normalized input / 11^8) */ - static std::array get_chi_renormalization_values(const std::array key) + static std::array get_chi_renormalization_values(const std::array key) { uint64_t accumulator = 0; uint64_t input = key[0]; @@ -96,7 +96,7 @@ class Chi { base_shift *= BASE; } - return { barretenberg::fr(accumulator), barretenberg::fr(accumulator / divisor) }; + return { bb::fr(accumulator), bb::fr(accumulator / divisor) }; } /** @@ -184,9 +184,9 @@ class Chi { table.get_values_from_key = &get_chi_renormalization_values; constexpr uint64_t step_size = numeric::pow64(static_cast(BASE), TABLE_BITS); - table.column_1_step_size = barretenberg::fr(step_size); - table.column_2_step_size = barretenberg::fr(step_size); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(step_size); + table.column_2_step_size = bb::fr(step_size); + table.column_3_step_size = bb::fr(0); return table; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp index ce161d24ebf..8fdc116f99f 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp @@ -35,15 +35,15 @@ class KeccakInput { * Used by the Plookup code to precompute lookup tables and generate witness values * * @param key (first element = table input. Second element is unused as this lookup does not have 2 keys per value) - * @return std::array table output + * @return std::array table output */ - static std::array get_keccak_input_values(const std::array key) + static std::array get_keccak_input_values(const std::array key) { const uint256_t t0 = numeric::map_into_sparse_form(key[0]); constexpr size_t msb_shift = (64 % TABLE_BITS == 0) ? TABLE_BITS - 1 : (64 % TABLE_BITS) - 1; const uint256_t t1 = key[0] >> msb_shift; - return { barretenberg::fr(t0), barretenberg::fr(t1) }; + return { bb::fr(t0), bb::fr(t1) }; } /** @@ -65,9 +65,9 @@ class KeccakInput { for (uint64_t i = 0; i < table.size; ++i) { const uint64_t source = i; const auto target = numeric::map_into_sparse_form(source); - table.column_1.emplace_back(barretenberg::fr(source)); - table.column_2.emplace_back(barretenberg::fr(target)); - table.column_3.emplace_back(barretenberg::fr(source >> msb_shift)); + table.column_1.emplace_back(bb::fr(source)); + table.column_2.emplace_back(bb::fr(target)); + table.column_3.emplace_back(bb::fr(source >> msb_shift)); } table.get_values_from_key = &get_keccak_input_values; @@ -76,9 +76,9 @@ class KeccakInput { for (size_t i = 0; i < TABLE_BITS; ++i) { sparse_step_size *= BASE; } - table.column_1_step_size = barretenberg::fr((1 << TABLE_BITS)); - table.column_2_step_size = barretenberg::fr(sparse_step_size); - table.column_3_step_size = barretenberg::fr(sparse_step_size); + table.column_1_step_size = bb::fr((1 << TABLE_BITS)); + table.column_2_step_size = bb::fr(sparse_step_size); + table.column_3_step_size = bb::fr(sparse_step_size); return table; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp index 3aaebfcdc35..6c5d57429b8 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp @@ -106,8 +106,8 @@ class KeccakOutput { table.get_values_from_key = &sparse_tables::get_sparse_normalization_values; - table.column_1_step_size = barretenberg::fr(numeric::pow64(static_cast(BASE), TABLE_BITS)); - table.column_2_step_size = barretenberg::fr(((uint64_t)1 << TABLE_BITS)); + table.column_1_step_size = bb::fr(numeric::pow64(static_cast(BASE), TABLE_BITS)); + table.column_2_step_size = bb::fr(((uint64_t)1 << TABLE_BITS)); table.column_3_step_size = 0; return table; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp index 158c6119d61..96dd0f99ff6 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp @@ -83,9 +83,9 @@ template class Rho { * Used by the Plookup code to precompute lookup tables and generate witness values * * @param key (first element = table input. Second element is unused as this lookup does not have 2 keys per value) - * @return std::array table output (normalized input and normalized input / 11^TABLE_BITS - 1) + * @return std::array table output (normalized input and normalized input / 11^TABLE_BITS - 1) */ - static std::array get_rho_renormalization_values(const std::array key) + static std::array get_rho_renormalization_values(const std::array key) { uint64_t accumulator = 0; uint64_t input = key[0]; @@ -100,7 +100,7 @@ template class Rho { base_shift *= BASE; } - return { barretenberg::fr(accumulator), barretenberg::fr(accumulator / divisor) }; + return { bb::fr(accumulator), bb::fr(accumulator / divisor) }; } /** @@ -186,9 +186,9 @@ template class Rho { table.get_values_from_key = &get_rho_renormalization_values; uint64_t step_size = numeric::pow64(static_cast(BASE), TABLE_BITS); - table.column_1_step_size = barretenberg::fr(step_size); - table.column_2_step_size = barretenberg::fr(step_size); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(step_size); + table.column_2_step_size = bb::fr(step_size); + table.column_3_step_size = bb::fr(0); return table; } @@ -246,7 +246,7 @@ template class Rho { table.column_3_step_sizes.push_back(1); // generate table selector values for the 'right' slice - barretenberg::constexpr_for<0, num_right_tables, 1>([&] { + bb::constexpr_for<0, num_right_tables, 1>([&] { constexpr size_t num_bits_processed = (i * MAXIMUM_MULTITABLE_BITS); constexpr size_t bit_slice = (num_bits_processed + MAXIMUM_MULTITABLE_BITS > right_bits) ? right_bits % MAXIMUM_MULTITABLE_BITS @@ -269,7 +269,7 @@ template class Rho { }); // generate table selector values for the 'left' slice - barretenberg::constexpr_for<0, num_left_tables, 1>([&] { + bb::constexpr_for<0, num_left_tables, 1>([&] { constexpr size_t num_bits_processed = (i * MAXIMUM_MULTITABLE_BITS); constexpr size_t bit_slice = (num_bits_processed + MAXIMUM_MULTITABLE_BITS > left_bits) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp index f7ed27f908a..c9137f0b3dc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp @@ -91,9 +91,9 @@ class Theta { * Used by the Plookup code to precompute lookup tables and generate witness values * * @param key (first element = table input. Second element is unused as this lookup does not have 2 keys per value) - * @return std::array table output (normalized input and normalized input / 11^TABLE_BITS - 1) + * @return std::array table output (normalized input and normalized input / 11^TABLE_BITS - 1) */ - static std::array get_theta_renormalization_values(const std::array key) + static std::array get_theta_renormalization_values(const std::array key) { uint64_t accumulator = 0; uint64_t input = key[0]; @@ -105,7 +105,7 @@ class Theta { input /= BASE; base_shift *= BASE; } - return { barretenberg::fr(accumulator), barretenberg::fr(0) }; + return { bb::fr(accumulator), bb::fr(0) }; } /** @@ -187,9 +187,9 @@ class Theta { table.get_values_from_key = &get_theta_renormalization_values; constexpr uint64_t step_size = numeric::pow64(static_cast(BASE), TABLE_BITS); - table.column_1_step_size = barretenberg::fr(step_size); - table.column_2_step_size = barretenberg::fr(step_size); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(step_size); + table.column_2_step_size = bb::fr(step_size); + table.column_3_step_size = bb::fr(0); return table; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp index 5a70295deaa..3e12005d314 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp @@ -60,18 +60,16 @@ template void ecc_generator_table::init_generator_tables() uint256_t y2 = y & MASK; y = y >> 68; uint256_t y3 = y & MASK; - ecc_generator_table::generator_xlo_table[i] = std::make_pair(x0, x1); - ecc_generator_table::generator_xhi_table[i] = std::make_pair(x2, x3); - ecc_generator_table::generator_endo_xlo_table[i] = - std::make_pair(endox0, endox1); - ecc_generator_table::generator_endo_xhi_table[i] = - std::make_pair(endox2, endox3); - ecc_generator_table::generator_ylo_table[i] = std::make_pair(y0, y1); - ecc_generator_table::generator_yhi_table[i] = std::make_pair(y2, y3); - ecc_generator_table::generator_xyprime_table[i] = std::make_pair( - barretenberg::fr(uint256_t(point_table[i].x)), barretenberg::fr(uint256_t(point_table[i].y))); - ecc_generator_table::generator_endo_xyprime_table[i] = std::make_pair( - barretenberg::fr(uint256_t(point_table[i].x * beta)), barretenberg::fr(uint256_t(point_table[i].y))); + ecc_generator_table::generator_xlo_table[i] = std::make_pair(x0, x1); + ecc_generator_table::generator_xhi_table[i] = std::make_pair(x2, x3); + ecc_generator_table::generator_endo_xlo_table[i] = std::make_pair(endox0, endox1); + ecc_generator_table::generator_endo_xhi_table[i] = std::make_pair(endox2, endox3); + ecc_generator_table::generator_ylo_table[i] = std::make_pair(y0, y1); + ecc_generator_table::generator_yhi_table[i] = std::make_pair(y2, y3); + ecc_generator_table::generator_xyprime_table[i] = + std::make_pair(bb::fr(uint256_t(point_table[i].x)), bb::fr(uint256_t(point_table[i].y))); + ecc_generator_table::generator_endo_xyprime_table[i] = std::make_pair( + bb::fr(uint256_t(point_table[i].x * beta)), bb::fr(uint256_t(point_table[i].y))); } init = true; } @@ -91,8 +89,7 @@ template size_t ecc_generator_table::convert_shifted_naf_to_po /** * Get 2 low 68-bit limbs of x-coordinate **/ -template -std::array ecc_generator_table::get_xlo_values(const std::array key) +template std::array ecc_generator_table::get_xlo_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -103,8 +100,7 @@ std::array ecc_generator_table::get_xlo_values(const st /** * Get 2 high 68-bit limbs of x-coordinate **/ -template -std::array ecc_generator_table::get_xhi_values(const std::array key) +template std::array ecc_generator_table::get_xhi_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -116,7 +112,7 @@ std::array ecc_generator_table::get_xhi_values(const st * Get 2 low 68-bit limbs of x-coordinate (for endomorphism point \lambda.[P]) **/ template -std::array ecc_generator_table::get_xlo_endo_values(const std::array key) +std::array ecc_generator_table::get_xlo_endo_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -128,7 +124,7 @@ std::array ecc_generator_table::get_xlo_endo_values(con * Get 2 high 68-bit limbs of x-coordinate (for endomorphism point \lambda.[1]) **/ template -std::array ecc_generator_table::get_xhi_endo_values(const std::array key) +std::array ecc_generator_table::get_xhi_endo_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -139,8 +135,7 @@ std::array ecc_generator_table::get_xhi_endo_values(con /** * Get 2 low 68-bit limbs of y-coordinate **/ -template -std::array ecc_generator_table::get_ylo_values(const std::array key) +template std::array ecc_generator_table::get_ylo_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -151,8 +146,7 @@ std::array ecc_generator_table::get_ylo_values(const st /** * Get 2 high 68-bit limbs of y-coordinate **/ -template -std::array ecc_generator_table::get_yhi_values(const std::array key) +template std::array ecc_generator_table::get_yhi_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -164,7 +158,7 @@ std::array ecc_generator_table::get_yhi_values(const st * Get the prime basis limbs for the x and y coordinates **/ template -std::array ecc_generator_table::get_xyprime_values(const std::array key) +std::array ecc_generator_table::get_xyprime_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -176,7 +170,7 @@ std::array ecc_generator_table::get_xyprime_values(cons * Get the prime basis limbs for the x and y coordinates (endomorphism version for \lambda.[1]) **/ template -std::array ecc_generator_table::get_xyprime_endo_values(const std::array key) +std::array ecc_generator_table::get_xyprime_endo_values(const std::array key) { init_generator_tables(); const size_t index = static_cast(key[0]); @@ -491,7 +485,7 @@ MultiTable ecc_generator_table::get_xyprime_endo_table(const MultiTableId id } return table; } -template class ecc_generator_table; +template class ecc_generator_table; template class ecc_generator_table; } // namespace ecc_generator_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp index 30a3a3c1bc2..16fd12a8686 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp @@ -16,28 +16,28 @@ template class ecc_generator_table { * Store arrays of precomputed 8-bit lookup tables for generator point coordinates (and their endomorphism *equivalents) **/ - inline static std::array, 256> generator_endo_xlo_table; - inline static std::array, 256> generator_endo_xhi_table; - inline static std::array, 256> generator_xlo_table; - inline static std::array, 256> generator_xhi_table; - inline static std::array, 256> generator_ylo_table; - inline static std::array, 256> generator_yhi_table; - inline static std::array, 256> generator_xyprime_table; - inline static std::array, 256> generator_endo_xyprime_table; + inline static std::array, 256> generator_endo_xlo_table; + inline static std::array, 256> generator_endo_xhi_table; + inline static std::array, 256> generator_xlo_table; + inline static std::array, 256> generator_xhi_table; + inline static std::array, 256> generator_ylo_table; + inline static std::array, 256> generator_yhi_table; + inline static std::array, 256> generator_xyprime_table; + inline static std::array, 256> generator_endo_xyprime_table; inline static bool init = false; static void init_generator_tables(); static size_t convert_position_to_shifted_naf(const size_t position); static size_t convert_shifted_naf_to_position(const size_t shifted_naf); - static std::array get_xlo_endo_values(const std::array key); - static std::array get_xhi_endo_values(const std::array key); - static std::array get_xlo_values(const std::array key); - static std::array get_xhi_values(const std::array key); - static std::array get_ylo_values(const std::array key); - static std::array get_yhi_values(const std::array key); - static std::array get_xyprime_values(const std::array key); - static std::array get_xyprime_endo_values(const std::array key); + static std::array get_xlo_endo_values(const std::array key); + static std::array get_xhi_endo_values(const std::array key); + static std::array get_xlo_values(const std::array key); + static std::array get_xhi_values(const std::array key); + static std::array get_ylo_values(const std::array key); + static std::array get_yhi_values(const std::array key); + static std::array get_xyprime_values(const std::array key); + static std::array get_xyprime_endo_values(const std::array key); static BasicTable generate_xlo_table(BasicTableId id, const size_t table_index); static BasicTable generate_xhi_table(BasicTableId id, const size_t table_index); static BasicTable generate_xlo_endo_table(BasicTableId id, const size_t table_index); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp index d7db3d8c2b2..c8f1f83de00 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp @@ -3,7 +3,7 @@ namespace plookup { -using namespace barretenberg; +using namespace bb; namespace { // TODO(@zac-williamson) convert these into static const members of a struct @@ -30,25 +30,22 @@ void init_multi_tables() MULTI_TABLES[MultiTableId::AES_SBOX] = aes128_tables::get_aes_sbox_table(MultiTableId::AES_SBOX); MULTI_TABLES[MultiTableId::UINT32_XOR] = uint_tables::get_uint32_xor_table(MultiTableId::UINT32_XOR); MULTI_TABLES[MultiTableId::UINT32_AND] = uint_tables::get_uint32_and_table(MultiTableId::UINT32_AND); - MULTI_TABLES[MultiTableId::BN254_XLO] = ecc_generator_tables::ecc_generator_table::get_xlo_table( + MULTI_TABLES[MultiTableId::BN254_XLO] = ecc_generator_tables::ecc_generator_table::get_xlo_table( MultiTableId::BN254_XLO, BasicTableId::BN254_XLO_BASIC); - MULTI_TABLES[MultiTableId::BN254_XHI] = ecc_generator_tables::ecc_generator_table::get_xhi_table( + MULTI_TABLES[MultiTableId::BN254_XHI] = ecc_generator_tables::ecc_generator_table::get_xhi_table( MultiTableId::BN254_XHI, BasicTableId::BN254_XHI_BASIC); - MULTI_TABLES[MultiTableId::BN254_YLO] = ecc_generator_tables::ecc_generator_table::get_ylo_table( + MULTI_TABLES[MultiTableId::BN254_YLO] = ecc_generator_tables::ecc_generator_table::get_ylo_table( MultiTableId::BN254_YLO, BasicTableId::BN254_YLO_BASIC); - MULTI_TABLES[MultiTableId::BN254_YHI] = ecc_generator_tables::ecc_generator_table::get_yhi_table( + MULTI_TABLES[MultiTableId::BN254_YHI] = ecc_generator_tables::ecc_generator_table::get_yhi_table( MultiTableId::BN254_YHI, BasicTableId::BN254_YHI_BASIC); - MULTI_TABLES[MultiTableId::BN254_XYPRIME] = - ecc_generator_tables::ecc_generator_table::get_xyprime_table( - MultiTableId::BN254_XYPRIME, BasicTableId::BN254_XYPRIME_BASIC); - MULTI_TABLES[MultiTableId::BN254_XLO_ENDO] = - ecc_generator_tables::ecc_generator_table::get_xlo_endo_table( - MultiTableId::BN254_XLO_ENDO, BasicTableId::BN254_XLO_ENDO_BASIC); - MULTI_TABLES[MultiTableId::BN254_XHI_ENDO] = - ecc_generator_tables::ecc_generator_table::get_xhi_endo_table( - MultiTableId::BN254_XHI_ENDO, BasicTableId::BN254_XHI_ENDO_BASIC); + MULTI_TABLES[MultiTableId::BN254_XYPRIME] = ecc_generator_tables::ecc_generator_table::get_xyprime_table( + MultiTableId::BN254_XYPRIME, BasicTableId::BN254_XYPRIME_BASIC); + MULTI_TABLES[MultiTableId::BN254_XLO_ENDO] = ecc_generator_tables::ecc_generator_table::get_xlo_endo_table( + MultiTableId::BN254_XLO_ENDO, BasicTableId::BN254_XLO_ENDO_BASIC); + MULTI_TABLES[MultiTableId::BN254_XHI_ENDO] = ecc_generator_tables::ecc_generator_table::get_xhi_endo_table( + MultiTableId::BN254_XHI_ENDO, BasicTableId::BN254_XHI_ENDO_BASIC); MULTI_TABLES[MultiTableId::BN254_XYPRIME_ENDO] = - ecc_generator_tables::ecc_generator_table::get_xyprime_endo_table( + ecc_generator_tables::ecc_generator_table::get_xyprime_endo_table( MultiTableId::BN254_XYPRIME_ENDO, BasicTableId::BN254_XYPRIME_ENDO_BASIC); MULTI_TABLES[MultiTableId::SECP256K1_XLO] = ecc_generator_tables::ecc_generator_table::get_xlo_table( MultiTableId::SECP256K1_XLO, BasicTableId::SECP256K1_XLO_BASIC); @@ -94,7 +91,7 @@ void init_multi_tables() MULTI_TABLES[MultiTableId::FIXED_BASE_RIGHT_HI] = fixed_base::table::get_fixed_base_table<3, 126>(MultiTableId::FIXED_BASE_RIGHT_HI); - barretenberg::constexpr_for<0, 25, 1>([&]() { + bb::constexpr_for<0, 25, 1>([&]() { MULTI_TABLES[static_cast(MultiTableId::KECCAK_NORMALIZE_AND_ROTATE) + i] = keccak_tables::Rho<8, i>::get_rho_output_table(MultiTableId::KECCAK_NORMALIZE_AND_ROTATE); }); @@ -111,16 +108,16 @@ const MultiTable& create_table(const MultiTableId id) return MULTI_TABLES[id]; } -ReadData get_lookup_accumulators(const MultiTableId id, - const fr& key_a, - const fr& key_b, - const bool is_2_to_1_lookup) +ReadData get_lookup_accumulators(const MultiTableId id, + const fr& key_a, + const fr& key_b, + const bool is_2_to_1_lookup) { // return multi-table, populating global array of all multi-tables if need be const auto& multi_table = create_table(id); const size_t num_lookups = multi_table.lookup_ids.size(); - ReadData lookup; + ReadData lookup; const auto key_a_slices = numeric::slice_input_using_variable_bases(key_a, multi_table.slice_sizes); const auto key_b_slices = numeric::slice_input_using_variable_bases(key_b, multi_table.slice_sizes); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp index e8588db642e..b4fcaeac1a1 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp @@ -20,10 +20,10 @@ namespace plookup { const MultiTable& create_table(MultiTableId id); -ReadData get_lookup_accumulators(MultiTableId id, - const barretenberg::fr& key_a, - const barretenberg::fr& key_b = 0, - bool is_2_to_1_lookup = false); +ReadData get_lookup_accumulators(MultiTableId id, + const bb::fr& key_a, + const bb::fr& key_b = 0, + bool is_2_to_1_lookup = false); inline BasicTable create_basic_table(const BasicTableId id, const size_t index) { @@ -98,32 +98,29 @@ inline BasicTable create_basic_table(const BasicTableId id, const size_t index) return uint_tables::generate_and_rotate_table<6, 0>(UINT_AND_ROTATE0, index); } case BN254_XLO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xlo_table(BN254_XLO_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_xlo_table(BN254_XLO_BASIC, index); } case BN254_XHI_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xhi_table(BN254_XHI_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_xhi_table(BN254_XHI_BASIC, index); } case BN254_YLO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_ylo_table(BN254_YLO_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_ylo_table(BN254_YLO_BASIC, index); } case BN254_YHI_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_yhi_table(BN254_YHI_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_yhi_table(BN254_YHI_BASIC, index); } case BN254_XYPRIME_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xyprime_table(BN254_XYPRIME_BASIC, - index); + return ecc_generator_tables::ecc_generator_table::generate_xyprime_table(BN254_XYPRIME_BASIC, index); } case BN254_XLO_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xlo_endo_table( - BN254_XLO_ENDO_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_xlo_endo_table(BN254_XLO_ENDO_BASIC, index); } case BN254_XHI_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xhi_endo_table( - BN254_XHI_ENDO_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_xhi_endo_table(BN254_XHI_ENDO_BASIC, index); } case BN254_XYPRIME_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xyprime_endo_table( - BN254_XYPRIME_ENDO_BASIC, index); + return ecc_generator_tables::ecc_generator_table::generate_xyprime_endo_table(BN254_XYPRIME_ENDO_BASIC, + index); } case SECP256K1_XLO_BASIC: { return ecc_generator_tables::ecc_generator_table::generate_xlo_table(SECP256K1_XLO_BASIC, index); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp index b738571db15..31316ae56d7 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp @@ -156,82 +156,71 @@ inline MultiTable get_majority_output_table(const MultiTableId id = SHA256_MAJ_O return table; } -inline std::array get_majority_rotation_multipliers() +inline std::array get_majority_rotation_multipliers() { constexpr uint64_t base_temp = 16; - auto base = barretenberg::fr(base_temp); + auto base = bb::fr(base_temp); // scaling factors applied to a's sparse limbs, excluding the rotated limb - const std::array rot2_coefficients{ 0, base.pow(11 - 2), base.pow(22 - 2) }; - const std::array rot13_coefficients{ base.pow(32 - 13), 0, base.pow(22 - 13) }; - const std::array rot22_coefficients{ base.pow(32 - 22), base.pow(32 - 22 + 11), 0 }; + const std::array rot2_coefficients{ 0, base.pow(11 - 2), base.pow(22 - 2) }; + const std::array rot13_coefficients{ base.pow(32 - 13), 0, base.pow(22 - 13) }; + const std::array rot22_coefficients{ base.pow(32 - 22), base.pow(32 - 22 + 11), 0 }; // these are the coefficients that we want - const std::array target_rotation_coefficients{ + const std::array target_rotation_coefficients{ rot2_coefficients[0] + rot13_coefficients[0] + rot22_coefficients[0], rot2_coefficients[1] + rot13_coefficients[1] + rot22_coefficients[1], rot2_coefficients[2] + rot13_coefficients[2] + rot22_coefficients[2], }; - barretenberg::fr column_2_row_1_multiplier = target_rotation_coefficients[0]; - barretenberg::fr column_2_row_2_multiplier = - target_rotation_coefficients[0] * (-barretenberg::fr(base).pow(11)) + target_rotation_coefficients[1]; + bb::fr column_2_row_1_multiplier = target_rotation_coefficients[0]; + bb::fr column_2_row_2_multiplier = + target_rotation_coefficients[0] * (-bb::fr(base).pow(11)) + target_rotation_coefficients[1]; - std::array rotation_multipliers = { column_2_row_1_multiplier, - column_2_row_2_multiplier, - barretenberg::fr(0) }; + std::array rotation_multipliers = { column_2_row_1_multiplier, column_2_row_2_multiplier, bb::fr(0) }; return rotation_multipliers; } // template -inline std::array get_choose_rotation_multipliers() +inline std::array get_choose_rotation_multipliers() { - const std::array column_2_row_3_coefficients{ - barretenberg::fr(1), - barretenberg::fr(28).pow(11), - barretenberg::fr(28).pow(22), + const std::array column_2_row_3_coefficients{ + bb::fr(1), + bb::fr(28).pow(11), + bb::fr(28).pow(22), }; // scaling factors applied to a's sparse limbs, excluding the rotated limb - const std::array rot6_coefficients{ barretenberg::fr(0), - barretenberg::fr(28).pow(11 - 6), - barretenberg::fr(28).pow(22 - 6) }; - const std::array rot11_coefficients{ barretenberg::fr(28).pow(32 - 11), - barretenberg::fr(0), - barretenberg::fr(28).pow(22 - 11) }; - const std::array rot25_coefficients{ barretenberg::fr(28).pow(32 - 25), - barretenberg::fr(28).pow(32 - 25 + 11), - barretenberg::fr(0) }; + const std::array rot6_coefficients{ bb::fr(0), bb::fr(28).pow(11 - 6), bb::fr(28).pow(22 - 6) }; + const std::array rot11_coefficients{ bb::fr(28).pow(32 - 11), bb::fr(0), bb::fr(28).pow(22 - 11) }; + const std::array rot25_coefficients{ bb::fr(28).pow(32 - 25), bb::fr(28).pow(32 - 25 + 11), bb::fr(0) }; // these are the coefficients that we want - const std::array target_rotation_coefficients{ + const std::array target_rotation_coefficients{ rot6_coefficients[0] + rot11_coefficients[0] + rot25_coefficients[0], rot6_coefficients[1] + rot11_coefficients[1] + rot25_coefficients[1], rot6_coefficients[2] + rot11_coefficients[2] + rot25_coefficients[2], }; - barretenberg::fr column_2_row_1_multiplier = - barretenberg::fr(1) * target_rotation_coefficients[0]; // why multiply by one? + bb::fr column_2_row_1_multiplier = bb::fr(1) * target_rotation_coefficients[0]; // why multiply by one? // this gives us the correct scaling factor for a0's 1st limb - std::array current_coefficients{ + std::array current_coefficients{ column_2_row_3_coefficients[0] * column_2_row_1_multiplier, column_2_row_3_coefficients[1] * column_2_row_1_multiplier, column_2_row_3_coefficients[2] * column_2_row_1_multiplier, }; - barretenberg::fr column_2_row_3_multiplier = -(current_coefficients[2]) + target_rotation_coefficients[2]; + bb::fr column_2_row_3_multiplier = -(current_coefficients[2]) + target_rotation_coefficients[2]; - std::array rotation_multipliers = { column_2_row_1_multiplier, - barretenberg::fr(0), - column_2_row_3_multiplier }; + std::array rotation_multipliers = { column_2_row_1_multiplier, bb::fr(0), column_2_row_3_multiplier }; return rotation_multipliers; } inline MultiTable get_witness_extension_input_table(const MultiTableId id = SHA256_WITNESS_INPUT) { - std::vector column_1_coefficients{ 1, 1 << 3, 1 << 10, 1 << 18 }; - std::vector column_2_coefficients{ 0, 0, 0, 0 }; - std::vector column_3_coefficients{ 0, 0, 0, 0 }; + std::vector column_1_coefficients{ 1, 1 << 3, 1 << 10, 1 << 18 }; + std::vector column_2_coefficients{ 0, 0, 0, 0 }; + std::vector column_3_coefficients{ 0, 0, 0, 0 }; MultiTable table(column_1_coefficients, column_2_coefficients, column_3_coefficients); table.id = id; table.slice_sizes = { (1 << 3), (1 << 7), (1 << 8), (1 << 18) }; @@ -304,44 +293,32 @@ inline MultiTable get_choose_input_table(const MultiTableId id = SHA256_CH_INPUT **/ // scaling factors applied to a's sparse limbs, excluding the rotated limb - const std::array rot6_coefficients{ barretenberg::fr(0), - barretenberg::fr(28).pow(11 - 6), - barretenberg::fr(28).pow(22 - 6) }; - const std::array rot11_coefficients{ barretenberg::fr(28).pow(32 - 11), - barretenberg::fr(0), - barretenberg::fr(28).pow(22 - 11) }; - const std::array rot25_coefficients{ barretenberg::fr(28).pow(32 - 25), - barretenberg::fr(28).pow(32 - 25 + 11), - barretenberg::fr(0) }; + const std::array rot6_coefficients{ bb::fr(0), bb::fr(28).pow(11 - 6), bb::fr(28).pow(22 - 6) }; + const std::array rot11_coefficients{ bb::fr(28).pow(32 - 11), bb::fr(0), bb::fr(28).pow(22 - 11) }; + const std::array rot25_coefficients{ bb::fr(28).pow(32 - 25), bb::fr(28).pow(32 - 25 + 11), bb::fr(0) }; // these are the coefficients that we want - const std::array target_rotation_coefficients{ + const std::array target_rotation_coefficients{ rot6_coefficients[0] + rot11_coefficients[0] + rot25_coefficients[0], rot6_coefficients[1] + rot11_coefficients[1] + rot25_coefficients[1], rot6_coefficients[2] + rot11_coefficients[2] + rot25_coefficients[2], }; - barretenberg::fr column_2_row_1_multiplier = target_rotation_coefficients[0]; + bb::fr column_2_row_1_multiplier = target_rotation_coefficients[0]; // this gives us the correct scaling factor for a0's 1st limb - std::array current_coefficients{ + std::array current_coefficients{ column_2_row_1_multiplier, - barretenberg::fr(28).pow(11) * column_2_row_1_multiplier, - barretenberg::fr(28).pow(22) * column_2_row_1_multiplier, + bb::fr(28).pow(11) * column_2_row_1_multiplier, + bb::fr(28).pow(22) * column_2_row_1_multiplier, }; - // barretenberg::fr column_2_row_3_multiplier = -(current_coefficients[2]) + target_rotation_coefficients[2]; - barretenberg::fr column_3_row_2_multiplier = -(current_coefficients[1]) + target_rotation_coefficients[1]; - - std::vector column_1_coefficients{ barretenberg::fr(1), - barretenberg::fr(1 << 11), - barretenberg::fr(1 << 22) }; - std::vector column_2_coefficients{ barretenberg::fr(1), - barretenberg::fr(28).pow(11), - barretenberg::fr(28).pow(22) }; - std::vector column_3_coefficients{ barretenberg::fr(1), - column_3_row_2_multiplier + barretenberg::fr(1), - barretenberg::fr(1) }; + // bb::fr column_2_row_3_multiplier = -(current_coefficients[2]) + target_rotation_coefficients[2]; + bb::fr column_3_row_2_multiplier = -(current_coefficients[1]) + target_rotation_coefficients[1]; + + std::vector column_1_coefficients{ bb::fr(1), bb::fr(1 << 11), bb::fr(1 << 22) }; + std::vector column_2_coefficients{ bb::fr(1), bb::fr(28).pow(11), bb::fr(28).pow(22) }; + std::vector column_3_coefficients{ bb::fr(1), column_3_row_2_multiplier + bb::fr(1), bb::fr(1) }; MultiTable table(column_1_coefficients, column_2_coefficients, column_3_coefficients); table.id = id; table.slice_sizes = { (1 << 11), (1 << 11), (1 << 10) }; @@ -381,35 +358,25 @@ inline MultiTable get_majority_input_table(const MultiTableId id = SHA256_MAJ_IN constexpr uint64_t base = 16; // scaling factors applied to a's sparse limbs, excluding the rotated limb - const std::array rot2_coefficients{ barretenberg::fr(0), - barretenberg::fr(base).pow(11 - 2), - barretenberg::fr(base).pow(22 - 2) }; - const std::array rot13_coefficients{ barretenberg::fr(base).pow(32 - 13), - barretenberg::fr(0), - barretenberg::fr(base).pow(22 - 13) }; - const std::array rot22_coefficients{ barretenberg::fr(base).pow(32 - 22), - barretenberg::fr(base).pow(32 - 22 + 11), - barretenberg::fr(0) }; + const std::array rot2_coefficients{ bb::fr(0), bb::fr(base).pow(11 - 2), bb::fr(base).pow(22 - 2) }; + const std::array rot13_coefficients{ bb::fr(base).pow(32 - 13), bb::fr(0), bb::fr(base).pow(22 - 13) }; + const std::array rot22_coefficients{ bb::fr(base).pow(32 - 22), + bb::fr(base).pow(32 - 22 + 11), + bb::fr(0) }; // these are the coefficients that we want - const std::array target_rotation_coefficients{ + const std::array target_rotation_coefficients{ rot2_coefficients[0] + rot13_coefficients[0] + rot22_coefficients[0], rot2_coefficients[1] + rot13_coefficients[1] + rot22_coefficients[1], rot2_coefficients[2] + rot13_coefficients[2] + rot22_coefficients[2], }; - barretenberg::fr column_2_row_3_multiplier = - target_rotation_coefficients[1] * (-barretenberg::fr(base).pow(11)) + target_rotation_coefficients[2]; - - std::vector column_1_coefficients{ barretenberg::fr(1), - barretenberg::fr(1 << 11), - barretenberg::fr(1 << 22) }; - std::vector column_2_coefficients{ barretenberg::fr(1), - barretenberg::fr(base).pow(11), - barretenberg::fr(base).pow(22) }; - std::vector column_3_coefficients{ barretenberg::fr(1), - barretenberg::fr(1), - barretenberg::fr(1) + column_2_row_3_multiplier }; + bb::fr column_2_row_3_multiplier = + target_rotation_coefficients[1] * (-bb::fr(base).pow(11)) + target_rotation_coefficients[2]; + + std::vector column_1_coefficients{ bb::fr(1), bb::fr(1 << 11), bb::fr(1 << 22) }; + std::vector column_2_coefficients{ bb::fr(1), bb::fr(base).pow(11), bb::fr(base).pow(22) }; + std::vector column_3_coefficients{ bb::fr(1), bb::fr(1), bb::fr(1) + column_2_row_3_multiplier }; MultiTable table(column_1_coefficients, column_2_coefficients, column_3_coefficients); table.id = id; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp index 006f9a3c7b0..5664c8cb4fa 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp @@ -11,16 +11,16 @@ namespace plookup { namespace sparse_tables { template -inline std::array get_sparse_table_with_rotation_values(const std::array key) +inline std::array get_sparse_table_with_rotation_values(const std::array key) { const auto t0 = numeric::map_into_sparse_form(key[0]); - barretenberg::fr t1; + bb::fr t1; if constexpr (num_rotated_bits > 0) { t1 = numeric::map_into_sparse_form(numeric::rotate32((uint32_t)key[0], num_rotated_bits)); } else { t1 = t0; } - return { barretenberg::fr(t0), barretenberg::fr(t1) }; + return { bb::fr(t0), bb::fr(t1) }; } template @@ -35,15 +35,15 @@ inline BasicTable generate_sparse_table_with_rotation(BasicTableId id, const siz for (uint64_t i = 0; i < table.size; ++i) { const uint64_t source = i; const auto target = numeric::map_into_sparse_form(source); - table.column_1.emplace_back(barretenberg::fr(source)); - table.column_2.emplace_back(barretenberg::fr(target)); + table.column_1.emplace_back(bb::fr(source)); + table.column_2.emplace_back(bb::fr(target)); if constexpr (num_rotated_bits > 0) { const auto rotated = numeric::map_into_sparse_form(numeric::rotate32((uint32_t)source, num_rotated_bits)); - table.column_3.emplace_back(barretenberg::fr(rotated)); + table.column_3.emplace_back(bb::fr(rotated)); } else { - table.column_3.emplace_back(barretenberg::fr(target)); + table.column_3.emplace_back(bb::fr(target)); } } @@ -53,15 +53,15 @@ inline BasicTable generate_sparse_table_with_rotation(BasicTableId id, const siz for (size_t i = 0; i < bits_per_slice; ++i) { sparse_step_size *= base; } - table.column_1_step_size = barretenberg::fr((1 << 11)); - table.column_2_step_size = barretenberg::fr(sparse_step_size); - table.column_3_step_size = barretenberg::fr(sparse_step_size); + table.column_1_step_size = bb::fr((1 << 11)); + table.column_2_step_size = bb::fr(sparse_step_size); + table.column_3_step_size = bb::fr(sparse_step_size); return table; } template -inline std::array get_sparse_normalization_values(const std::array key) +inline std::array get_sparse_normalization_values(const std::array key) { uint64_t accumulator = 0; uint64_t input = key[0]; @@ -74,7 +74,7 @@ inline std::array get_sparse_normalization_values(const std input /= base; ++count; } - return { barretenberg::fr(accumulator), barretenberg::fr(0) }; + return { bb::fr(accumulator), bb::fr(0) }; } template @@ -104,15 +104,15 @@ inline BasicTable generate_sparse_normalization_table(BasicTableId id, const siz table.column_1.emplace_back(accumulator.get_sparse_value()); table.column_2.emplace_back(key); - table.column_3.emplace_back(barretenberg::fr(0)); + table.column_3.emplace_back(bb::fr(0)); accumulator += to_add; } table.get_values_from_key = &get_sparse_normalization_values; - table.column_1_step_size = barretenberg::fr(table.size); - table.column_2_step_size = barretenberg::fr(((uint64_t)1 << num_bits)); - table.column_3_step_size = barretenberg::fr(0); + table.column_1_step_size = bb::fr(table.size); + table.column_2_step_size = bb::fr(((uint64_t)1 << num_bits)); + table.column_3_step_size = bb::fr(0); return table; } } // namespace sparse_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp index 020baa373d5..181844ea163 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp @@ -123,16 +123,16 @@ enum MultiTableId { struct MultiTable { // Coefficients are accumulated products of corresponding step sizes until that point - std::vector column_1_coefficients; - std::vector column_2_coefficients; - std::vector column_3_coefficients; + std::vector column_1_coefficients; + std::vector column_2_coefficients; + std::vector column_3_coefficients; MultiTableId id; std::vector lookup_ids; std::vector slice_sizes; - std::vector column_1_step_sizes; - std::vector column_2_step_sizes; - std::vector column_3_step_sizes; - typedef std::array table_out; + std::vector column_1_step_sizes; + std::vector column_2_step_sizes; + std::vector column_3_step_sizes; + typedef std::array table_out; typedef std::array table_in; std::vector get_table_values; @@ -140,15 +140,15 @@ struct MultiTable { void init_step_sizes() { const size_t num_lookups = column_1_coefficients.size(); - column_1_step_sizes.emplace_back(barretenberg::fr(1)); - column_2_step_sizes.emplace_back(barretenberg::fr(1)); - column_3_step_sizes.emplace_back(barretenberg::fr(1)); + column_1_step_sizes.emplace_back(bb::fr(1)); + column_2_step_sizes.emplace_back(bb::fr(1)); + column_3_step_sizes.emplace_back(bb::fr(1)); - std::vector coefficient_inverses(column_1_coefficients.begin(), column_1_coefficients.end()); + std::vector coefficient_inverses(column_1_coefficients.begin(), column_1_coefficients.end()); std::copy(column_2_coefficients.begin(), column_2_coefficients.end(), std::back_inserter(coefficient_inverses)); std::copy(column_3_coefficients.begin(), column_3_coefficients.end(), std::back_inserter(coefficient_inverses)); - barretenberg::fr::batch_invert(&coefficient_inverses[0], num_lookups * 3); + bb::fr::batch_invert(&coefficient_inverses[0], num_lookups * 3); for (size_t i = 1; i < num_lookups; ++i) { column_1_step_sizes.emplace_back(column_1_coefficients[i] * coefficient_inverses[i - 1]); @@ -158,9 +158,9 @@ struct MultiTable { } public: - MultiTable(const barretenberg::fr& col_1_repeated_coeff, - const barretenberg::fr& col_2_repeated_coeff, - const barretenberg::fr& col_3_repeated_coeff, + MultiTable(const bb::fr& col_1_repeated_coeff, + const bb::fr& col_2_repeated_coeff, + const bb::fr& col_3_repeated_coeff, const size_t num_lookups) { column_1_coefficients.emplace_back(1); @@ -174,9 +174,9 @@ struct MultiTable { } init_step_sizes(); } - MultiTable(const std::vector& col_1_coeffs, - const std::vector& col_2_coeffs, - const std::vector& col_3_coeffs) + MultiTable(const std::vector& col_1_coeffs, + const std::vector& col_2_coeffs, + const std::vector& col_3_coeffs) : column_1_coefficients(col_1_coeffs) , column_2_coefficients(col_2_coeffs) , column_3_coefficients(col_3_coeffs) @@ -195,10 +195,10 @@ struct MultiTable { // struct PlookupLargeKeyTable { // struct KeyEntry { // uint256_t key; -// std::array value{ barretenberg::fr(0), barretenberg::fr(0) }; +// std::array value{ bb::fr(0), bb::fr(0) }; // bool operator<(const KeyEntry& other) const { return key < other.key; } -// std::array to_sorted_list_components(const bool use_two_keys) const +// std::array to_sorted_list_components(const bool use_two_keys) const // { // return { // key[0], @@ -213,27 +213,27 @@ struct MultiTable { // size_t size; // bool use_twin_keys; -// barretenberg::fr column_1_step_size = barretenberg::fr(0); -// barretenberg::fr column_2_step_size = barretenberg::fr(0); -// barretenberg::fr column_3_step_size = barretenberg::fr(0); -// std::vector column_1; -// std::vector column_3; -// std::vector column_2; +// bb::fr column_1_step_size = bb::fr(0); +// bb::fr column_2_step_size = bb::fr(0); +// bb::fr column_3_step_size = bb::fr(0); +// std::vector column_1; +// std::vector column_3; +// std::vector column_2; // std::vector lookup_gates; -// std::array (*get_values_from_key)(const std::array); +// std::array (*get_values_from_key)(const std::array); // }; // struct PlookupFatKeyTable { // struct KeyEntry { -// barretenberg::fr key; -// std::array values{ 0, 0 }; +// bb::fr key; +// std::array values{ 0, 0 }; // bool operator<(const KeyEntry& other) const // { // return (key.from_montgomery_form() < other.key.from_montgomery_form()); // } -// std::array to_sorted_list_components() const { return { key, values[0], values[0] }; } +// std::array to_sorted_list_components() const { return { key, values[0], values[0] }; } // } // BasicTableId id; @@ -241,15 +241,15 @@ struct MultiTable { // size_t size; // bool use_twin_keys; -// barretenberg::fr column_1_step_size = barretenberg::fr(0); -// barretenberg::fr column_2_step_size = barretenberg::fr(0); -// barretenberg::fr column_3_step_size = barretenberg::fr(0); -// std::vector column_1; -// std::vector column_3; -// std::vector column_2; +// bb::fr column_1_step_size = bb::fr(0); +// bb::fr column_2_step_size = bb::fr(0); +// bb::fr column_3_step_size = bb::fr(0); +// std::vector column_1; +// std::vector column_3; +// std::vector column_2; // std::vector lookup_gates; -// std::array (*get_values_from_key)(const std::array); +// std::array (*get_values_from_key)(const std::array); // } @@ -263,17 +263,17 @@ struct MultiTable { struct BasicTable { struct KeyEntry { std::array key{ 0, 0 }; - std::array value{ barretenberg::fr(0), barretenberg::fr(0) }; + std::array value{ bb::fr(0), bb::fr(0) }; bool operator<(const KeyEntry& other) const { return key[0] < other.key[0] || ((key[0] == other.key[0]) && key[1] < other.key[1]); } - std::array to_sorted_list_components(const bool use_two_keys) const + std::array to_sorted_list_components(const bool use_two_keys) const { return { - barretenberg::fr(key[0]), - use_two_keys ? barretenberg::fr(key[1]) : value[0], + bb::fr(key[0]), + use_two_keys ? bb::fr(key[1]) : value[0], use_two_keys ? value[0] : value[1], }; } @@ -287,15 +287,15 @@ struct BasicTable { // This means that we are using two inputs to look up stuff, not translate a single entry into another one. bool use_twin_keys; - barretenberg::fr column_1_step_size = barretenberg::fr(0); - barretenberg::fr column_2_step_size = barretenberg::fr(0); - barretenberg::fr column_3_step_size = barretenberg::fr(0); - std::vector column_1; - std::vector column_3; - std::vector column_2; + bb::fr column_1_step_size = bb::fr(0); + bb::fr column_2_step_size = bb::fr(0); + bb::fr column_3_step_size = bb::fr(0); + std::vector column_1; + std::vector column_3; + std::vector column_2; std::vector lookup_gates; - std::array (*get_values_from_key)(const std::array); + std::array (*get_values_from_key)(const std::array); }; enum ColumnIdx { C1, C2, C3 }; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp index 05ccb4275e6..dcf02fe79f7 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp @@ -8,7 +8,7 @@ namespace plookup { namespace uint_tables { template -inline std::array get_xor_rotate_values_from_key(const std::array key) +inline std::array get_xor_rotate_values_from_key(const std::array key) { return { numeric::rotate64(key[0] ^ key[1], num_rotated_output_bits), 0ULL }; } @@ -41,7 +41,7 @@ inline BasicTable generate_xor_rotate_table(BasicTableId id, const size_t table_ } template -inline std::array get_and_rotate_values_from_key(const std::array key) +inline std::array get_and_rotate_values_from_key(const std::array key) { return { numeric::rotate64(key[0] & key[1], num_rotated_output_bits), 0ULL }; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.cpp b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.cpp index 8712f4c4f92..bc45811207e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.cpp @@ -22,7 +22,7 @@ template void PolynomialStore::put(std::string const& key, Pol * @param key string ID of the polynomial * @return Polynomial&; a reference to the polynomial associated with the given key */ -template barretenberg::Polynomial PolynomialStore::get(std::string const& key) +template bb::Polynomial PolynomialStore::get(std::string const& key) { // info("poly store get: ", key); // Take a shallow copy of the polynomial. Compiler will move the shallow copy to call site. @@ -71,6 +71,6 @@ template void PolynomialStore::print() info(); } -template class PolynomialStore; +template class PolynomialStore; } // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.hpp b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.hpp index 9cadd40b15c..8ed842f56fd 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.hpp @@ -11,7 +11,7 @@ namespace proof_system { template class PolynomialStore { private: - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; std::unordered_map polynomial_map; public: diff --git a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp index 8993c6393b3..125be65ec3e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store.test.cpp @@ -6,9 +6,9 @@ namespace proof_system { -using namespace barretenberg; -using Fr = barretenberg::fr; -using Polynomial = barretenberg::Polynomial; +using namespace bb; +using Fr = bb::fr; +using Polynomial = bb::Polynomial; // Test basic put and get functionality TEST(PolynomialStore, PutThenGet) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_cache.hpp b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_cache.hpp index b0d138471c3..82869745cdb 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_cache.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_cache.hpp @@ -17,10 +17,10 @@ namespace proof_system { */ class PolynomialStoreCache { private: - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; std::map cache_; std::multimap::iterator> size_map_; - PolynomialStoreWasm external_store; + PolynomialStoreWasm external_store; size_t max_cache_size_; public: diff --git a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.cpp b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.cpp index be983a879c5..663ab838965 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.cpp @@ -7,11 +7,11 @@ namespace proof_system { template void PolynomialStoreWasm::put(std::string const& key, Polynomial&& value) { // info("put ", key, ": ", value.hash()); - set_data(key.c_str(), (uint8_t*)value.data().get(), value.size() * sizeof(barretenberg::fr)); + set_data(key.c_str(), (uint8_t*)value.data().get(), value.size() * sizeof(bb::fr)); size_map[key] = value.size(); }; -template barretenberg::Polynomial PolynomialStoreWasm::get(std::string const& key) +template bb::Polynomial PolynomialStoreWasm::get(std::string const& key) { auto p = Polynomial(size_map[key]); get_data(key.c_str(), (uint8_t*)p.data().get()); @@ -19,6 +19,6 @@ template barretenberg::Polynomial PolynomialStoreWasm::get return p; }; -template class PolynomialStoreWasm; +template class PolynomialStoreWasm; } // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.hpp b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.hpp index 0cbc91b58e0..fc428a0e032 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/polynomial_store/polynomial_store_wasm.hpp @@ -7,7 +7,7 @@ namespace proof_system { template class PolynomialStoreWasm { private: - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; std::unordered_map size_map; public: diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index 8ff572f47b9..25d25c7808a 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -7,12 +7,12 @@ #include using namespace proof_system::honk; -namespace barretenberg::test_protogalaxy_prover { +namespace bb::test_protogalaxy_prover { using Flavor = proof_system::honk::flavor::Ultra; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; using RelationParameters = proof_system::RelationParameters; -using PowPolynomial = barretenberg::PowPolynomial; +using PowPolynomial = bb::PowPolynomial; // TODO(https://github.com/AztecProtocol/barretenberg/issues/780): Improve combiner tests to check more than the // arithmetic relation so we more than unit test folding relation parameters and alpha as well. @@ -55,20 +55,19 @@ TEST(Protogalaxy, CombinerOn2Instances) instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only auto pow_polynomial = PowPolynomial(std::vector{ 2 }); auto result = prover.compute_combiner(instances, pow_polynomial); - auto expected_result = - barretenberg::Univariate(std::array{ 87706, - 13644570, - 76451738, - 226257946, - static_cast(500811930), - static_cast(937862426), - static_cast(1575158170), - static_cast(2450447898), - static_cast(3601480346), - static_cast(5066004250), - static_cast(6881768346), - static_cast(9086521370), - static_cast(11718012058) }); + auto expected_result = bb::Univariate(std::array{ 87706, + 13644570, + 76451738, + 226257946, + static_cast(500811930), + static_cast(937862426), + static_cast(1575158170), + static_cast(2450447898), + static_cast(3601480346), + static_cast(5066004250), + static_cast(6881768346), + static_cast(9086521370), + static_cast(11718012058) }); EXPECT_EQ(result, expected_result); } else { std::vector> instance_data(NUM_INSTANCES); @@ -133,8 +132,8 @@ TEST(Protogalaxy, CombinerOn2Instances) auto pow_polynomial = PowPolynomial(std::vector{ 2 }); auto result = prover.compute_combiner(instances, pow_polynomial); - auto expected_result = barretenberg::Univariate( - std::array{ 0, 0, 12, 36, 72, 120, 180, 252, 336, 432, 540, 660, 792 }); + auto expected_result = + bb::Univariate(std::array{ 0, 0, 12, 36, 72, 120, 180, 252, 336, 432, 540, 660, 792 }); EXPECT_EQ(result, expected_result); } @@ -186,10 +185,10 @@ TEST(Protogalaxy, CombinerOn4Instances) auto result = prover.compute_combiner(instances, pow_polynomial); std::array zeroes; std::fill(zeroes.begin(), zeroes.end(), 0); - auto expected_result = barretenberg::Univariate(zeroes); + auto expected_result = bb::Univariate(zeroes); EXPECT_EQ(result, expected_result); }; run_test(); }; -} // namespace barretenberg::test_protogalaxy_prover \ No newline at end of file +} // namespace bb::test_protogalaxy_prover \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 8b533659270..dd7c313322a 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -4,7 +4,7 @@ #include "barretenberg/sumcheck/instance/verifier_instance.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::honk::sumcheck; namespace proof_system::honk { @@ -17,7 +17,7 @@ DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& tr {} template DeciderVerifier_::DeciderVerifier_() - : pcs_verification_key(std::make_unique(0, barretenberg::srs::get_crs_factory())) + : pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) , transcript(std::make_shared()) {} diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp index f9eed3b6bb2..3d689561d41 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp @@ -19,7 +19,7 @@ template class ProtoGalaxyProver_ { using Transcript = typename Flavor::Transcript; using FF = typename Flavor::FF; using Instance = typename ProverInstances::Instance; - using Utils = barretenberg::RelationUtils; + using Utils = bb::RelationUtils; using RowEvaluations = typename Flavor::AllValues; using ProverPolynomials = typename Flavor::ProverPolynomials; using Relations = typename Flavor::Relations; diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp index 2c89ecc16e0..eb6536d8fdf 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp @@ -43,8 +43,8 @@ template class ECCVMTranscriptRelationImpl { // TODO(@zac-williamson #2609 find more generic way of doing this) static constexpr FF get_curve_b() { - if constexpr (FF::modulus == barretenberg::fq::modulus) { - return barretenberg::g1::curve_b; + if constexpr (FF::modulus == bb::fq::modulus) { + return bb::g1::curve_b; } else if constexpr (FF::modulus == grumpkin::fq::modulus) { return grumpkin::g1::curve_b; } else { diff --git a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp index da69eb2d282..544457edb71 100644 --- a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp @@ -17,8 +17,8 @@ template class EllipticRelationImpl { // TODO(@zac-williamson #2609 find more generic way of doing this) static constexpr FF get_curve_b() { - if constexpr (FF::modulus == barretenberg::fq::modulus) { - return barretenberg::g1::curve_b; + if constexpr (FF::modulus == bb::fq::modulus) { + return bb::g1::curve_b; } else if constexpr (FF::modulus == grumpkin::fq::modulus) { return grumpkin::g1::curve_b; } else { diff --git a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp index 12f61dbb200..44f7c590d01 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp @@ -389,7 +389,7 @@ template class GenericLookupRelationImpl { auto result = Accumulator(0); // Iterate over tuple and sum as a polynomial over beta - barretenberg::constexpr_for( + bb::constexpr_for( [&]() { result = (result * params.beta) + View(std::get(all_polynomials)); }); const auto& gamma = params.gamma; return result + gamma; @@ -399,12 +399,10 @@ template class GenericLookupRelationImpl { auto result = Accumulator(0); // Iterate over tuple and sum as a polynomial over beta - barretenberg::constexpr_for( - [&]() { - result = - (result * params.beta) + View(std::get(all_polynomials)) - - View(std::get(all_polynomials)) * View(std::get(all_polynomials)); - }); + bb::constexpr_for([&]() { + result = (result * params.beta) + View(std::get(all_polynomials)) - + View(std::get(all_polynomials)) * View(std::get(all_polynomials)); + }); const auto& gamma = params.gamma; return result + gamma; } else { @@ -439,7 +437,7 @@ template class GenericLookupRelationImpl { auto result = Accumulator(0); // Iterate over tuple and sum as a polynomial over beta - barretenberg::constexpr_for( + bb::constexpr_for( [&]() { result = (result * params.beta) + View(std::get(all_polynomials)); }); const auto& gamma = params.gamma; return result + gamma; diff --git a/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp index 6fd7159ba37..3439aea9abf 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp @@ -151,10 +151,9 @@ template class GenericPermutationRelationImpl auto result = Accumulator(0); // Iterate over tuple and sum as a polynomial over beta - barretenberg::constexpr_for( - [&]() { result = result * params.beta + View(std::get(all_polynomials)); }); + bb::constexpr_for([&]() { result = result * params.beta + View(std::get(all_polynomials)); }); const auto& gamma = params.gamma; return result + gamma; @@ -182,10 +181,9 @@ template class GenericPermutationRelationImpl auto result = Accumulator(0); // Iterate over tuple and sum as a polynomial over beta - barretenberg::constexpr_for( - [&]() { result = result * params.beta + View(std::get(used_entities)); }); + bb::constexpr_for([&]() { result = result * params.beta + View(std::get(used_entities)); }); const auto& gamma = params.gamma; return result + gamma; diff --git a/barretenberg/cpp/src/barretenberg/relations/nested_containers.hpp b/barretenberg/cpp/src/barretenberg/relations/nested_containers.hpp index 90ca8238ce1..2f30a94b776 100644 --- a/barretenberg/cpp/src/barretenberg/relations/nested_containers.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/nested_containers.hpp @@ -33,7 +33,7 @@ using HomogeneousTupleToArray = std::array, std:: // Types needed for sumcheck and folding. template -using TupleOfUnivariates = typename TupleOfContainersOverArray::type; +using TupleOfUnivariates = typename TupleOfContainersOverArray::type; template using TupleOfValues = typename TupleOfContainersOverArray::type; diff --git a/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp b/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp index 74ad603403a..8f5c1bba63b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp @@ -7,7 +7,7 @@ using namespace proof_system; namespace proof_system::nested_contianers_tests { -using FF = barretenberg::fr; +using FF = bb::fr; class NestedContainers : public testing::Test {}; @@ -15,9 +15,9 @@ TEST_F(NestedContainers, Univariate) { static constexpr std::array LENGTHS = { 0, 1, 2 }; static constexpr TupleOfUnivariates tuple; - static constexpr auto result0 = barretenberg::Univariate(); - static constexpr auto result1 = barretenberg::Univariate(); - static constexpr auto result2 = barretenberg::Univariate(); + static constexpr auto result0 = bb::Univariate(); + static constexpr auto result1 = bb::Univariate(); + static constexpr auto result2 = bb::Univariate(); EXPECT_EQ(std::get<0>(tuple), result0); EXPECT_EQ(std::get<1>(tuple), result1); EXPECT_EQ(std::get<2>(tuple), result2); diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp b/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp index 752852167a1..8b245739e66 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp @@ -6,7 +6,7 @@ namespace proof_system::relation_manual_tests { -using FF = barretenberg::fr; +using FF = bb::fr; class RelationManual : public testing::Test {}; diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp index b53d154cbfe..252905c086b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp @@ -4,7 +4,7 @@ #include template -concept IsField = std::same_as /* || std::same_as */; +concept IsField = std::same_as /* || std::same_as */; namespace proof_system { diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp index aeaf1178c2c..056e6e0fe3e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp @@ -616,7 +616,7 @@ void GoblinTranslatorDecompositionRelationImpl::accumulate(ContainerOverSubr std::get<47>(accumulators) += tmp_48; }; -template class GoblinTranslatorDecompositionRelationImpl; +template class GoblinTranslatorDecompositionRelationImpl; DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, honk::flavor::GoblinTranslator); } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp index 9224f4966f8..173e4c4214b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp @@ -146,8 +146,8 @@ void GoblinTranslatorAccumulatorTransferRelationImpl::accumulate(ContainerOv std::get<11>(accumulators) += tmp_12; }; -template class GoblinTranslatorOpcodeConstraintRelationImpl; -template class GoblinTranslatorAccumulatorTransferRelationImpl; +template class GoblinTranslatorOpcodeConstraintRelationImpl; +template class GoblinTranslatorAccumulatorTransferRelationImpl; DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorOpcodeConstraintRelationImpl, honk::flavor::GoblinTranslator); DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, honk::flavor::GoblinTranslator); diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp index 8cbb0ea995e..628701ffa14 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp @@ -126,7 +126,7 @@ void GoblinTranslatorGenPermSortRelationImpl::accumulate(ContainerOverSubrel }(); }; -template class GoblinTranslatorGenPermSortRelationImpl; +template class GoblinTranslatorGenPermSortRelationImpl; DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorGenPermSortRelationImpl, honk::flavor::GoblinTranslator); } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp index 9a4722593cf..37bfc28fa02 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp @@ -277,7 +277,7 @@ void GoblinTranslatorNonNativeFieldRelationImpl::accumulate(ContainerOverSub std::get<2>(accumulators) += tmp; }; -template class GoblinTranslatorNonNativeFieldRelationImpl; +template class GoblinTranslatorNonNativeFieldRelationImpl; DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, honk::flavor::GoblinTranslator); } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp index 508fd95ca2e..8b6078fb6ae 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp @@ -59,7 +59,7 @@ void GoblinTranslatorPermutationRelationImpl::accumulate(ContainerOverSubrel }(); }; -template class GoblinTranslatorPermutationRelationImpl; +template class GoblinTranslatorPermutationRelationImpl; DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorPermutationRelationImpl, honk::flavor::GoblinTranslator); } // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp index 65d33ff8c73..2b4964bec5b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp @@ -28,7 +28,7 @@ using namespace proof_system; namespace proof_system::ultra_relation_consistency_tests { -using FF = barretenberg::fr; +using FF = bb::fr; struct InputElements { static constexpr size_t NUM_ELEMENTS = 45; std::array _data; diff --git a/barretenberg/cpp/src/barretenberg/relations/utils.hpp b/barretenberg/cpp/src/barretenberg/relations/utils.hpp index b3a0750617e..e1379999875 100644 --- a/barretenberg/cpp/src/barretenberg/relations/utils.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/utils.hpp @@ -5,7 +5,7 @@ #include "barretenberg/polynomials/pow.hpp" #include "barretenberg/relations/relation_parameters.hpp" -namespace barretenberg { +namespace bb { template class RelationUtils { public: @@ -174,7 +174,7 @@ template class RelationUtils { /** * @brief Set each element in a tuple of arrays to zero. - * @details FF's default constructor may not initialize to zero (e.g., barretenberg::fr), hence we can't rely on + * @details FF's default constructor may not initialize to zero (e.g., bb::fr), hence we can't rely on * aggregate initialization of the evaluations array. */ template static void zero_elements(auto& tuple) @@ -241,4 +241,4 @@ template class RelationUtils { } } }; -} // namespace barretenberg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp b/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp index e9f83617578..3979e8919be 100644 --- a/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp +++ b/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp @@ -7,33 +7,33 @@ // TODO eventually move to barretenberg struct GoodExample { - barretenberg::fr a; - barretenberg::fr b; + bb::fr a; + bb::fr b; MSGPACK_FIELDS(a, b); } good_example; struct BadExampleOverlap { - barretenberg::fr a; - barretenberg::fr b; + bb::fr a; + bb::fr b; MSGPACK_FIELDS(a, a); } bad_example_overlap; struct BadExampleIncomplete { - barretenberg::fr a; - barretenberg::fr b; + bb::fr a; + bb::fr b; MSGPACK_FIELDS(a); } bad_example_incomplete; struct BadExampleCompileTimeError { std::vector a; - barretenberg::fr b; + bb::fr b; MSGPACK_FIELDS(b); // Type mismatch, expect 'a', will catch at compile-time } bad_example_compile_time_error; struct BadExampleOutOfObject { - barretenberg::fr a; - barretenberg::fr b; + bb::fr a; + bb::fr b; void msgpack(auto ar) { BadExampleOutOfObject other_object; @@ -66,10 +66,10 @@ TEST(msgpack_tests, msgpack_sanity_sanity) } struct ComplicatedSchema { - std::vector> array; + std::vector> array; std::optional good_or_not; - barretenberg::fr bare; - std::variant huh; + bb::fr bare; + std::variant huh; MSGPACK_FIELDS(array, good_or_not, bare, huh); } complicated_schema; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/circuit/circuit.hpp b/barretenberg/cpp/src/barretenberg/smt_verification/circuit/circuit.hpp index 96e8a9c3ff6..57ed452b7ba 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/circuit/circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/circuit/circuit.hpp @@ -20,8 +20,8 @@ struct CircuitSchema { std::string modulus; std::vector public_inps; std::unordered_map vars_of_interest; - std::vector variables; - std::vector> selectors; + std::vector variables; + std::vector> selectors; std::vector> wires; MSGPACK_FIELDS(modulus, public_inps, vars_of_interest, variables, selectors, wires); }; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp index 3747c980e65..78b3f2d5aa1 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp @@ -27,7 +27,7 @@ #include "barretenberg/smt_verification/circuit/circuit.hpp" using namespace smt_circuit; -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; using field_ct = proof_system::plonk::stdlib::field_t; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp index 5aa84f4c24d..6db36ab0eb8 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp @@ -8,7 +8,7 @@ #include "barretenberg/smt_verification/circuit/circuit.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace { diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp index 1570c0dec4d..7e694347deb 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp @@ -13,7 +13,7 @@ #include "barretenberg/serialize/cbind.hpp" #include "barretenberg/smt_verification/circuit/circuit.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; using namespace smt_circuit; diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp index 229473d156c..02ee6b17cf8 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp @@ -32,7 +32,7 @@ template class RecursiveCircuit { using inner_scalar_field = typename inner_curve::ScalarFieldNative; using outer_scalar_field = typename outer_curve::BaseFieldNative; - using pairing_target_field = barretenberg::fq12; + using pairing_target_field = bb::fq12; static constexpr bool is_ultra_to_ultra = std::is_same_v; using ProverOfInnerCircuit = std::conditional_t; @@ -101,8 +101,7 @@ template class RecursiveCircuit { return { output, verification_key }; }; - static bool check_recursive_proof_public_inputs(OuterBuilder& builder, - const barretenberg::pairing::miller_lines* lines) + static bool check_recursive_proof_public_inputs(OuterBuilder& builder, const bb::pairing::miller_lines* lines) { if (builder.contains_recursive_proof && builder.recursive_proof_public_input_indices.size() == 16) { const auto& inputs = builder.public_inputs; @@ -140,8 +139,7 @@ template class RecursiveCircuit { { x1, y1 }, }; - pairing_target_field result = - barretenberg::pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); + pairing_target_field result = bb::pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); return (result == pairing_target_field::one()); } @@ -152,14 +150,13 @@ template class RecursiveCircuit { } static void check_pairing(const circuit_outputs& circuit_output) { - auto g2_lines = barretenberg::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); g1::affine_element P[2]; P[0].x = outer_scalar_field(circuit_output.aggregation_state.P0.x.get_value().lo); P[0].y = outer_scalar_field(circuit_output.aggregation_state.P0.y.get_value().lo); P[1].x = outer_scalar_field(circuit_output.aggregation_state.P1.x.get_value().lo); P[1].y = outer_scalar_field(circuit_output.aggregation_state.P1.y.get_value().lo); - pairing_target_field inner_proof_result = - barretenberg::pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); + pairing_target_field inner_proof_result = bb::pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); if (inner_proof_result != pairing_target_field::one()) { throw_or_abort("inner proof result != 1"); } diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/key_gen.cpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/key_gen.cpp index ff7601e7fc4..b9f750400dd 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/key_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/key_gen.cpp @@ -64,7 +64,7 @@ int main(int argc, char** argv) const std::string output_path = args[3]; const std::string srs_path = args[4]; - barretenberg::srs::init_crs_factory(srs_path); + bb::srs::init_crs_factory(srs_path); // @todo - Add support for unrolled standard verifier. Needs a new solidity verifier contract. if (plonk_flavour != "ultra") { diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp index 8bd33bb6560..97e82644e88 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp @@ -62,7 +62,7 @@ int main(int argc, char** argv) const std::string srs_path = args[3]; const std::string string_input = args[4]; - barretenberg::srs::init_crs_factory(srs_path); + bb::srs::init_crs_factory(srs_path); // @todo dynamically allocate this uint256_t inputs[] = { 0, 0, 0, 0, 0, 0 }; diff --git a/barretenberg/cpp/src/barretenberg/srs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/srs/c_bind.cpp index 43e3ea04153..96514f54617 100644 --- a/barretenberg/cpp/src/barretenberg/srs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/c_bind.cpp @@ -6,7 +6,7 @@ #include #include -using namespace barretenberg; +using namespace bb; /** * We are not passed a vector (length prefixed), but the buffer and num points independently. @@ -17,10 +17,10 @@ WASM_EXPORT void srs_init_srs(uint8_t const* points_buf, uint32_t const* num_poi auto num_points = ntohl(*num_points_buf); auto g1_points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - g1_points[i] = from_buffer(points_buf, i * 64); + g1_points[i] = from_buffer(points_buf, i * 64); } auto g2_point = from_buffer(g2_point_buf); - barretenberg::srs::init_crs_factory(g1_points, g2_point); + bb::srs::init_crs_factory(g1_points, g2_point); } /** @@ -32,5 +32,5 @@ WASM_EXPORT void srs_init_grumpkin_srs(uint8_t const* points_buf, uint32_t const auto points = std::vector(ntohl(*num_points)); srs::IO::read_affine_elements_from_buffer(points.data(), (char*)points_buf, points.size() * 64); - barretenberg::srs::init_grumpkin_crs_factory(points); + bb::srs::init_grumpkin_crs_factory(points); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/crs_factory.hpp b/barretenberg/cpp/src/barretenberg/srs/factories/crs_factory.hpp index ddc34fd41f0..66e5e55f27d 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/crs_factory.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/crs_factory.hpp @@ -6,11 +6,11 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include -namespace barretenberg::pairing { +namespace bb::pairing { struct miller_lines; -} // namespace barretenberg::pairing +} // namespace bb::pairing -namespace barretenberg::srs::factories { +namespace bb::srs::factories { /** * A prover crs representation. @@ -40,7 +40,7 @@ template <> class VerifierCrs { * @brief As the G_2 element of the CRS is fixed, we can precompute the operations performed on it during the * pairing algorithm to optimize pairing computations. */ - virtual barretenberg::pairing::miller_lines const* get_precomputed_g2_lines() const = 0; + virtual bb::pairing::miller_lines const* get_precomputed_g2_lines() const = 0; /** * @brief Returns the first G_1 element from the CRS, used by the Shplonk verifier to compute the final * commtiment. @@ -74,12 +74,11 @@ template class CrsFactory { CrsFactory() = default; CrsFactory(CrsFactory&& other) = default; virtual ~CrsFactory() = default; - virtual std::shared_ptr> get_prover_crs(size_t) { return nullptr; } - virtual std::shared_ptr> get_verifier_crs( - [[maybe_unused]] size_t degree = 0) + virtual std::shared_ptr> get_prover_crs(size_t) { return nullptr; } + virtual std::shared_ptr> get_verifier_crs([[maybe_unused]] size_t degree = 0) { return nullptr; } }; -} // namespace barretenberg::srs::factories \ No newline at end of file +} // namespace bb::srs::factories \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.cpp index 602300657dc..f082700e32f 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.cpp @@ -7,18 +7,17 @@ #include "barretenberg/ecc/scalar_multiplication/point_table.hpp" #include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp" -namespace barretenberg::srs::factories { +namespace bb::srs::factories { FileVerifierCrs::FileVerifierCrs(std::string const& path, const size_t) - : precomputed_g2_lines( - (barretenberg::pairing::miller_lines*)(aligned_alloc(64, sizeof(barretenberg::pairing::miller_lines) * 2))) + : precomputed_g2_lines((bb::pairing::miller_lines*)(aligned_alloc(64, sizeof(bb::pairing::miller_lines) * 2))) { using Curve = curve::BN254; auto point_buf = scalar_multiplication::point_table_alloc(1); srs::IO::read_transcript_g1(point_buf.get(), 1, path); srs::IO::read_transcript_g2(g2_x, path); - barretenberg::pairing::precompute_miller_lines(barretenberg::g2::one, precomputed_g2_lines[0]); - barretenberg::pairing::precompute_miller_lines(g2_x, precomputed_g2_lines[1]); + bb::pairing::precompute_miller_lines(bb::g2::one, precomputed_g2_lines[0]); + bb::pairing::precompute_miller_lines(g2_x, precomputed_g2_lines[1]); first_g1 = point_buf[0]; } @@ -54,7 +53,7 @@ FileCrsFactory::FileCrsFactory(std::string path, size_t initial_degree) {} template -std::shared_ptr> FileCrsFactory::get_prover_crs(size_t degree) +std::shared_ptr> FileCrsFactory::get_prover_crs(size_t degree) { if (degree != degree_ || !prover_crs_) { prover_crs_ = std::make_shared>(degree, path_); @@ -64,7 +63,7 @@ std::shared_ptr> FileCrsFactory -std::shared_ptr> FileCrsFactory::get_verifier_crs(size_t degree) +std::shared_ptr> FileCrsFactory::get_verifier_crs(size_t degree) { if (degree != degree_ || !verifier_crs_) { verifier_crs_ = std::make_shared>(path_, degree); @@ -78,4 +77,4 @@ template class FileProverCrs; template class FileCrsFactory; template class FileCrsFactory; -} // namespace barretenberg::srs::factories +} // namespace bb::srs::factories diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.hpp b/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.hpp index c17ffc84f5c..09dad29a1cb 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/file_crs_factory.hpp @@ -8,7 +8,7 @@ #include #include -namespace barretenberg::srs::factories { +namespace bb::srs::factories { /** * Create reference strings given a path to a directory of transcript files. @@ -18,15 +18,15 @@ template class FileCrsFactory : public CrsFactory { FileCrsFactory(std::string path, size_t initial_degree = 0); FileCrsFactory(FileCrsFactory&& other) = default; - std::shared_ptr> get_prover_crs(size_t degree) override; + std::shared_ptr> get_prover_crs(size_t degree) override; - std::shared_ptr> get_verifier_crs(size_t degree = 0) override; + std::shared_ptr> get_verifier_crs(size_t degree = 0) override; private: std::string path_; size_t degree_; - std::shared_ptr> prover_crs_; - std::shared_ptr> verifier_crs_; + std::shared_ptr> prover_crs_; + std::shared_ptr> verifier_crs_; }; template class FileProverCrs : public ProverCrs { @@ -86,4 +86,4 @@ template <> class FileVerifierCrs : public VerifierCrs monomials_; }; -} // namespace barretenberg::srs::factories +} // namespace bb::srs::factories diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp index a9161115af0..0c9767328a0 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.cpp @@ -8,19 +8,19 @@ namespace { -using namespace barretenberg; -using namespace barretenberg::srs::factories; +using namespace bb; +using namespace bb::srs::factories; class MemVerifierCrs : public VerifierCrs { public: MemVerifierCrs(g2::affine_element const& g2_point) : g2_x(g2_point) , precomputed_g2_lines( - static_cast(aligned_alloc(64, sizeof(barretenberg::pairing::miller_lines) * 2))) + static_cast(aligned_alloc(64, sizeof(bb::pairing::miller_lines) * 2))) { - barretenberg::pairing::precompute_miller_lines(barretenberg::g2::one, precomputed_g2_lines[0]); - barretenberg::pairing::precompute_miller_lines(g2_x, precomputed_g2_lines[1]); + bb::pairing::precompute_miller_lines(bb::g2::one, precomputed_g2_lines[0]); + bb::pairing::precompute_miller_lines(g2_x, precomputed_g2_lines[1]); } virtual ~MemVerifierCrs() { aligned_free(precomputed_g2_lines); } @@ -38,7 +38,7 @@ class MemVerifierCrs : public VerifierCrs { } // namespace -namespace barretenberg::srs::factories { +namespace bb::srs::factories { MemBn254CrsFactory::MemBn254CrsFactory(std::vector const& points, g2::affine_element const& g2_point) @@ -46,14 +46,14 @@ MemBn254CrsFactory::MemBn254CrsFactory(std::vector const& po , verifier_crs_(std::make_shared(g2_point)) {} -std::shared_ptr> MemBn254CrsFactory::get_prover_crs(size_t) +std::shared_ptr> MemBn254CrsFactory::get_prover_crs(size_t) { return prover_crs_; } -std::shared_ptr> MemBn254CrsFactory::get_verifier_crs(size_t) +std::shared_ptr> MemBn254CrsFactory::get_verifier_crs(size_t) { return verifier_crs_; } -} // namespace barretenberg::srs::factories \ No newline at end of file +} // namespace bb::srs::factories \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.hpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.hpp index 9054a4a2812..017674a9643 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_bn254_crs_factory.hpp @@ -6,7 +6,7 @@ #include #include -namespace barretenberg::srs::factories { +namespace bb::srs::factories { /** * Create reference strings given pointers to in memory buffers. @@ -18,14 +18,13 @@ class MemBn254CrsFactory : public CrsFactory { MemBn254CrsFactory(std::vector const& points, g2::affine_element const& g2_point); MemBn254CrsFactory(MemBn254CrsFactory&& other) = default; - std::shared_ptr> get_prover_crs(size_t degree) override; + std::shared_ptr> get_prover_crs(size_t degree) override; - std::shared_ptr> get_verifier_crs( - size_t degree = 0) override; + std::shared_ptr> get_verifier_crs(size_t degree = 0) override; private: - std::shared_ptr> prover_crs_; - std::shared_ptr> verifier_crs_; + std::shared_ptr> prover_crs_; + std::shared_ptr> verifier_crs_; }; -} // namespace barretenberg::srs::factories +} // namespace bb::srs::factories diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp index 7477ebd63b9..46dfdecc57a 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp @@ -7,8 +7,8 @@ #include #include -using namespace barretenberg; -using namespace barretenberg::srs::factories; +using namespace bb; +using namespace bb::srs::factories; using namespace curve; TEST(reference_string, mem_bn254_file_consistency) @@ -41,7 +41,7 @@ TEST(reference_string, mem_bn254_file_consistency) EXPECT_EQ(memcmp(mem_verifier_crs->get_precomputed_g2_lines(), file_verifier_crs->get_precomputed_g2_lines(), - sizeof(barretenberg::pairing::miller_lines) * 2), + sizeof(bb::pairing::miller_lines) * 2), 0); } diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp index 253374e1d46..d9ab3b28f59 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp @@ -8,8 +8,8 @@ namespace { using namespace curve; -using namespace barretenberg; -using namespace barretenberg::srs::factories; +using namespace bb; +using namespace bb::srs::factories; using Curve = curve::Grumpkin; @@ -35,21 +35,21 @@ class MemVerifierCrs : public VerifierCrs { } // namespace -namespace barretenberg::srs::factories { +namespace bb::srs::factories { MemGrumpkinCrsFactory::MemGrumpkinCrsFactory(std::vector const& points) : prover_crs_(std::make_shared>(points)) , verifier_crs_(std::make_shared(points)) {} -std::shared_ptr> MemGrumpkinCrsFactory::get_prover_crs(size_t) +std::shared_ptr> MemGrumpkinCrsFactory::get_prover_crs(size_t) { return prover_crs_; } -std::shared_ptr> MemGrumpkinCrsFactory::get_verifier_crs(size_t) +std::shared_ptr> MemGrumpkinCrsFactory::get_verifier_crs(size_t) { return verifier_crs_; } -} // namespace barretenberg::srs::factories \ No newline at end of file +} // namespace bb::srs::factories \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.hpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.hpp index f1fb942ef05..700dc14f08b 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.hpp @@ -3,7 +3,7 @@ #include #include -namespace barretenberg::srs::factories { +namespace bb::srs::factories { /** * Create reference strings given pointers to in memory buffers. @@ -15,14 +15,13 @@ class MemGrumpkinCrsFactory : public CrsFactory { MemGrumpkinCrsFactory(std::vector const& points); MemGrumpkinCrsFactory(MemGrumpkinCrsFactory&& other) = default; - std::shared_ptr> get_prover_crs(size_t degree) override; + std::shared_ptr> get_prover_crs(size_t degree) override; - std::shared_ptr> get_verifier_crs( - size_t degree = 0) override; + std::shared_ptr> get_verifier_crs(size_t degree = 0) override; private: - std::shared_ptr> prover_crs_; - std::shared_ptr> verifier_crs_; + std::shared_ptr> prover_crs_; + std::shared_ptr> verifier_crs_; }; -} // namespace barretenberg::srs::factories +} // namespace bb::srs::factories diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_prover_crs.hpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_prover_crs.hpp index b3a1bc79e56..20fbcda9e54 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_prover_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_prover_crs.hpp @@ -4,7 +4,7 @@ #include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp" #include "barretenberg/srs/factories/crs_factory.hpp" -namespace barretenberg::srs::factories { +namespace bb::srs::factories { // Common to both Grumpkin and Bn254, and generally curves regardless of pairing-friendliness template class MemProverCrs : public ProverCrs { public: @@ -25,4 +25,4 @@ template class MemProverCrs : public ProverCrs { std::shared_ptr monomials_; }; -} // namespace barretenberg::srs::factories \ No newline at end of file +} // namespace bb::srs::factories \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp index c156cae415e..6bf83a86b44 100644 --- a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp @@ -6,11 +6,11 @@ namespace { // TODO(#637): As a PoC we have two global variables for the two CRS but this could be improved to avoid duplication. -std::shared_ptr> crs_factory; -std::shared_ptr> grumpkin_crs_factory; +std::shared_ptr> crs_factory; +std::shared_ptr> grumpkin_crs_factory; } // namespace -namespace barretenberg::srs { +namespace bb::srs { // Initializes the crs using the memory buffers void init_crs_factory(std::vector const& points, g2::affine_element const g2_point) @@ -50,4 +50,4 @@ std::shared_ptr> get_grumpkin_crs_factory } return grumpkin_crs_factory; } -} // namespace barretenberg::srs \ No newline at end of file +} // namespace bb::srs \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp b/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp index ef57171a449..a2aa632b16d 100644 --- a/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/global_crs.hpp @@ -2,7 +2,7 @@ #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace barretenberg::srs { +namespace bb::srs { // Initializes the crs using files void init_crs_factory(std::string crs_path); @@ -10,10 +10,9 @@ void init_grumpkin_crs_factory(std::string crs_path); // Initializes the crs using memory buffers void init_grumpkin_crs_factory(std::vector const& points); -void init_crs_factory(std::vector const& points, - barretenberg::g2::affine_element const g2_point); +void init_crs_factory(std::vector const& points, bb::g2::affine_element const g2_point); -std::shared_ptr> get_crs_factory(); -std::shared_ptr> get_grumpkin_crs_factory(); +std::shared_ptr> get_crs_factory(); +std::shared_ptr> get_grumpkin_crs_factory(); -} // namespace barretenberg::srs \ No newline at end of file +} // namespace bb::srs \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/srs/io.hpp b/barretenberg/cpp/src/barretenberg/srs/io.hpp index 7dff29f349e..24397f47608 100644 --- a/barretenberg/cpp/src/barretenberg/srs/io.hpp +++ b/barretenberg/cpp/src/barretenberg/srs/io.hpp @@ -7,7 +7,7 @@ #include #include -namespace barretenberg::srs { +namespace bb::srs { /** * @brief The manifest structure holds the header of a transcript file * @@ -427,4 +427,4 @@ template class IO { } }; -} // namespace barretenberg::srs +} // namespace bb::srs diff --git a/barretenberg/cpp/src/barretenberg/srs/io.test.cpp b/barretenberg/cpp/src/barretenberg/srs/io.test.cpp index ce0e7a601cd..f9d2db9e30f 100644 --- a/barretenberg/cpp/src/barretenberg/srs/io.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/io.test.cpp @@ -4,7 +4,7 @@ #include "barretenberg/ecc/curves/bn254/pairing.hpp" #include -using namespace barretenberg; +using namespace bb; TEST(io, read_transcript_loads_well_formed_srs) { diff --git a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp index cc20572566e..b9805c7c7d1 100644 --- a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp @@ -24,7 +24,7 @@ namespace { auto& engine = numeric::random::get_debug_engine(); } -using namespace barretenberg; +using namespace bb; template class ScalarMultiplicationTests : public ::testing::Test { public: @@ -72,7 +72,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBucketsSimple) auto crs = srs::factories::FileProverCrs(num_points / 2, TestFixture::SRS_PATH); auto monomials = crs.get_monomial_points(); - std::vector point_schedule(barretenberg::scalar_multiplication::point_table_size(num_points / 2)); + std::vector point_schedule(bb::scalar_multiplication::point_table_size(num_points / 2)); std::array bucket_empty_status; // 16 buckets, each bucket has one point std::array transcript; @@ -231,14 +231,14 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBucketsSimple) std::array bucket_counts; std::array bit_offsets = { 0 }; - barretenberg::scalar_multiplication::affine_product_runtime_state product_state{ + bb::scalar_multiplication::affine_product_runtime_state product_state{ &monomials[0], &point_pairs[0], &output_buckets[0], &scratch_space[0], &bucket_counts[0], &bit_offsets[0], &point_schedule[0], num_points, 2, &bucket_empty_status[0] }; - AffineElement* output = barretenberg::scalar_multiplication::reduce_buckets(product_state, true); + AffineElement* output = bb::scalar_multiplication::reduce_buckets(product_state, true); for (size_t i = 0; i < product_state.num_buckets; ++i) { expected[i] = expected[i].normalize(); @@ -274,8 +274,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) TestFixture::read_transcript(monomials, num_initial_points, TestFixture::SRS_PATH); - barretenberg::scalar_multiplication::generate_pippenger_point_table( - monomials, monomials, num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * num_initial_points)); @@ -283,21 +282,21 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) scalars[i] = Fr::random_element(); } - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_initial_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::organize_buckets(state.point_schedule, num_points); + bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = barretenberg::scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * 100 * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -313,21 +312,19 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) const size_t last_bucket = point_schedule_copy[num_points - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - barretenberg::scalar_multiplication::affine_product_runtime_state product_state{ - monomials, - point_pairs, - scratch_points, - scratch_field, - bucket_counts, - &bit_offsets[0], - &state.point_schedule[num_points], - num_points, - static_cast(num_buckets), - bucket_empty_status - }; + bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, + point_pairs, + scratch_points, + scratch_field, + bucket_counts, + &bit_offsets[0], + &state.point_schedule[num_points], + num_points, + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - // barretenberg::scalar_multiplication::scalar_multiplication_internal(state, monomials); + // bb::scalar_multiplication::scalar_multiplication_internal(state, monomials); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "scalar mul: " << diff.count() << "ms" << std::endl; @@ -348,7 +345,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) size_t it = 0; - AffineElement* result_buckets = barretenberg::scalar_multiplication::reduce_buckets(product_state, true); + AffineElement* result_buckets = bb::scalar_multiplication::reduce_buckets(product_state, true); printf("num buckets = %zu \n", num_buckets); for (size_t i = 0; i < num_buckets; ++i) { @@ -404,23 +401,22 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) Fr::__copy(source_scalar, scalars[i]); } - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_initial_points); - barretenberg::scalar_multiplication::generate_pippenger_point_table( - monomials, monomials, num_initial_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::organize_buckets(state.point_schedule, num_points); + bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = barretenberg::scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -429,22 +425,20 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) const size_t last_bucket = state.point_schedule[num_points - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - barretenberg::scalar_multiplication::affine_product_runtime_state product_state{ - monomials, - point_pairs, - scratch_points, - scratch_field, - bucket_counts, - &bit_offsets[0], - state.point_schedule, - (uint32_t)state.round_counts[0], - static_cast(num_buckets), - bucket_empty_status - }; + bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, + point_pairs, + scratch_points, + scratch_field, + bucket_counts, + &bit_offsets[0], + state.point_schedule, + (uint32_t)state.round_counts[0], + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::reduce_buckets(product_state, true); - // barretenberg::scalar_multiplication::scalar_multiplication_internal(state, monomials); + bb::scalar_multiplication::reduce_buckets(product_state, true); + // bb::scalar_multiplication::scalar_multiplication_internal(state, monomials); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "scalar mul: " << diff.count() << "ms" << std::endl; @@ -484,7 +478,7 @@ TYPED_TEST(ScalarMultiplicationTests, AddAffinePoints) points_copy[count + 1] = points_copy[count + 1].normalize(); } - barretenberg::scalar_multiplication::add_affine_points(points, num_points, scratch_space); + bb::scalar_multiplication::add_affine_points(points, num_points, scratch_space); for (size_t i = num_points - 1; i > num_points - 1 - (num_points / 2); --i) { EXPECT_EQ((points[i].x == points_copy[i].x), true); EXPECT_EQ((points[i].y == points_copy[i].y), true); @@ -515,23 +509,22 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) Fr::__copy(source_scalar, scalars[i]); } - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_initial_points); - barretenberg::scalar_multiplication::generate_pippenger_point_table( - monomials, monomials, num_initial_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::organize_buckets(state.point_schedule, num_points); + bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = barretenberg::scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); bool* bucket_empty_status = static_cast(aligned_alloc(64, num_points * sizeof(bool))); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -540,21 +533,20 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) const size_t last_bucket = state.point_schedule[state.round_counts[0] - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - barretenberg::scalar_multiplication::affine_product_runtime_state product_state{ - monomials, - monomials, - monomials, - nullptr, - bucket_counts, - &bit_offsets[0], - state.point_schedule, - static_cast(state.round_counts[0]), - static_cast(num_buckets), - bucket_empty_status - }; + bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, + monomials, + monomials, + nullptr, + bucket_counts, + &bit_offsets[0], + state.point_schedule, + static_cast( + state.round_counts[0]), + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - barretenberg::scalar_multiplication::construct_addition_chains(product_state, true); + bb::scalar_multiplication::construct_addition_chains(product_state, true); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); info("construct addition chains: ", diff.count(), "ms"); @@ -616,7 +608,7 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) // check that our radix sort correctly sorts! constexpr size_t target_degree = 1 << 8; - constexpr size_t num_rounds = barretenberg::scalar_multiplication::get_num_rounds(target_degree * 2); + constexpr size_t num_rounds = bb::scalar_multiplication::get_num_rounds(target_degree * 2); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * target_degree)); Fr source_scalar = Fr::random_element(); @@ -625,14 +617,14 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) Fr::__copy(source_scalar, scalars[i]); } - barretenberg::scalar_multiplication::pippenger_runtime_state state(target_degree); - barretenberg::scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::pippenger_runtime_state state(target_degree); + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, target_degree); uint64_t* wnaf_copy = (uint64_t*)(aligned_alloc(64, sizeof(uint64_t) * target_degree * 2 * num_rounds)); memcpy((void*)wnaf_copy, (void*)state.point_schedule, sizeof(uint64_t) * target_degree * 2 * num_rounds); - barretenberg::scalar_multiplication::organize_buckets(state.point_schedule, target_degree * 2); + bb::scalar_multiplication::organize_buckets(state.point_schedule, target_degree * 2); for (size_t i = 0; i < num_rounds; ++i) { uint64_t* unsorted_wnaf = &wnaf_copy[i * target_degree * 2]; uint64_t* sorted_wnaf = &state.point_schedule[i * target_degree * 2]; @@ -676,7 +668,7 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) memcpy((void*)(monomials + (2 * transcript_degree)), (void*)monomials, ((2 * target_degree - 2 * transcript_degree) * sizeof(AffineElement))); - barretenberg::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, target_degree); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, target_degree); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * target_degree)); @@ -686,17 +678,17 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) accumulator *= source_scalar; Fr::__copy(accumulator, scalars[i]); } - barretenberg::scalar_multiplication::pippenger_runtime_state state(target_degree); + bb::scalar_multiplication::pippenger_runtime_state state(target_degree); - Element first = barretenberg::scalar_multiplication::pippenger(scalars, monomials, target_degree, state); + Element first = bb::scalar_multiplication::pippenger(scalars, monomials, target_degree, state); first = first.normalize(); for (size_t i = 0; i < target_degree; ++i) { scalars[i].self_neg(); } - barretenberg::scalar_multiplication::pippenger_runtime_state state_2(target_degree); + bb::scalar_multiplication::pippenger_runtime_state state_2(target_degree); - Element second = barretenberg::scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); + Element second = bb::scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); second = second.normalize(); EXPECT_EQ((first.z == second.z), true); @@ -735,11 +727,11 @@ TYPED_TEST(ScalarMultiplicationTests, UndersizedInputs) expected += temp; } expected = expected.normalize(); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -773,10 +765,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerSmall) expected += temp; } expected = expected.normalize(); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -813,9 +805,9 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerEdgeCaseDbl) if (!expected.is_point_at_infinity()) { expected = expected.normalize(); } - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points, num_points, state); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -835,7 +827,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) Fr* scalars = (Fr*)aligned_alloc(32, sizeof(Fr) * num_points); - auto points = barretenberg::scalar_multiplication::point_table_alloc(num_points); + auto points = bb::scalar_multiplication::point_table_alloc(num_points); for (std::ptrdiff_t i = 0; i < (std::ptrdiff_t)num_points; ++i) { points[i] = AffineElement(Element::random_element()); @@ -870,10 +862,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) expected += temp; } expected = expected.normalize(); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points.get(), num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -892,7 +884,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) Fr* scalars = (Fr*)aligned_alloc(32, sizeof(Fr) * num_points); - auto points = barretenberg::scalar_multiplication::point_table_alloc(num_points); + auto points = bb::scalar_multiplication::point_table_alloc(num_points); for (std::ptrdiff_t i = 0; i < (std::ptrdiff_t)num_points; ++i) { scalars[i] = Fr::random_element(); @@ -906,11 +898,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) expected += temp; } expected = expected.normalize(); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = - barretenberg::scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); + Element result = bb::scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -964,10 +955,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafeShortInputs) expected += temp; } expected = expected.normalize(); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = barretenberg::scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -1001,10 +992,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerOne) expected += temp; } expected = expected.normalize(); - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - barretenberg::scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -1024,8 +1015,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerZeroPoints) AffineElement* points = (AffineElement*)aligned_alloc(32, sizeof(AffineElement) * (2 + 1)); - barretenberg::scalar_multiplication::pippenger_runtime_state state(0); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points, 0, state); + bb::scalar_multiplication::pippenger_runtime_state state(0); + Element result = bb::scalar_multiplication::pippenger(scalars, points, 0, state); aligned_free(scalars); aligned_free(points); @@ -1047,10 +1038,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerMulByZero) scalars[0] = Fr::zero(); points[0] = Group::affine_one; - barretenberg::scalar_multiplication::generate_pippenger_point_table(points, points, 1); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, 1); - barretenberg::scalar_multiplication::pippenger_runtime_state state(1); - Element result = barretenberg::scalar_multiplication::pippenger(scalars, points, 1, state); + bb::scalar_multiplication::pippenger_runtime_state state(1); + Element result = bb::scalar_multiplication::pippenger(scalars, points, 1, state); aligned_free(scalars); aligned_free(points); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp index e60c8c4731f..7e49097cd81 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp @@ -7,7 +7,7 @@ #include "pedersen.hpp" namespace test_StdlibPedersen { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -62,11 +62,11 @@ template class StdlibPedersen : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { - inputs.push_back(barretenberg::fr::random_element()); + inputs.push_back(bb::fr::random_element()); if (i % 2 == 1) { witness_inputs.push_back(witness_ct(&builder, inputs[i])); } else { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp index 595abbe80dc..2bbaff733c6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp @@ -8,7 +8,7 @@ #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" using namespace crypto::aes128; -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp index 9ce03d388a6..34393f39324 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp @@ -4,7 +4,7 @@ #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; TEST(stdlib_aes128, encrypt_64_bytes) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp index a84fe113e1f..78468e1ffdd 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp @@ -6,7 +6,7 @@ #include "barretenberg/common/test.hpp" #include "ecdsa.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace test_stdlib_ecdsa { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp index 9223cacdbec..b054e814188 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp @@ -7,7 +7,7 @@ namespace proof_system::test_stdlib_schnorr { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; using namespace proof_system::plonk::stdlib::schnorr; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/sha256/sha256.bench.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/sha256/sha256.bench.cpp index 3a6953d4bbc..6267595a99d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/sha256/sha256.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/sha256/sha256.bench.cpp @@ -16,7 +16,7 @@ constexpr size_t MAX_BYTES = START_BYTES + (BYTES_PER_CHUNK * (NUM_HASHES - 1)); char get_random_char() { - return static_cast(barretenberg::fr::random_element().data[0] % 8); + return static_cast(bb::fr::random_element().data[0] % 8); } void generate_test_plonk_circuit(Builder& builder, size_t num_bytes) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp index 1b01854ceaa..479e939c310 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp @@ -4,7 +4,7 @@ #include "blake2s_plookup.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; using Builder = proof_system::UltraCircuitBuilder; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp index c06f47566dd..202ef12155f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp @@ -4,7 +4,7 @@ #include "blake3s_plookup.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; using byte_array = stdlib::byte_array; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp index c6d5a2c42fd..f319e87be13 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp @@ -91,13 +91,13 @@ field_t keccak::normalize_and_rotate(const field_ct& limb, fie * stdlib::plookup cannot derive witnesses in the above pattern without a substantial rewrite, * so we do it manually in this method! **/ - plookup::ReadData lookup; + plookup::ReadData lookup; // compute plookup witness values for a given slice // (same lambda can be used to compute witnesses for left and right slices) auto compute_lookup_witnesses_for_limb = [&](uint256_t& normalized) { // (use a constexpr loop to make some pow and div operations compile-time) - barretenberg::constexpr_for<0, num_lookups, 1>([&] { + bb::constexpr_for<0, num_lookups, 1>([&] { constexpr size_t num_bits_processed = i * max_bits_per_table; // How many bits can this slice contain? diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp index 852488f5a6c..d34577022cd 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp @@ -4,7 +4,7 @@ #include "keccak.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; typedef proof_system::UltraCircuitBuilder Builder; @@ -68,7 +68,7 @@ TEST(stdlib_keccak, keccak_rho_output_table) { Builder builder = Builder(); - barretenberg::constexpr_for<0, 25, 1>([&] { + bb::constexpr_for<0, 25, 1>([&] { uint256_t extended_native = 0; uint256_t binary_native = 0; for (size_t j = 0; j < 64; ++j) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp index 0323c4c3a97..b495d7eefd3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp @@ -41,8 +41,8 @@ constexpr size_t get_index(const size_t target_count_base) } void generate_test_pedersen_hash_circuit(Builder& builder, size_t num_repetitions) { - plonk::stdlib::field_t left(plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); - plonk::stdlib::field_t out(plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); + plonk::stdlib::field_t left(plonk::stdlib::witness_t(&builder, bb::fr::random_element())); + plonk::stdlib::field_t out(plonk::stdlib::witness_t(&builder, bb::fr::random_element())); for (size_t i = 0; i < num_repetitions; ++i) { out = proof_system::plonk::stdlib::pedersen_hash::hash({ left, out }); @@ -53,7 +53,7 @@ void generate_test_pedersen_hash_buffer_circuit(Builder& builder, size_t num_rep { stdlib::byte_array input; for (size_t i = 0; i < num_repetitions; ++i) { - stdlib::byte_array tmp(plonk::stdlib::witness_t(&builder, barretenberg::fr::random_element())); + stdlib::byte_array tmp(plonk::stdlib::witness_t(&builder, bb::fr::random_element())); input.write(tmp); } auto out = proof_system::plonk::stdlib::pedersen_hash::hash_buffer(input); @@ -106,7 +106,7 @@ BENCHMARK(native_pedersen_eight_hash_bench)->MinTime(3); void construct_pedersen_witnesses_bench(State& state) noexcept { - barretenberg::srs::init_crs_factory(BARRETENBERG_SRS_PATH); + bb::srs::init_crs_factory(BARRETENBERG_SRS_PATH); for (auto _ : state) { state.PauseTiming(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp index cba3fcbca1a..3c0237f39e6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp @@ -2,7 +2,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" namespace proof_system::plonk::stdlib { -using namespace barretenberg; +using namespace bb; using namespace proof_system; template diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp index b9387245a74..44bc2f8f874 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.hpp @@ -8,7 +8,7 @@ namespace proof_system::plonk::stdlib { -using namespace barretenberg; +using namespace bb; /** * @brief stdlib class that evaluates in-circuit pedersen hashes, consistent with behavior in * crypto::pedersen_hash diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp index ba52c11b9ec..8801ed0d5d4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp @@ -6,7 +6,7 @@ #include "pedersen.hpp" namespace test_StdlibPedersen { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -156,41 +156,41 @@ template class StdlibPedersen : public testing::Test { Builder builder; for (size_t i = 0; i < 7; ++i) { - std::vector inputs; - inputs.push_back(barretenberg::fr::random_element()); - inputs.push_back(barretenberg::fr::random_element()); - inputs.push_back(barretenberg::fr::random_element()); - inputs.push_back(barretenberg::fr::random_element()); + std::vector inputs; + inputs.push_back(bb::fr::random_element()); + inputs.push_back(bb::fr::random_element()); + inputs.push_back(bb::fr::random_element()); + inputs.push_back(bb::fr::random_element()); if (i == 1) { - inputs[0] = barretenberg::fr(0); + inputs[0] = bb::fr(0); } if (i == 2) { - inputs[1] = barretenberg::fr(0); - inputs[2] = barretenberg::fr(0); + inputs[1] = bb::fr(0); + inputs[2] = bb::fr(0); } if (i == 3) { - inputs[3] = barretenberg::fr(0); + inputs[3] = bb::fr(0); } if (i == 4) { - inputs[0] = barretenberg::fr(0); - inputs[3] = barretenberg::fr(0); + inputs[0] = bb::fr(0); + inputs[3] = bb::fr(0); } if (i == 5) { - inputs[0] = barretenberg::fr(0); - inputs[1] = barretenberg::fr(0); - inputs[2] = barretenberg::fr(0); - inputs[3] = barretenberg::fr(0); + inputs[0] = bb::fr(0); + inputs[1] = bb::fr(0); + inputs[2] = bb::fr(0); + inputs[3] = bb::fr(0); } if (i == 6) { - inputs[1] = barretenberg::fr(1); + inputs[1] = bb::fr(1); } std::vector witnesses; for (auto input : inputs) { witnesses.push_back(witness_ct(&builder, input)); } - barretenberg::fr expected = crypto::pedersen_hash::hash(inputs); + bb::fr expected = crypto::pedersen_hash::hash(inputs); fr_ct result = pedersen_hash::hash(witnesses); EXPECT_EQ(result.get_value(), expected); @@ -211,7 +211,7 @@ template class StdlibPedersen : public testing::Test { std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { - inputs.emplace_back(barretenberg::fr::random_element()); + inputs.emplace_back(bb::fr::random_element()); witness_inputs.emplace_back(witness_ct(&builder, inputs[i])); } @@ -226,11 +226,11 @@ template class StdlibPedersen : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { - inputs.push_back(barretenberg::fr::random_element()); + inputs.push_back(bb::fr::random_element()); if (i % 2 == 1) { witness_inputs.push_back(witness_ct(&builder, inputs[i])); } else { @@ -238,7 +238,7 @@ template class StdlibPedersen : public testing::Test { } } - barretenberg::fr expected = crypto::pedersen_hash::hash(inputs); + bb::fr expected = crypto::pedersen_hash::hash(inputs); auto result = pedersen_hash::hash(witness_inputs); EXPECT_EQ(result.get_value(), expected); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.cpp index ff8e31dd56e..fd6a4f868e1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.cpp @@ -2,7 +2,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" namespace proof_system::plonk::stdlib { -using namespace barretenberg; +using namespace bb; using namespace proof_system; /** diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.hpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.hpp index fcfb93f91d2..b367f480106 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.hpp @@ -8,7 +8,7 @@ namespace proof_system::plonk::stdlib { -using namespace barretenberg; +using namespace bb; /** * @brief stdlib class that evaluates in-circuit poseidon2 hashes, consistent with behavior in * crypto::poseidon2 diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp index 797cec6669c..d487533a59c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp @@ -5,7 +5,7 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" namespace test_StdlibPoseidon2 { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { auto& engine = numeric::random::get_debug_engine(); @@ -129,11 +129,11 @@ template class StdlibPoseidon2 : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { - inputs.push_back(barretenberg::fr::random_element()); + inputs.push_back(bb::fr::random_element()); if (i % 2 == 1) { witness_inputs.push_back(witness_ct(&builder, inputs[i])); } else { @@ -141,7 +141,7 @@ template class StdlibPoseidon2 : public testing::Test { } } - barretenberg::fr expected = native_poseidon2::hash(inputs); + bb::fr expected = native_poseidon2::hash(inputs); auto result = poseidon2::hash(builder, witness_inputs); EXPECT_EQ(result.get_value(), expected); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp index 02409a10d2a..6e2a1b2148e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp @@ -15,7 +15,7 @@ auto& engine = numeric::random::get_debug_engine(); namespace proof_system::test_stdlib_sha256 { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; using Builder = proof_system::UltraCircuitBuilder; @@ -125,7 +125,7 @@ std::array inner_block(std::array& w) // for (size_t i = 0; i < 64; ++i) { // w_inputs[i] = engine.get_random_uint32(); // w_elements[i] = proof_system::plonk::stdlib::witness_t(&builder, -// barretenberg::fr(w_inputs[i])); +// bb::fr(w_inputs[i])); // } // const auto expected = inner_block(w_inputs); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp index 2800c1fff21..6268ab5315a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp @@ -7,7 +7,7 @@ #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" #include "barretenberg/stdlib/primitives/uint/uint.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.hpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.hpp index 7011f2db217..302e0642d13 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.hpp @@ -55,9 +55,8 @@ template struct sparse_value { { normal = in; if (normal.witness_index == IS_CONSTANT) { - sparse = field_t( - in.get_context(), - barretenberg::fr(numeric::map_into_sparse_form<16>(uint256_t(in.get_value()).data[0]))); + sparse = field_t(in.get_context(), + bb::fr(numeric::map_into_sparse_form<16>(uint256_t(in.get_value()).data[0]))); } } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.hpp index b81dfb230af..ae3e3bb6eff 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.hpp @@ -10,12 +10,12 @@ namespace proof_system::plonk::stdlib::merkle_tree { -inline barretenberg::fr hash_pair_native(barretenberg::fr const& lhs, barretenberg::fr const& rhs) +inline bb::fr hash_pair_native(bb::fr const& lhs, bb::fr const& rhs) { return crypto::pedersen_hash::hash({ lhs, rhs }); // uses lookup tables } -inline barretenberg::fr hash_native(std::vector const& inputs) +inline bb::fr hash_native(std::vector const& inputs) { return crypto::pedersen_hash::hash(inputs); // uses lookup tables } @@ -26,14 +26,14 @@ inline barretenberg::fr hash_native(std::vector const& inputs) * @param input: vector of leaf values. * @returns root as field */ -inline barretenberg::fr compute_tree_root_native(std::vector const& input) +inline bb::fr compute_tree_root_native(std::vector const& input) { // Check if the input vector size is a power of 2. ASSERT(input.size() > 0); ASSERT(numeric::is_power_of_two(input.size())); auto layer = input; while (layer.size() > 1) { - std::vector next_layer(layer.size() / 2); + std::vector next_layer(layer.size() / 2); for (size_t i = 0; i < next_layer.size(); ++i) { next_layer[i] = crypto::pedersen_hash::hash({ layer[i * 2], layer[i * 2 + 1] }); } @@ -44,15 +44,15 @@ inline barretenberg::fr compute_tree_root_native(std::vector c } // TODO write test -inline std::vector compute_tree_native(std::vector const& input) +inline std::vector compute_tree_native(std::vector const& input) { // Check if the input vector size is a power of 2. ASSERT(input.size() > 0); ASSERT(numeric::is_power_of_two(input.size())); auto layer = input; - std::vector tree(input); + std::vector tree(input); while (layer.size() > 1) { - std::vector next_layer(layer.size() / 2); + std::vector next_layer(layer.size() / 2); for (size_t i = 0; i < next_layer.size(); ++i) { next_layer[i] = crypto::pedersen_hash::hash({ layer[i * 2], layer[i * 2 + 1] }); tree.push_back(next_layer[i]); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp index b0441e7812e..73a4af577c0 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp @@ -7,7 +7,7 @@ namespace proof_system::stdlib_merkle_tree_hash_test { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; using Builder = proof_system::UltraCircuitBuilder; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash_path.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash_path.hpp index 3e6325fcb14..8a31b506298 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash_path.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash_path.hpp @@ -6,7 +6,7 @@ namespace proof_system::plonk::stdlib::merkle_tree { -using namespace barretenberg; +using namespace bb; using fr_hash_path = std::vector>; using fr_sibling_path = std::vector; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp index 577d0590563..af42b027a29 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp @@ -13,7 +13,7 @@ auto& engine = numeric::random::get_debug_engine(); namespace proof_system::stdlib_merkle_test { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib::merkle_tree; using namespace proof_system::plonk::stdlib; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.hpp index ac1b6bd0bf0..604bec13e76 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.hpp @@ -5,7 +5,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; /** * A MemoryTree is structured as follows: @@ -39,8 +39,8 @@ class MemoryTree { public: size_t depth_; size_t total_size_; - barretenberg::fr root_; - std::vector hashes_; + bb::fr root_; + std::vector hashes_; }; } // namespace merkle_tree diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.test.cpp index 2b91a36b597..f86095b1b82 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/memory_tree.test.cpp @@ -1,7 +1,7 @@ #include "memory_tree.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib::merkle_tree; static std::vector VALUES = []() { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.cpp index c104b3c829e..b4886651ecf 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.cpp @@ -12,7 +12,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; // Size of merkle tree nodes in bytes. constexpr size_t REGULAR_NODE_SIZE = 64; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.hpp index 981a502ddb0..1c25cb79e83 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.hpp @@ -6,7 +6,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; class MemoryStore; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_leaf.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_leaf.hpp index b2372c93152..0bd8034cc27 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_leaf.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_leaf.hpp @@ -6,7 +6,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; typedef uint256_t index_t; struct nullifier_leaf { @@ -24,7 +24,7 @@ struct nullifier_leaf { return os; } - barretenberg::fr hash() const { return stdlib::merkle_tree::hash_native({ value, nextIndex, nextValue }); } + bb::fr hash() const { return stdlib::merkle_tree::hash_native({ value, nextIndex, nextValue }); } }; /** @@ -70,9 +70,9 @@ class WrappedNullifierLeaf { /** * @brief Return the hash of the wrapped object, other return the zero hash of 0 * - * @return barretenberg::fr + * @return bb::fr */ - barretenberg::fr hash() const { return data.has_value() ? data.value().hash() : barretenberg::fr::zero(); } + bb::fr hash() const { return data.has_value() ? data.value().hash() : bb::fr::zero(); } /** * @brief Generate a zero leaf (call the constructor with no arguments) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.hpp index d40b2ea2bc5..be57eb7c907 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.hpp @@ -7,7 +7,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; /** * An NullifierMemoryTree is structured just like a usual merkle tree: @@ -78,7 +78,7 @@ class NullifierMemoryTree : public MemoryTree { fr update_element(fr const& value); - const std::vector& get_hashes() { return hashes_; } + const std::vector& get_hashes() { return hashes_; } const WrappedNullifierLeaf get_leaf(size_t index) { return (index < leaves_.size()) ? leaves_[index] : WrappedNullifierLeaf::zero(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.test.cpp index 1a5b5bfae83..6636641e108 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.test.cpp @@ -1,7 +1,7 @@ #include "nullifier_memory_tree.hpp" #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib::merkle_tree; void print_tree(const size_t depth, std::vector hashes, std::string const& msg) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.cpp index 74f03c575e7..083ae99a7e4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.cpp @@ -13,7 +13,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; template inline bool bit_set(T const& index, size_t i) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.hpp index 5eaf9359dc4..ddb7ef9471d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.hpp @@ -7,7 +7,7 @@ namespace proof_system::plonk { namespace stdlib { namespace merkle_tree { -using namespace barretenberg; +using namespace bb; template class NullifierTree : public MerkleTree { public: diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp index 36a82bdb843..f8d55f3d3ad 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp @@ -5,7 +5,7 @@ #include "barretenberg/numeric/random/engine.hpp" #include "nullifier_memory_tree.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib::merkle_tree; namespace { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/address/address.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/address/address.hpp index 377552e4e39..7525c4f1343 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/address/address.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/address/address.hpp @@ -9,7 +9,7 @@ namespace proof_system::plonk { namespace stdlib { -using barretenberg::fr; +using bb::fr; using numeric::uint256_t; using stdlib::bool_t; using stdlib::cycle_group; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp index 5111ea71a54..86e26fea2d1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp @@ -125,7 +125,7 @@ template class BigFieldBase { typedef proof_system::plonk::stdlib::field_t field_t; typedef proof_system::plonk::stdlib::witness_t witness_t; typedef proof_system::plonk::stdlib::public_witness_t public_witness_t; - typedef proof_system::plonk::stdlib::bigfield bigfield_t; + typedef proof_system::plonk::stdlib::bigfield bigfield_t; public: /** diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp index 3de1bd7342b..6bd83a79eef 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp @@ -18,7 +18,7 @@ template class bigfield { public: typedef T TParams; - typedef barretenberg::field native; + typedef bb::field native; struct Basis { uint512_t modulus; @@ -104,12 +104,11 @@ template class bigfield { const bool can_overflow = false, const size_t maximum_bitlength = 0); - static bigfield from_witness(Builder* ctx, const barretenberg::field& input) + static bigfield from_witness(Builder* ctx, const bb::field& input) { uint256_t input_u256(input); - field_t low(witness_t(ctx, barretenberg::fr(input_u256.slice(0, NUM_LIMB_BITS * 2)))); - field_t hi( - witness_t(ctx, barretenberg::fr(input_u256.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 4)))); + field_t low(witness_t(ctx, bb::fr(input_u256.slice(0, NUM_LIMB_BITS * 2)))); + field_t hi(witness_t(ctx, bb::fr(input_u256.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 4)))); return bigfield(low, hi); } @@ -130,16 +129,15 @@ template class bigfield { static constexpr uint256_t prime_basis_maximum_limb = uint256_t(modulus_u512.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4)); - static constexpr Basis prime_basis{ uint512_t(barretenberg::fr::modulus), barretenberg::fr::modulus.get_msb() + 1 }; + static constexpr Basis prime_basis{ uint512_t(bb::fr::modulus), bb::fr::modulus.get_msb() + 1 }; static constexpr Basis binary_basis{ uint512_t(1) << LOG2_BINARY_MODULUS, LOG2_BINARY_MODULUS }; static constexpr Basis target_basis{ modulus_u512, modulus_u512.get_msb() + 1 }; - static constexpr barretenberg::fr shift_1 = barretenberg::fr(uint256_t(1) << NUM_LIMB_BITS); - static constexpr barretenberg::fr shift_2 = barretenberg::fr(uint256_t(1) << (NUM_LIMB_BITS * 2)); - static constexpr barretenberg::fr shift_3 = barretenberg::fr(uint256_t(1) << (NUM_LIMB_BITS * 3)); - static constexpr barretenberg::fr shift_right_1 = barretenberg::fr(1) / shift_1; - static constexpr barretenberg::fr shift_right_2 = barretenberg::fr(1) / shift_2; - static constexpr barretenberg::fr negative_prime_modulus_mod_binary_basis = - -barretenberg::fr(uint256_t(modulus_u512)); + static constexpr bb::fr shift_1 = bb::fr(uint256_t(1) << NUM_LIMB_BITS); + static constexpr bb::fr shift_2 = bb::fr(uint256_t(1) << (NUM_LIMB_BITS * 2)); + static constexpr bb::fr shift_3 = bb::fr(uint256_t(1) << (NUM_LIMB_BITS * 3)); + static constexpr bb::fr shift_right_1 = bb::fr(1) / shift_1; + static constexpr bb::fr shift_right_2 = bb::fr(1) / shift_2; + static constexpr bb::fr negative_prime_modulus_mod_binary_basis = -bb::fr(uint256_t(modulus_u512)); static constexpr uint512_t negative_prime_modulus = binary_basis.modulus - target_basis.modulus; static constexpr uint256_t neg_modulus_limbs_u256[4]{ uint256_t(negative_prime_modulus.slice(0, NUM_LIMB_BITS).lo), @@ -147,11 +145,11 @@ template class bigfield { uint256_t(negative_prime_modulus.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3).lo), uint256_t(negative_prime_modulus.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4).lo), }; - static constexpr barretenberg::fr neg_modulus_limbs[4]{ - barretenberg::fr(negative_prime_modulus.slice(0, NUM_LIMB_BITS).lo), - barretenberg::fr(negative_prime_modulus.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2).lo), - barretenberg::fr(negative_prime_modulus.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3).lo), - barretenberg::fr(negative_prime_modulus.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4).lo), + static constexpr bb::fr neg_modulus_limbs[4]{ + bb::fr(negative_prime_modulus.slice(0, NUM_LIMB_BITS).lo), + bb::fr(negative_prime_modulus.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2).lo), + bb::fr(negative_prime_modulus.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3).lo), + bb::fr(negative_prime_modulus.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4).lo), }; byte_array to_byte_array() const @@ -286,12 +284,10 @@ template class bigfield { auto msb = multiple_of_modulus.get_msb(); bigfield result(nullptr, uint256_t(0)); - result.binary_basis_limbs[0] = Limb(barretenberg::fr(multiple_of_modulus.slice(0, NUM_LIMB_BITS).lo)); - result.binary_basis_limbs[1] = - Limb(barretenberg::fr(multiple_of_modulus.slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS).lo)); - result.binary_basis_limbs[2] = - Limb(barretenberg::fr(multiple_of_modulus.slice(2 * NUM_LIMB_BITS, 3 * NUM_LIMB_BITS).lo)); - result.binary_basis_limbs[3] = Limb(barretenberg::fr(multiple_of_modulus.slice(3 * NUM_LIMB_BITS, msb + 1).lo)); + result.binary_basis_limbs[0] = Limb(bb::fr(multiple_of_modulus.slice(0, NUM_LIMB_BITS).lo)); + result.binary_basis_limbs[1] = Limb(bb::fr(multiple_of_modulus.slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS).lo)); + result.binary_basis_limbs[2] = Limb(bb::fr(multiple_of_modulus.slice(2 * NUM_LIMB_BITS, 3 * NUM_LIMB_BITS).lo)); + result.binary_basis_limbs[3] = Limb(bb::fr(multiple_of_modulus.slice(3 * NUM_LIMB_BITS, msb + 1).lo)); result.prime_basis_limb = field_t((multiple_of_modulus % uint512_t(field_t::modulus)).lo); return result; } @@ -430,8 +426,7 @@ template class bigfield { static constexpr uint64_t MAX_ADDITION_LOG = 10; // the rationale of the expression is we should not overflow Fr when applying any bigfield operation (e.g. *) and // starting with this max limb size - static constexpr uint64_t MAX_UNREDUCED_LIMB_SIZE = - (barretenberg::fr::modulus.get_msb() + 1) / 2 - MAX_ADDITION_LOG; + static constexpr uint64_t MAX_UNREDUCED_LIMB_SIZE = (bb::fr::modulus.get_msb() + 1) / 2 - MAX_ADDITION_LOG; static constexpr uint256_t get_maximum_unreduced_limb_value() { return uint256_t(1) << MAX_UNREDUCED_LIMB_SIZE; } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp index 8637ccbff91..9cc10d289d6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp @@ -19,7 +19,7 @@ #include namespace test_stdlib_bigfield { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; /* A note regarding Plookup: @@ -828,18 +828,18 @@ template class stdlib_bigfield : public testing::Test { static void test_conditional_select_regression() { auto builder = Builder(); - barretenberg::fq a(0); - barretenberg::fq b(1); + bb::fq a(0); + bb::fq b(1); fq_ct a_ct(&builder, a); fq_ct b_ct(&builder, b); fq_ct selected = a_ct.conditional_select(b_ct, typename bn254::bool_ct(&builder, true)); - EXPECT_EQ(barretenberg::fq((selected.get_value() % uint512_t(barretenberg::fq::modulus)).lo), b); + EXPECT_EQ(bb::fq((selected.get_value() % uint512_t(bb::fq::modulus)).lo), b); } static void test_division_context() { auto builder = Builder(); - barretenberg::fq a(1); + bb::fq a(1); fq_ct a_ct(&builder, a); fq_ct ret = fq_ct::div_check_denominator_nonzero({}, a_ct); EXPECT_NE(ret.get_context(), nullptr); @@ -940,19 +940,19 @@ TYPED_TEST(stdlib_bigfield, division_context) // size_t num_repetitions = 1; // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; -// fq_ct a(witness_ct(&builder, barretenberg::fr(uint256_t(inputs[0]).slice(0, +// fq_ct a(witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), // witness_ct( // &builder, -// barretenberg::fr(uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, +// bb::fr(uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, // fq_ct::NUM_LIMB_BITS * 4)))); // fq_ct b1(&builder, uint256_t(inputs[1])); // fq_ct b2(&builder, uint256_t(inputs[2])); // fq_ct c = a / (b1 - b2); -// // uint256_t modulus{ barretenberg::Bn254FqParams::modulus_0, -// // barretenberg::Bn254FqParams::modulus_1, -// // barretenberg::Bn254FqParams::modulus_2, -// // barretenberg::Bn254FqParams::modulus_3 }; +// // uint256_t modulus{ bb::Bn254FqParams::modulus_0, +// // bb::Bn254FqParams::modulus_1, +// // bb::Bn254FqParams::modulus_2, +// // bb::Bn254FqParams::modulus_3 }; // fq expected = (inputs[0] / (inputs[1] - inputs[2])); // std::cerr << "denominator = " << inputs[1] - inputs[2] << std::endl; @@ -984,15 +984,15 @@ TYPED_TEST(stdlib_bigfield, division_context) // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; // fq_ct a( -// witness_ct(&builder, barretenberg::fr(uint256_t(inputs[0]).slice(0, +// witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// barretenberg::fr( +// bb::fr( // uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // fq_ct b( -// witness_ct(&builder, barretenberg::fr(uint256_t(inputs[1]).slice(0, +// witness_ct(&builder, bb::fr(uint256_t(inputs[1]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// barretenberg::fr( +// bb::fr( // uint256_t(inputs[1]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // std::cerr << "starting mul" << std::endl; @@ -1031,9 +1031,9 @@ TYPED_TEST(stdlib_bigfield, division_context) // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; // fq_ct a( -// witness_ct(&builder, barretenberg::fr(uint256_t(inputs[0]).slice(0, +// witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// barretenberg::fr( +// bb::fr( // uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // uint64_t before = builder.get_num_gates(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp index 5d78358dfe3..d9f61931e2e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp @@ -9,7 +9,7 @@ #include "../bit_array/bit_array.hpp" #include "../field/field.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { @@ -17,20 +17,17 @@ namespace stdlib { template bigfield::bigfield(Builder* parent_context) : context(parent_context) - , binary_basis_limbs{ Limb(barretenberg::fr(0)), - Limb(barretenberg::fr(0)), - Limb(barretenberg::fr(0)), - Limb(barretenberg::fr(0)) } + , binary_basis_limbs{ Limb(bb::fr(0)), Limb(bb::fr(0)), Limb(bb::fr(0)), Limb(bb::fr(0)) } , prime_basis_limb(context, 0) {} template bigfield::bigfield(Builder* parent_context, const uint256_t& value) : context(parent_context) - , binary_basis_limbs{ Limb(barretenberg::fr(value.slice(0, NUM_LIMB_BITS))), - Limb(barretenberg::fr(value.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2))), - Limb(barretenberg::fr(value.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3))), - Limb(barretenberg::fr(value.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4))) } + , binary_basis_limbs{ Limb(bb::fr(value.slice(0, NUM_LIMB_BITS))), + Limb(bb::fr(value.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2))), + Limb(bb::fr(value.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3))), + Limb(bb::fr(value.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4))) } , prime_basis_limb(context, value) { ASSERT(value < modulus); @@ -87,8 +84,8 @@ bigfield::bigfield(const field_t& low_bits_in, } 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)); + limb_0 = field_t(context, bb::fr(slice_0)); + limb_1 = field_t(context, bb::fr(slice_1)); } // If we wish to continue working with this element with lazy reductions - i.e. not moding out again after each @@ -123,8 +120,8 @@ bigfield::bigfield(const field_t& low_bits_in, } 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)); + limb_2 = field_t(context, bb::fr(slice_2)); + limb_3 = field_t(context, bb::fr(slice_3)); } binary_basis_limbs[0] = Limb(limb_0, DEFAULT_MAXIMUM_LIMB); binary_basis_limbs[1] = Limb(limb_1, DEFAULT_MAXIMUM_LIMB); @@ -192,10 +189,10 @@ bigfield bigfield::create_from_u512_as_witness(Builder* field_t limb_2(ctx); field_t limb_3(ctx); field_t prime_limb(ctx); - limb_0.witness_index = ctx->add_variable(barretenberg::fr(limbs[0])); - limb_1.witness_index = ctx->add_variable(barretenberg::fr(limbs[1])); - limb_2.witness_index = ctx->add_variable(barretenberg::fr(limbs[2])); - limb_3.witness_index = ctx->add_variable(barretenberg::fr(limbs[3])); + limb_0.witness_index = ctx->add_variable(bb::fr(limbs[0])); + limb_1.witness_index = ctx->add_variable(bb::fr(limbs[1])); + limb_2.witness_index = ctx->add_variable(bb::fr(limbs[2])); + limb_3.witness_index = ctx->add_variable(bb::fr(limbs[3])); prime_limb.witness_index = ctx->add_variable(limb_0.get_value() + limb_1.get_value() * shift_1 + limb_2.get_value() * shift_2 + limb_3.get_value() * shift_3); // evaluate prime basis limb with addition gate that taps into the 4th wire in the next gate @@ -401,34 +398,34 @@ bigfield bigfield::operator+(const bigfield& other) cons limbconst = limbconst || other.prime_basis_limb.is_constant(); limbconst = limbconst || (prime_basis_limb.witness_index == other.prime_basis_limb.witness_index); if (!limbconst) { - std::pair x0{ binary_basis_limbs[0].element.witness_index, - binary_basis_limbs[0].element.multiplicative_constant }; - std::pair x1{ binary_basis_limbs[1].element.witness_index, - binary_basis_limbs[1].element.multiplicative_constant }; - std::pair x2{ binary_basis_limbs[2].element.witness_index, - binary_basis_limbs[2].element.multiplicative_constant }; - std::pair x3{ binary_basis_limbs[3].element.witness_index, - binary_basis_limbs[3].element.multiplicative_constant }; - std::pair y0{ other.binary_basis_limbs[0].element.witness_index, - other.binary_basis_limbs[0].element.multiplicative_constant }; - std::pair y1{ other.binary_basis_limbs[1].element.witness_index, - other.binary_basis_limbs[1].element.multiplicative_constant }; - std::pair y2{ other.binary_basis_limbs[2].element.witness_index, - other.binary_basis_limbs[2].element.multiplicative_constant }; - std::pair y3{ other.binary_basis_limbs[3].element.witness_index, - other.binary_basis_limbs[3].element.multiplicative_constant }; - barretenberg::fr c0(binary_basis_limbs[0].element.additive_constant + - other.binary_basis_limbs[0].element.additive_constant); - barretenberg::fr c1(binary_basis_limbs[1].element.additive_constant + - other.binary_basis_limbs[1].element.additive_constant); - barretenberg::fr c2(binary_basis_limbs[2].element.additive_constant + - other.binary_basis_limbs[2].element.additive_constant); - barretenberg::fr c3(binary_basis_limbs[3].element.additive_constant + - other.binary_basis_limbs[3].element.additive_constant); + std::pair x0{ binary_basis_limbs[0].element.witness_index, + binary_basis_limbs[0].element.multiplicative_constant }; + std::pair x1{ binary_basis_limbs[1].element.witness_index, + binary_basis_limbs[1].element.multiplicative_constant }; + std::pair x2{ binary_basis_limbs[2].element.witness_index, + binary_basis_limbs[2].element.multiplicative_constant }; + std::pair x3{ binary_basis_limbs[3].element.witness_index, + binary_basis_limbs[3].element.multiplicative_constant }; + std::pair y0{ other.binary_basis_limbs[0].element.witness_index, + other.binary_basis_limbs[0].element.multiplicative_constant }; + std::pair y1{ other.binary_basis_limbs[1].element.witness_index, + other.binary_basis_limbs[1].element.multiplicative_constant }; + std::pair y2{ other.binary_basis_limbs[2].element.witness_index, + other.binary_basis_limbs[2].element.multiplicative_constant }; + std::pair y3{ other.binary_basis_limbs[3].element.witness_index, + other.binary_basis_limbs[3].element.multiplicative_constant }; + bb::fr c0(binary_basis_limbs[0].element.additive_constant + + other.binary_basis_limbs[0].element.additive_constant); + bb::fr c1(binary_basis_limbs[1].element.additive_constant + + other.binary_basis_limbs[1].element.additive_constant); + bb::fr c2(binary_basis_limbs[2].element.additive_constant + + other.binary_basis_limbs[2].element.additive_constant); + bb::fr c3(binary_basis_limbs[3].element.additive_constant + + other.binary_basis_limbs[3].element.additive_constant); uint32_t xp(prime_basis_limb.witness_index); uint32_t yp(other.prime_basis_limb.witness_index); - barretenberg::fr cp(prime_basis_limb.additive_constant + other.prime_basis_limb.additive_constant); + bb::fr cp(prime_basis_limb.additive_constant + other.prime_basis_limb.additive_constant); const auto output_witnesses = ctx->evaluate_non_native_field_addition( { x0, y0, c0 }, { x1, y1, c1 }, { x2, y2, c2 }, { x3, y3, c3 }, { xp, yp, cp }); @@ -590,10 +587,10 @@ bigfield bigfield::operator-(const bigfield& other) cons /** * Compute the binary basis limbs of our result **/ - result.binary_basis_limbs[0].element = binary_basis_limbs[0].element + barretenberg::fr(to_add_0); - result.binary_basis_limbs[1].element = binary_basis_limbs[1].element + barretenberg::fr(to_add_1); - result.binary_basis_limbs[2].element = binary_basis_limbs[2].element + barretenberg::fr(to_add_2); - result.binary_basis_limbs[3].element = binary_basis_limbs[3].element + barretenberg::fr(to_add_3); + result.binary_basis_limbs[0].element = binary_basis_limbs[0].element + bb::fr(to_add_0); + result.binary_basis_limbs[1].element = binary_basis_limbs[1].element + bb::fr(to_add_1); + result.binary_basis_limbs[2].element = binary_basis_limbs[2].element + bb::fr(to_add_2); + result.binary_basis_limbs[3].element = binary_basis_limbs[3].element + bb::fr(to_add_3); if constexpr (HasPlookup) { if (prime_basis_limb.multiplicative_constant == 1 && other.prime_basis_limb.multiplicative_constant == 1 && @@ -610,36 +607,36 @@ bigfield bigfield::operator-(const bigfield& other) cons limbconst = limbconst || other.prime_basis_limb.is_constant(); limbconst = limbconst || (prime_basis_limb.witness_index == other.prime_basis_limb.witness_index); if (!limbconst) { - std::pair x0{ result.binary_basis_limbs[0].element.witness_index, - binary_basis_limbs[0].element.multiplicative_constant }; - std::pair x1{ result.binary_basis_limbs[1].element.witness_index, - binary_basis_limbs[1].element.multiplicative_constant }; - std::pair x2{ result.binary_basis_limbs[2].element.witness_index, - binary_basis_limbs[2].element.multiplicative_constant }; - std::pair x3{ result.binary_basis_limbs[3].element.witness_index, - binary_basis_limbs[3].element.multiplicative_constant }; - std::pair y0{ other.binary_basis_limbs[0].element.witness_index, - other.binary_basis_limbs[0].element.multiplicative_constant }; - std::pair y1{ other.binary_basis_limbs[1].element.witness_index, - other.binary_basis_limbs[1].element.multiplicative_constant }; - std::pair y2{ other.binary_basis_limbs[2].element.witness_index, - other.binary_basis_limbs[2].element.multiplicative_constant }; - std::pair y3{ other.binary_basis_limbs[3].element.witness_index, - other.binary_basis_limbs[3].element.multiplicative_constant }; - barretenberg::fr c0(result.binary_basis_limbs[0].element.additive_constant - - other.binary_basis_limbs[0].element.additive_constant); - barretenberg::fr c1(result.binary_basis_limbs[1].element.additive_constant - - other.binary_basis_limbs[1].element.additive_constant); - barretenberg::fr c2(result.binary_basis_limbs[2].element.additive_constant - - other.binary_basis_limbs[2].element.additive_constant); - barretenberg::fr c3(result.binary_basis_limbs[3].element.additive_constant - - other.binary_basis_limbs[3].element.additive_constant); + std::pair x0{ result.binary_basis_limbs[0].element.witness_index, + binary_basis_limbs[0].element.multiplicative_constant }; + std::pair x1{ result.binary_basis_limbs[1].element.witness_index, + binary_basis_limbs[1].element.multiplicative_constant }; + std::pair x2{ result.binary_basis_limbs[2].element.witness_index, + binary_basis_limbs[2].element.multiplicative_constant }; + std::pair x3{ result.binary_basis_limbs[3].element.witness_index, + binary_basis_limbs[3].element.multiplicative_constant }; + std::pair y0{ other.binary_basis_limbs[0].element.witness_index, + other.binary_basis_limbs[0].element.multiplicative_constant }; + std::pair y1{ other.binary_basis_limbs[1].element.witness_index, + other.binary_basis_limbs[1].element.multiplicative_constant }; + std::pair y2{ other.binary_basis_limbs[2].element.witness_index, + other.binary_basis_limbs[2].element.multiplicative_constant }; + std::pair y3{ other.binary_basis_limbs[3].element.witness_index, + other.binary_basis_limbs[3].element.multiplicative_constant }; + bb::fr c0(result.binary_basis_limbs[0].element.additive_constant - + other.binary_basis_limbs[0].element.additive_constant); + bb::fr c1(result.binary_basis_limbs[1].element.additive_constant - + other.binary_basis_limbs[1].element.additive_constant); + bb::fr c2(result.binary_basis_limbs[2].element.additive_constant - + other.binary_basis_limbs[2].element.additive_constant); + bb::fr c3(result.binary_basis_limbs[3].element.additive_constant - + other.binary_basis_limbs[3].element.additive_constant); uint32_t xp(prime_basis_limb.witness_index); uint32_t yp(other.prime_basis_limb.witness_index); - barretenberg::fr cp(prime_basis_limb.additive_constant - other.prime_basis_limb.additive_constant); + bb::fr cp(prime_basis_limb.additive_constant - other.prime_basis_limb.additive_constant); uint512_t constant_to_add_mod_p = (constant_to_add) % prime_basis.modulus; - cp += barretenberg::fr(constant_to_add_mod_p.lo); + cp += bb::fr(constant_to_add_mod_p.lo); const auto output_witnesses = ctx->evaluate_non_native_field_subtraction( { x0, y0, c0 }, { x1, y1, c1 }, { x2, y2, c2 }, { x3, y3, c3 }, { xp, yp, cp }); @@ -663,7 +660,7 @@ bigfield bigfield::operator-(const bigfield& other) cons * Compute the prime basis limb of the result **/ uint512_t constant_to_add_mod_p = (constant_to_add) % prime_basis.modulus; - field_t prime_basis_to_add(ctx, barretenberg::fr(constant_to_add_mod_p.lo)); + field_t prime_basis_to_add(ctx, bb::fr(constant_to_add_mod_p.lo)); result.prime_basis_limb = prime_basis_limb + prime_basis_to_add; result.prime_basis_limb -= other.prime_basis_limb; return result; @@ -1479,15 +1476,15 @@ bigfield bigfield::conditional_negate(const bool_t>(predicate).madd(-(binary_basis_limbs[0].element * two) + to_add_0, binary_basis_limbs[0].element); @@ -1510,7 +1507,7 @@ bigfield bigfield::conditional_negate(const bool_t>(predicate).madd(-(prime_basis_limb * two) + prime_basis_to_add, prime_basis_limb); @@ -1853,7 +1850,7 @@ template void bigfield::self_reduce() ++maximum_quotient_bits; } // TODO: implicit assumption here - NUM_LIMB_BITS large enough for all the quotient - uint32_t quotient_limb_index = context->add_variable(barretenberg::fr(quotient_value.lo)); + uint32_t quotient_limb_index = context->add_variable(bb::fr(quotient_value.lo)); field_t quotient_limb = field_t::from_witness_index(context, quotient_limb_index); if constexpr (HasPlookup) { context->decompose_into_default_range(quotient_limb.witness_index, static_cast(maximum_quotient_bits)); @@ -2026,7 +2023,7 @@ void bigfield::unsafe_evaluate_multiply_add(const bigfield& input_le }; field_t remainder_prime_limb = field_t::accumulate(prime_limb_accumulator); - proof_system::non_native_field_witnesses witnesses{ + proof_system::non_native_field_witnesses witnesses{ { left.binary_basis_limbs[0].element.normalize().witness_index, left.binary_basis_limbs[1].element.normalize().witness_index, @@ -2061,7 +2058,7 @@ void bigfield::unsafe_evaluate_multiply_add(const bigfield& input_le // N.B. this method also evaluates the prime field component of the non-native field mul const auto [lo_idx, hi_idx] = ctx->evaluate_non_native_field_multiplication(witnesses, false); - barretenberg::fr neg_prime = -barretenberg::fr(uint256_t(target_basis.modulus)); + bb::fr neg_prime = -bb::fr(uint256_t(target_basis.modulus)); field_t::evaluate_polynomial_identity(left.prime_basis_limb, to_mul.prime_basis_limb, quotient.prime_basis_limb * neg_prime, @@ -2142,9 +2139,9 @@ void bigfield::unsafe_evaluate_multiply_add(const bigfield& input_le carry_hi = carry_hi.add_two(-remainders[i].binary_basis_limbs[2].element * shift_right_2, -remainders[i].binary_basis_limbs[3].element * (shift_1 * shift_right_2)); } - barretenberg::fr neg_prime = -barretenberg::fr(uint256_t(target_basis.modulus)); + bb::fr neg_prime = -bb::fr(uint256_t(target_basis.modulus)); - field_t linear_terms(ctx, barretenberg::fr(0)); + field_t linear_terms(ctx, bb::fr(0)); if (to_add.size() >= 2) { for (size_t i = 0; i < to_add.size(); i += 2) { linear_terms = linear_terms.add_two(to_add[i].prime_basis_limb, to_add[i + 1].prime_basis_limb); @@ -2169,7 +2166,7 @@ void bigfield::unsafe_evaluate_multiply_add(const bigfield& input_le const uint64_t carry_lo_msb = max_lo_bits - (2 * NUM_LIMB_BITS); const uint64_t carry_hi_msb = max_hi_bits - (2 * NUM_LIMB_BITS); - const barretenberg::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); + const bb::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); if ((carry_hi_msb + carry_lo_msb) < field_t::modulus.get_msb()) { field_t carry_combined = carry_lo + (carry_hi * carry_lo_shift); carry_combined = carry_combined.normalize(); @@ -2366,7 +2363,7 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vect } if (i > 0) { - proof_system::non_native_field_witnesses mul_witnesses = { + proof_system::non_native_field_witnesses mul_witnesses = { { left[i].binary_basis_limbs[0].element.normalize().witness_index, left[i].binary_basis_limbs[1].element.normalize().witness_index, @@ -2462,7 +2459,7 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vect }; field_t remainder_prime_limb = field_t::accumulate(prime_limb_accumulator); - proof_system::non_native_field_witnesses witnesses{ + proof_system::non_native_field_witnesses witnesses{ { left[0].binary_basis_limbs[0].element.normalize().witness_index, left[0].binary_basis_limbs[1].element.normalize().witness_index, @@ -2497,7 +2494,7 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vect const auto [lo_1_idx, hi_1_idx] = ctx->evaluate_non_native_field_multiplication(witnesses, false); - barretenberg::fr neg_prime = -barretenberg::fr(uint256_t(target_basis.modulus)); + bb::fr neg_prime = -bb::fr(uint256_t(target_basis.modulus)); field_t::evaluate_polynomial_identity(left[0].prime_basis_limb, right[0].prime_basis_limb, @@ -2668,9 +2665,9 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vect field_t carry_hi_2 = t1 * shift_right_2; field_t carry_hi = carry_hi_0.add_two(carry_hi_1, carry_hi_2); - barretenberg::fr neg_prime = -barretenberg::fr(uint256_t(target_basis.modulus)); + bb::fr neg_prime = -bb::fr(uint256_t(target_basis.modulus)); - field_t linear_terms(ctx, barretenberg::fr(0)); + field_t linear_terms(ctx, bb::fr(0)); linear_terms += -remainder_prime_limb; @@ -2681,7 +2678,7 @@ void bigfield::unsafe_evaluate_multiple_multiply_add(const std::vect const uint64_t carry_lo_msb = max_lo_bits - (2 * NUM_LIMB_BITS); const uint64_t carry_hi_msb = max_hi_bits - (2 * NUM_LIMB_BITS); - const barretenberg::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); + const bb::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); if constexpr (HasPlookup) { carry_lo = carry_lo.normalize(); @@ -2770,8 +2767,8 @@ void bigfield::unsafe_evaluate_square_add(const bigfield& left, ++max_hi_bits; } - field_t half(ctx, barretenberg::fr(2).invert()); - field_t two(ctx, barretenberg::fr(2)); + field_t half(ctx, bb::fr(2).invert()); + field_t two(ctx, bb::fr(2)); field_t b_quotient_0 = (quotient.binary_basis_limbs[1].element * neg_modulus_limbs[0]); field_t b_quotient_1 = (quotient.binary_basis_limbs[0].element * neg_modulus_limbs[1]); @@ -2826,7 +2823,7 @@ void bigfield::unsafe_evaluate_square_add(const bigfield& left, add_element.binary_basis_limbs[3].element * (shift_1 * shift_right_2)); } - barretenberg::fr neg_prime = -barretenberg::fr(uint256_t(target_basis.modulus)); + bb::fr neg_prime = -bb::fr(uint256_t(target_basis.modulus)); field_t linear_terms = -remainder.prime_basis_limb; if (to_add.size() >= 2) { for (size_t i = 0; i < to_add.size() / 2; i += 1) { @@ -2842,7 +2839,7 @@ void bigfield::unsafe_evaluate_square_add(const bigfield& left, const uint64_t carry_lo_msb = max_lo_bits - (2 * NUM_LIMB_BITS); const uint64_t carry_hi_msb = max_hi_bits - (2 * NUM_LIMB_BITS); - const barretenberg::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); + const bb::fr carry_lo_shift(uint256_t(uint256_t(1) << carry_lo_msb)); if constexpr (HasPlookup) { carry_lo = carry_lo.normalize(); carry_hi = carry_hi.normalize(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp index f413ce25523..ba81f2027c1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.hpp @@ -11,10 +11,10 @@ #include "barretenberg/ecc/curves/secp256r1/secp256r1.hpp" // TODO(https://github.com/AztecProtocol/barretenberg/issues/707) If using a a circuit builder with Goblin, which is -// designed to have efficient barretenberg::g1 operations, a developer might accidentally write inefficient circuits +// designed to have efficient bb::g1 operations, a developer might accidentally write inefficient circuits // using biggroup functions that do not use the OpQueue. We use this concept to prevent compilation of such functions. template -concept IsNotGoblinInefficiencyTrap = !(IsGoblinBuilder && std::same_as); +concept IsNotGoblinInefficiencyTrap = !(IsGoblinBuilder && std::same_as); namespace proof_system::plonk::stdlib { @@ -202,14 +202,14 @@ template class element { // template // && the compiler can't perform partial template specialization on member functions of class templates // => our template parameter cannot be a value but must instead by a type - // Our input to `std::enable_if` is a comparison between two types (NativeGroup and barretenberg::g1), which + // Our input to `std::enable_if` is a comparison between two types (NativeGroup and bb::g1), which // resolves to either `true/false`. // If `std::enable_if` resolves to `true`, it resolves to a `typedef` that equals `void` // If `std::enable_if` resolves to `false`, there is no member typedef // We want to take the *type* of the output typedef of `std::enable_if` // i.e. for the bn254 curve, the template param is `typename = void` // for any other curve, there is no template param - template ::value>> + template ::value>> requires(IsNotGoblinBuilder) // TODO(https://github.com/AztecProtocol/barretenberg/issues/707) static element bn254_endo_batch_mul(const std::vector& big_points, const std::vector& big_scalars, @@ -217,7 +217,7 @@ template class element { const std::vector& small_scalars, const size_t max_num_small_bits); - template ::value>> + template ::value>> requires(IsNotGoblinBuilder) // TODO(https://github.com/AztecProtocol/barretenberg/issues/707) static element bn254_endo_batch_mul_with_generator(const std::vector& big_points, const std::vector& big_scalars, @@ -329,8 +329,8 @@ template class element { for (size_t i = 0; i < 16; ++i) { endoP1.element_table[i].y = P1.element_table[15 - i].y; } - uint256_t beta_val = barretenberg::field::cube_root_of_unity(); - Fq beta(barretenberg::fr(beta_val.slice(0, 136)), barretenberg::fr(beta_val.slice(136, 256)), false); + uint256_t beta_val = bb::field::cube_root_of_unity(); + Fq beta(bb::fr(beta_val.slice(0, 136)), bb::fr(beta_val.slice(136, 256)), false); for (size_t i = 0; i < 8; ++i) { endoP1.element_table[i].x = P1.element_table[i].x * beta; endoP1.element_table[15 - i].x = endoP1.element_table[i].x; @@ -424,8 +424,8 @@ template class element { { quad_lookup_table base_table(inputs); quad_lookup_table endo_table; - uint256_t beta_val = barretenberg::field::cube_root_of_unity(); - Fq beta(barretenberg::fr(beta_val.slice(0, 136)), barretenberg::fr(beta_val.slice(136, 256)), false); + uint256_t beta_val = bb::field::cube_root_of_unity(); + Fq beta(bb::fr(beta_val.slice(0, 136)), bb::fr(beta_val.slice(136, 256)), false); if constexpr (HasPlookup) { for (size_t i = 0; i < 8; ++i) { endo_table.element_table[i + 8].x = base_table[7 - i].x * beta; @@ -457,8 +457,8 @@ template class element { { lookup_table_plookup<5> base_table(inputs); lookup_table_plookup<5> endo_table; - uint256_t beta_val = barretenberg::field::cube_root_of_unity(); - Fq beta(barretenberg::fr(beta_val.slice(0, 136)), barretenberg::fr(beta_val.slice(136, 256)), false); + uint256_t beta_val = bb::field::cube_root_of_unity(); + Fq beta(bb::fr(beta_val.slice(0, 136)), bb::fr(beta_val.slice(136, 256)), false); if constexpr (HasPlookup) { for (size_t i = 0; i < 16; ++i) { endo_table.element_table[i + 16].x = base_table[15 - i].x * beta; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_bn254.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_bn254.hpp index 4f4c655e079..75f72b15f19 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_bn254.hpp @@ -60,13 +60,13 @@ element element::bn254_endo_batch_mul_with_generator std::vector>> small_naf_entries; const auto split_into_endomorphism_scalars = [ctx](const Fr& scalar) { - barretenberg::fr k = scalar.get_value(); - barretenberg::fr k1(0); - barretenberg::fr k2(0); - barretenberg::fr::split_into_endomorphism_scalars(k.from_montgomery_form(), k1, k2); + bb::fr k = scalar.get_value(); + bb::fr k1(0); + bb::fr k2(0); + bb::fr::split_into_endomorphism_scalars(k.from_montgomery_form(), k1, k2); Fr scalar_k1 = Fr::from_witness(ctx, k1.to_montgomery_form()); Fr scalar_k2 = Fr::from_witness(ctx, k2.to_montgomery_form()); - barretenberg::fr beta = barretenberg::fr::cube_root_of_unity(); + bb::fr beta = bb::fr::cube_root_of_unity(); scalar.assert_equal(scalar_k1 - scalar_k2 * beta); return std::make_pair((Fr)scalar_k1, (Fr)scalar_k2); }; @@ -166,8 +166,8 @@ element element::bn254_endo_batch_mul_with_generator accumulator = element(out_x, out_y); } - uint256_t beta_val = barretenberg::field::cube_root_of_unity(); - Fq beta(barretenberg::fr(beta_val.slice(0, 136)), barretenberg::fr(beta_val.slice(136, 256)), false); + uint256_t beta_val = bb::field::cube_root_of_unity(); + Fq beta(bb::fr(beta_val.slice(0, 136)), bb::fr(beta_val.slice(136, 256)), false); for (size_t i = 0; i < NUM_BIG_POINTS; ++i) { element skew_point = big_points[i]; @@ -205,7 +205,7 @@ element element::bn254_endo_batch_mul_with_generator } /** - * A batch multiplication method for the BN254 curve. This method is only available if Fr == field_t + * A batch multiplication method for the BN254 curve. This method is only available if Fr == field_t * * big_points : group elements we will multiply by full 254-bit scalar multipliers * big_scalars : 254-bit scalar multipliers. We want to compute (\sum big_scalars[i] * big_points[i]) @@ -251,18 +251,18 @@ element element::bn254_endo_batch_mul(const std::vec * This ensures ALL our scalar multipliers can now be treated as 128-bit scalars, * which halves the number of iterations of our main "double and add" loop! */ - barretenberg::fr lambda = barretenberg::fr::cube_root_of_unity(); - barretenberg::fq beta = barretenberg::fq::cube_root_of_unity(); + bb::fr lambda = bb::fr::cube_root_of_unity(); + bb::fq beta = bb::fq::cube_root_of_unity(); for (size_t i = 0; i < num_big_points; ++i) { Fr scalar = big_scalars[i]; // Q: is it a problem if wraps? get_value is 512 bits - // A: it can't wrap, this method only compiles if the Fr type is a field_t type + // A: it can't wrap, this method only compiles if the Fr type is a field_t type // Split k into short scalars (scalar_k1, scalar_k2) using bn254 endomorphism. - barretenberg::fr k = uint256_t(scalar.get_value()); - barretenberg::fr k1(0); - barretenberg::fr k2(0); - barretenberg::fr::split_into_endomorphism_scalars(k.from_montgomery_form(), k1, k2); + bb::fr k = uint256_t(scalar.get_value()); + bb::fr k1(0); + bb::fr k2(0); + bb::fr::split_into_endomorphism_scalars(k.from_montgomery_form(), k1, k2); Fr scalar_k1 = Fr::from_witness(ctx, k1.to_montgomery_form()); Fr scalar_k2 = Fr::from_witness(ctx, k2.to_montgomery_form()); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_impl.hpp index 95302189a68..c5181c32ba9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_impl.hpp @@ -3,7 +3,7 @@ #include "../bit_array/bit_array.hpp" #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk::stdlib { @@ -56,7 +56,7 @@ element& element::operator=(element&& other) template element element::operator+(const element& other) const { - if constexpr (IsGoblinBuilder && std::same_as) { + if constexpr (IsGoblinBuilder && std::same_as) { // TODO(https://github.com/AztecProtocol/barretenberg/issues/707) Optimize // Current gate count: 6398 std::vector points{ *this, other }; @@ -74,7 +74,7 @@ element element::operator+(const element& other) con template element element::operator-(const element& other) const { - if constexpr (IsGoblinBuilder && std::same_as) { + if constexpr (IsGoblinBuilder && std::same_as) { // TODO(https://github.com/AztecProtocol/barretenberg/issues/707) Optimize std::vector points{ *this, other }; std::vector scalars{ 1, -Fr(1) }; @@ -107,7 +107,7 @@ element element::operator-(const element& other) con template std::array, 2> element::add_sub(const element& other) const { - if constexpr (IsGoblinBuilder && std::same_as) { + if constexpr (IsGoblinBuilder && std::same_as) { return { *this + other, *this - other }; } @@ -622,7 +622,7 @@ element element::batch_mul(const std::vector && std::same_as) { + if constexpr (IsGoblinBuilder && std::same_as) { return goblin_batch_mul(points, scalars); } else { @@ -702,7 +702,7 @@ element element::operator*(const Fr& scalar) const * **/ - if constexpr (IsGoblinBuilder && std::same_as) { + if constexpr (IsGoblinBuilder && std::same_as) { std::vector points{ *this }; std::vector scalars{ scalar }; return goblin_batch_mul(points, scalars); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp index 55bc21b6cbb..ba10e3e9f8d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp @@ -149,10 +149,10 @@ typename element::secp256k1_wnaf_pair element::compu uint256_t k_u256{ k.data[0], k.data[1], k.data[2], k.data[3] }; k_u256 = k_u256 >> stagger; if (is_lo) { - barretenberg::wnaf::fixed_wnaf( + bb::wnaf::fixed_wnaf( &k_u256.data[0], &wnaf_values[0], skew_without_stagger, 0); } else { - barretenberg::wnaf::fixed_wnaf( + bb::wnaf::fixed_wnaf( &k_u256.data[0], &wnaf_values[0], skew_without_stagger, 0); } @@ -267,7 +267,7 @@ typename element::secp256k1_wnaf_pair element::compu } // Accumulate entries, shift by stagger and add the stagger itself field_t sum = field_t::accumulate(accumulator); - sum = sum * field_t(barretenberg::fr(1ULL << stagger)); + sum = sum * field_t(bb::fr(1ULL << stagger)); sum += (stagger_fragment); sum = sum.normalize(); // TODO: improve efficiency by creating a constructor that does NOT require us to range constrain @@ -341,8 +341,7 @@ typename element::secp256k1_wnaf_pair element::compu const auto [khi_reconstructed, khi_out] = compute_single_wnaf(khi, hi_stagger, khi_negative, false); uint256_t minus_lambda_val(-secp256k1::fr::cube_root_of_unity()); - Fr minus_lambda( - barretenberg::fr(minus_lambda_val.slice(0, 136)), barretenberg::fr(minus_lambda_val.slice(136, 256)), false); + Fr minus_lambda(bb::fr(minus_lambda_val.slice(0, 136)), bb::fr(minus_lambda_val.slice(136, 256)), false); Fr reconstructed_scalar = khi_reconstructed.madd(minus_lambda, { klo_reconstructed }); @@ -372,7 +371,7 @@ std::vector> element::compute_wnaf(const Fr& scalar) uint64_t wnaf_values[num_rounds] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf(&scalar_multiplier.data[0], &wnaf_values[0], skew, 0); + bb::wnaf::fixed_wnaf(&scalar_multiplier.data[0], &wnaf_values[0], skew, 0); std::vector> wnaf_entries; for (size_t i = 0; i < num_rounds; ++i) { @@ -463,12 +462,10 @@ std::vector> element::compute_wnaf(const Fr& scalar) } ASSERT((num_rounds - midpoint) * 4 == 136); // If skew == 1 lo_offset = 0, else = 0xf...f - field_t lo_offset = - (-field_t(barretenberg::fr(negative_lo))) - .madd(wnaf_entries[wnaf_entries.size() - 1], field_t(barretenberg::fr(negative_lo))) - .normalize(); - Fr offset = - Fr(lo_offset, field_t(barretenberg::fr(negative_hi)) + wnaf_entries[wnaf_entries.size() - 1], true); + field_t lo_offset = (-field_t(bb::fr(negative_lo))) + .madd(wnaf_entries[wnaf_entries.size() - 1], field_t(bb::fr(negative_lo))) + .normalize(); + Fr offset = Fr(lo_offset, field_t(bb::fr(negative_hi)) + wnaf_entries[wnaf_entries.size() - 1], true); Fr reconstructed = Fr(lo_accumulators, hi_accumulators, true); reconstructed = (reconstructed + reconstructed) - offset; reconstructed.assert_is_in_field(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.hpp index b6932d6b32d..e589a3336c8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.hpp @@ -84,7 +84,7 @@ template class bit_array { for (size_t j = 0; j < end; ++j) { const auto bit = rbits[i * 8 + j]; const uint256_t scaling_factor = uint256_t(1) << (end - j - 1); - accumulator += field_t(bit) * barretenberg::fr(scaling_factor); + accumulator += field_t(bit) * bb::fr(scaling_factor); } values[i] = accumulator; } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp index d31f7dfc45c..02d9fefec2e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp @@ -19,7 +19,7 @@ namespace test_stdlib_bit_array { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.cpp index 359455323ce..271e84521c2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.cpp @@ -1,7 +1,7 @@ #include "bool.hpp" #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace proof_system::plonk { @@ -28,10 +28,10 @@ template bool_t::bool_t(const witness_t& value) : context(value.context) { - ASSERT((value.witness == barretenberg::fr::zero()) || (value.witness == barretenberg::fr::one())); + ASSERT((value.witness == bb::fr::zero()) || (value.witness == bb::fr::one())); witness_index = value.witness_index; context->create_bool_gate(witness_index); - witness_bool = (value.witness == barretenberg::fr::one()); + witness_bool = (value.witness == bb::fr::one()); witness_inverted = false; } @@ -92,9 +92,9 @@ template bool_t& bool_t::operator=(bool_t&& template bool_t& bool_t::operator=(const witness_t& other) { - ASSERT((other.witness == barretenberg::fr::one()) || (other.witness == barretenberg::fr::zero())); + ASSERT((other.witness == bb::fr::one()) || (other.witness == bb::fr::zero())); context = other.context; - witness_bool = (other.witness == barretenberg::fr::zero()) ? false : true; + witness_bool = (other.witness == bb::fr::zero()) ? false : true; witness_index = other.witness_index; witness_inverted = false; context->create_bool_gate(witness_index); @@ -110,7 +110,7 @@ template bool_t bool_t::operator&(const boo ASSERT(result.context || (witness_index == IS_CONSTANT && other.witness_index == IS_CONSTANT)); if (witness_index != IS_CONSTANT && other.witness_index != IS_CONSTANT) { result.witness_bool = left & right; - barretenberg::fr value = result.witness_bool ? barretenberg::fr::one() : barretenberg::fr::zero(); + bb::fr value = result.witness_bool ? bb::fr::one() : bb::fr::zero(); result.witness_index = context->add_variable(value); result.witness_inverted = false; @@ -189,47 +189,47 @@ template bool_t bool_t::operator|(const boo ASSERT(result.context || (witness_index == IS_CONSTANT && other.witness_index == IS_CONSTANT)); result.witness_bool = (witness_bool ^ witness_inverted) | (other.witness_bool ^ other.witness_inverted); - barretenberg::fr value = result.witness_bool ? barretenberg::fr::one() : barretenberg::fr::zero(); + bb::fr value = result.witness_bool ? bb::fr::one() : bb::fr::zero(); result.witness_inverted = false; if ((other.witness_index != IS_CONSTANT) && (witness_index != IS_CONSTANT)) { result.witness_index = context->add_variable(value); // result = A + B - AB, where A,B are the "real" values of the variables. But according to whether // witness_inverted flag is true, we need to invert the input. Hence, we look at four cases, and compute the // relevent coefficients of the selector q_1,q_2,q_m,q_c in each case - barretenberg::fr multiplicative_coefficient; - barretenberg::fr left_coefficient; - barretenberg::fr right_coefficient; - barretenberg::fr constant_coefficient; + bb::fr multiplicative_coefficient; + bb::fr left_coefficient; + bb::fr right_coefficient; + bb::fr constant_coefficient; // a inverted: (1-a) + b - (1-a)b = 1-a+ab // ==> q_1=-1,q_2=0,q_m=1,q_c=1 if (witness_inverted && !other.witness_inverted) { - multiplicative_coefficient = barretenberg::fr::one(); - left_coefficient = barretenberg::fr::neg_one(); - right_coefficient = barretenberg::fr::zero(); - constant_coefficient = barretenberg::fr::one(); + multiplicative_coefficient = bb::fr::one(); + left_coefficient = bb::fr::neg_one(); + right_coefficient = bb::fr::zero(); + constant_coefficient = bb::fr::one(); } // b inverted: a + (1-b) - a(1-b) = 1-b+ab // ==> q_1=0,q_2=-1,q_m=1,q_c=1 else if (!witness_inverted && other.witness_inverted) { - multiplicative_coefficient = barretenberg::fr::one(); - left_coefficient = barretenberg::fr::zero(); - right_coefficient = barretenberg::fr::neg_one(); - constant_coefficient = barretenberg::fr::one(); + multiplicative_coefficient = bb::fr::one(); + left_coefficient = bb::fr::zero(); + right_coefficient = bb::fr::neg_one(); + constant_coefficient = bb::fr::one(); } // Both inverted: (1 - a) + (1 - b) - (1 - a)(1 - b) = 2 - a - b - (1 -a -b +ab) = 1 - ab // ==> q_m=-1,q_1=0,q_2=0,q_c=1 else if (witness_inverted && other.witness_inverted) { - multiplicative_coefficient = barretenberg::fr::neg_one(); - left_coefficient = barretenberg::fr::zero(); - right_coefficient = barretenberg::fr::zero(); - constant_coefficient = barretenberg::fr::one(); + multiplicative_coefficient = bb::fr::neg_one(); + left_coefficient = bb::fr::zero(); + right_coefficient = bb::fr::zero(); + constant_coefficient = bb::fr::one(); } // No inversions: a + b - ab ==> q_m=-1,q_1=1,q_2=1,q_c=0 else { - multiplicative_coefficient = barretenberg::fr::neg_one(); - left_coefficient = barretenberg::fr::one(); - right_coefficient = barretenberg::fr::one(); - constant_coefficient = barretenberg::fr::zero(); + multiplicative_coefficient = bb::fr::neg_one(); + left_coefficient = bb::fr::one(); + right_coefficient = bb::fr::one(); + constant_coefficient = bb::fr::zero(); } context->create_poly_gate({ witness_index, other.witness_index, @@ -237,7 +237,7 @@ template bool_t bool_t::operator|(const boo multiplicative_coefficient, left_coefficient, right_coefficient, - barretenberg::fr::neg_one(), + bb::fr::neg_one(), constant_coefficient }); } else if (witness_index != IS_CONSTANT && other.witness_index == IS_CONSTANT) { if (other.witness_bool ^ other.witness_inverted) { @@ -269,7 +269,7 @@ template bool_t bool_t::operator^(const boo ASSERT(result.context || (witness_index == IS_CONSTANT && other.witness_index == IS_CONSTANT)); result.witness_bool = (witness_bool ^ witness_inverted) ^ (other.witness_bool ^ other.witness_inverted); - barretenberg::fr value = result.witness_bool ? barretenberg::fr::one() : barretenberg::fr::zero(); + bb::fr value = result.witness_bool ? bb::fr::one() : bb::fr::zero(); result.witness_inverted = false; if ((other.witness_index != IS_CONSTANT) && (witness_index != IS_CONSTANT)) { @@ -278,20 +278,20 @@ template bool_t bool_t::operator^(const boo // inv a, norm b: (1 - a) + b - 2(1 - a)b = 1 - a - b + 2ab // norm a, inv b: a + (1 - b) - 2(a)(1 - b) = 1 - a - b + 2ab // inv a, inv b: (1 - a) + (1 - b) - 2(1 - a)(1 - b) = a + b - 2ab - barretenberg::fr multiplicative_coefficient; - barretenberg::fr left_coefficient; - barretenberg::fr right_coefficient; - barretenberg::fr constant_coefficient; + bb::fr multiplicative_coefficient; + bb::fr left_coefficient; + bb::fr right_coefficient; + bb::fr constant_coefficient; if ((witness_inverted && other.witness_inverted) || (!witness_inverted && !other.witness_inverted)) { - multiplicative_coefficient = (barretenberg::fr::neg_one() + barretenberg::fr::neg_one()); - left_coefficient = barretenberg::fr::one(); - right_coefficient = barretenberg::fr::one(); - constant_coefficient = barretenberg::fr::zero(); + multiplicative_coefficient = (bb::fr::neg_one() + bb::fr::neg_one()); + left_coefficient = bb::fr::one(); + right_coefficient = bb::fr::one(); + constant_coefficient = bb::fr::zero(); } else { - multiplicative_coefficient = barretenberg::fr::one() + barretenberg::fr::one(); - left_coefficient = barretenberg::fr::neg_one(); - right_coefficient = barretenberg::fr::neg_one(); - constant_coefficient = barretenberg::fr::one(); + multiplicative_coefficient = bb::fr::one() + bb::fr::one(); + left_coefficient = bb::fr::neg_one(); + right_coefficient = bb::fr::neg_one(); + constant_coefficient = bb::fr::one(); } context->create_poly_gate({ witness_index, other.witness_index, @@ -299,7 +299,7 @@ template bool_t bool_t::operator^(const boo multiplicative_coefficient, left_coefficient, right_coefficient, - barretenberg::fr::neg_one(), + bb::fr::neg_one(), constant_coefficient }); } else if (witness_index != IS_CONSTANT && other.witness_index == IS_CONSTANT) { // witness ^ 1 = !witness @@ -351,24 +351,24 @@ template bool_t bool_t::operator==(const bo } else { bool_t result(context == nullptr ? other.context : context); result.witness_bool = (witness_bool ^ witness_inverted) == (other.witness_bool ^ other.witness_inverted); - barretenberg::fr value = result.witness_bool ? barretenberg::fr::one() : barretenberg::fr::zero(); + bb::fr value = result.witness_bool ? bb::fr::one() : bb::fr::zero(); result.witness_index = context->add_variable(value); // norm a, norm b or both inv: 1 - a - b + 2ab // inv a or inv b = a + b - 2ab - barretenberg::fr multiplicative_coefficient; - barretenberg::fr left_coefficient; - barretenberg::fr right_coefficient; - barretenberg::fr constant_coefficient; + bb::fr multiplicative_coefficient; + bb::fr left_coefficient; + bb::fr right_coefficient; + bb::fr constant_coefficient; if ((witness_inverted && other.witness_inverted) || (!witness_inverted && !other.witness_inverted)) { - multiplicative_coefficient = barretenberg::fr::one() + barretenberg::fr::one(); - left_coefficient = barretenberg::fr::neg_one(); - right_coefficient = barretenberg::fr::neg_one(); - constant_coefficient = barretenberg::fr::one(); + multiplicative_coefficient = bb::fr::one() + bb::fr::one(); + left_coefficient = bb::fr::neg_one(); + right_coefficient = bb::fr::neg_one(); + constant_coefficient = bb::fr::one(); } else { - multiplicative_coefficient = (barretenberg::fr::neg_one() + barretenberg::fr::neg_one()); - left_coefficient = barretenberg::fr::one(); - right_coefficient = barretenberg::fr::one(); - constant_coefficient = barretenberg::fr::zero(); + multiplicative_coefficient = (bb::fr::neg_one() + bb::fr::neg_one()); + left_coefficient = bb::fr::one(); + right_coefficient = bb::fr::one(); + constant_coefficient = bb::fr::zero(); } context->create_poly_gate({ witness_index, other.witness_index, @@ -376,7 +376,7 @@ template bool_t bool_t::operator==(const bo multiplicative_coefficient, left_coefficient, right_coefficient, - barretenberg::fr::neg_one(), + bb::fr::neg_one(), constant_coefficient }); return result; } @@ -526,20 +526,20 @@ template bool_t bool_t::normalize() const return *this; } - barretenberg::fr value = witness_bool ^ witness_inverted ? barretenberg::fr::one() : barretenberg::fr::zero(); + bb::fr value = witness_bool ^ witness_inverted ? bb::fr::one() : bb::fr::zero(); uint32_t new_witness = context->add_variable(value); uint32_t new_value = witness_bool ^ witness_inverted; - barretenberg::fr q_l; - barretenberg::fr q_c; + bb::fr q_l; + bb::fr q_c; - q_l = witness_inverted ? barretenberg::fr::neg_one() : barretenberg::fr::one(); - q_c = witness_inverted ? barretenberg::fr::one() : barretenberg::fr::zero(); + q_l = witness_inverted ? bb::fr::neg_one() : bb::fr::one(); + q_c = witness_inverted ? bb::fr::one() : bb::fr::zero(); - barretenberg::fr q_o = barretenberg::fr::neg_one(); - barretenberg::fr q_m = barretenberg::fr::zero(); - barretenberg::fr q_r = barretenberg::fr::zero(); + bb::fr q_o = bb::fr::neg_one(); + bb::fr q_m = bb::fr::zero(); + bb::fr q_r = bb::fr::zero(); context->create_poly_gate({ witness_index, witness_index, new_witness, q_m, q_l, q_r, q_o, q_c }); witness_index = new_witness; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp index 4a26bd7300e..771226f64eb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp @@ -9,7 +9,7 @@ using bool_ct = stdlib::bool_t; namespace test_stdlib_bool { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { @@ -29,8 +29,8 @@ TYPED_TEST(BoolTest, TestBasicOperations) auto gates_before = builder.get_num_gates(); - bool_ct a = witness_ct(&builder, barretenberg::fr::one()); - bool_ct b = witness_ct(&builder, barretenberg::fr::zero()); + bool_ct a = witness_ct(&builder, bb::fr::one()); + bool_ct b = witness_ct(&builder, bb::fr::zero()); a = a ^ b; // a = 1 EXPECT_EQ(a.get_value(), 1); b = !b; // b = 1 (witness 0) @@ -480,8 +480,8 @@ TYPED_TEST(BoolTest, TestSimpleProof) bool_ct a(&builder); bool_ct b(&builder); - a = witness_ct(&builder, barretenberg::fr::one()); - b = witness_ct(&builder, barretenberg::fr::zero()); + a = witness_ct(&builder, bb::fr::one()); + b = witness_ct(&builder, bb::fr::zero()); // bool_ct c(&builder); a = a ^ b; // a = 1 b = !b; // b = 1 (witness 0) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp index 3e7980c7a43..c767b835aff 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.cpp @@ -4,7 +4,7 @@ #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { @@ -62,7 +62,7 @@ byte_array::byte_array(Builder* parent_context, std::vector co * are used to construct the corresponding uint256_t validator := \sum_{i=0}^{8num_bytes-1} 2^{i}b_{i}, and `validator` * is copy constrained to be equal to `input`. However, more constraints are needed in general. * - * Let r = barretenberg::fr::modulus. For later applications, we want to ensure that the prover must pass the bit + * Let r = bb::fr::modulus. For later applications, we want to ensure that the prover must pass the bit * decomposition of the standard representative of the mod r residue class containing `input`, which is to say that we * want to show `validator` lies in [0, ..., r-1]. By the formula for `validator`, we do not have to worry about it * wrapping the modulus if num_bytes < 32 or, in the default case, if the `input` fits into 31 bytes. @@ -99,18 +99,18 @@ template byte_array::byte_array(const field_t validator(context, 0); field_t shifted_high_limb(context, 0); // will be set to 2^128v_hi if `i` reaches 15. for (size_t i = 0; i < num_bytes; ++i) { - barretenberg::fr byte_val = value.slice((num_bytes - i - 1) * 8, (num_bytes - i) * 8); + bb::fr byte_val = value.slice((num_bytes - i - 1) * 8, (num_bytes - i) * 8); field_t byte = witness_t(context, byte_val); byte.create_range_constraint(8, "byte_array: byte extraction failed."); - barretenberg::fr scaling_factor_value = byte_shift.pow(static_cast(num_bytes - 1 - i)); + bb::fr scaling_factor_value = byte_shift.pow(static_cast(num_bytes - 1 - i)); field_t scaling_factor(context, scaling_factor_value); validator = validator + (scaling_factor * byte); values[i] = byte; @@ -212,11 +212,11 @@ template byte_array& byte_array::operator=( template byte_array::operator field_t() const { const size_t bytes = values.size(); - barretenberg::fr shift(256); - field_t result(context, barretenberg::fr(0)); + bb::fr shift(256); + field_t result(context, bb::fr(0)); for (size_t i = 0; i < values.size(); ++i) { field_t temp(values[i]); - barretenberg::fr scaling_factor_value = shift.pow(static_cast(bytes - 1 - i)); + bb::fr scaling_factor_value = shift.pow(static_cast(bytes - 1 - i)); field_t scaling_factor(values[i].context, scaling_factor_value); result = result + (scaling_factor * temp); } @@ -324,7 +324,7 @@ template void byte_array::set_bit(size_t index_rever const size_t byte_index = index / 8UL; const size_t bit_index = 7UL - (index % 8UL); - field_t scaled_new_bit = field_t(new_bit) * barretenberg::fr(uint256_t(1) << bit_index); + field_t scaled_new_bit = field_t(new_bit) * bb::fr(uint256_t(1) << bit_index); const auto new_value = slice.low.add_two(slice.high, scaled_new_bit).normalize(); values[byte_index] = new_value; } @@ -372,8 +372,8 @@ typename byte_array::byte_slice byte_array::split_byte(const s high.assert_equal(0); } - field_t scaled_high = high * barretenberg::fr(uint256_t(1) << (8ULL - num_high_bits)); - field_t scaled_bit = field_t(bit) * barretenberg::fr(uint256_t(1) << bit_index); + field_t scaled_high = high * bb::fr(uint256_t(1) << (8ULL - num_high_bits)); + field_t scaled_bit = field_t(bit) * bb::fr(uint256_t(1) << bit_index); field_t result = low.add_two(scaled_high, scaled_bit); result.assert_equal(byte); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp index e9ad658d75a..63b3f4f2287 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp @@ -8,7 +8,7 @@ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" namespace test_stdlib_byte_array { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk::stdlib; #define STDLIB_TYPE_ALIASES \ diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp index aba6069c7e0..d17994fc581 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp @@ -16,21 +16,20 @@ class Ultra; } // namespace flavor } // namespace proof_system::honk -namespace barretenberg { +namespace bb { class Bn254FrParams; class Bn254FqParams; template struct alignas(32) field; -} // namespace barretenberg +} // namespace bb namespace arithmetization { template class Ultra; } // namespace arithmetization namespace proof_system { template class StandardCircuitBuilder_; -using StandardCircuitBuilder = StandardCircuitBuilder_>; -using StandardGrumpkinCircuitBuilder = StandardCircuitBuilder_>; +using StandardCircuitBuilder = StandardCircuitBuilder_>; +using StandardGrumpkinCircuitBuilder = StandardCircuitBuilder_>; template class UltraCircuitBuilder_; -using UltraCircuitBuilder = - UltraCircuitBuilder_>>; +using UltraCircuitBuilder = UltraCircuitBuilder_>>; template class GoblinUltraCircuitBuilder_; -using GoblinUltraCircuitBuilder = GoblinUltraCircuitBuilder_>; +using GoblinUltraCircuitBuilder = GoblinUltraCircuitBuilder_>; } // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp index 5dfde40f293..924953a3b43 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp @@ -23,7 +23,7 @@ template struct bn254 { // Note: its useful to have these type names match the native analog exactly so that components that digest a Curve // (e.g. Gemini) can be agnostic as to whether they're operating on native or stdlib types. using ScalarField = field_t; - using BaseField = bigfield; + using BaseField = bigfield; using Group = element; using Element = Group; using AffineElement = Group; @@ -36,7 +36,7 @@ template struct bn254 { using bool_ct = bool_t; using uint32_ct = stdlib::uint32; - using bigfr_ct = bigfield; + using bigfr_ct = bigfield; using g1_bigfr_ct = element; }; // namespace bn254 diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp index c94152d63e3..9f65fb59a22 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp @@ -14,7 +14,7 @@ auto& engine = numeric::random::get_debug_engine(); template void ignore_unused(T&) {} // use to ignore unused variables in lambdas -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; template class stdlib_array : public testing::Test { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.cpp index f02ee3169f9..eca27a46ee8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.cpp @@ -12,8 +12,8 @@ namespace stdlib { template field_t::field_t(Builder* parent_context) : context(parent_context) - , additive_constant(barretenberg::fr::zero()) - , multiplicative_constant(barretenberg::fr::one()) + , additive_constant(bb::fr::zero()) + , multiplicative_constant(bb::fr::one()) , witness_index(IS_CONSTANT) {} @@ -27,11 +27,11 @@ field_t::field_t(const witness_t& value) } template -field_t::field_t(Builder* parent_context, const barretenberg::fr& value) +field_t::field_t(Builder* parent_context, const bb::fr& value) : context(parent_context) { additive_constant = value; - multiplicative_constant = barretenberg::fr::zero(); + multiplicative_constant = bb::fr::zero(); witness_index = IS_CONSTANT; } @@ -39,14 +39,13 @@ template field_t::field_t(const bool_t& oth { context = (other.context == nullptr) ? nullptr : other.context; if (other.witness_index == IS_CONSTANT) { - additive_constant = - (other.witness_bool ^ other.witness_inverted) ? barretenberg::fr::one() : barretenberg::fr::zero(); - multiplicative_constant = barretenberg::fr::one(); + additive_constant = (other.witness_bool ^ other.witness_inverted) ? bb::fr::one() : bb::fr::zero(); + multiplicative_constant = bb::fr::one(); witness_index = IS_CONSTANT; } else { witness_index = other.witness_index; - additive_constant = other.witness_inverted ? barretenberg::fr::one() : barretenberg::fr::zero(); - multiplicative_constant = other.witness_inverted ? barretenberg::fr::neg_one() : barretenberg::fr::one(); + additive_constant = other.witness_inverted ? bb::fr::one() : bb::fr::zero(); + multiplicative_constant = other.witness_inverted ? bb::fr::neg_one() : bb::fr::one(); } } @@ -62,23 +61,22 @@ template field_t::operator bool_t() const { if (witness_index == IS_CONSTANT) { bool_t result(context); - result.witness_bool = (additive_constant == barretenberg::fr::one()); + result.witness_bool = (additive_constant == bb::fr::one()); result.witness_inverted = false; result.witness_index = IS_CONSTANT; return result; } - bool add_constant_check = (additive_constant == barretenberg::fr::zero()); - bool mul_constant_check = (multiplicative_constant == barretenberg::fr::one()); - bool inverted_check = - (additive_constant == barretenberg::fr::one()) && (multiplicative_constant == barretenberg::fr::neg_one()); + bool add_constant_check = (additive_constant == bb::fr::zero()); + bool mul_constant_check = (multiplicative_constant == bb::fr::one()); + bool inverted_check = (additive_constant == bb::fr::one()) && (multiplicative_constant == bb::fr::neg_one()); if ((!add_constant_check || !mul_constant_check) && !inverted_check) { normalize(); } - barretenberg::fr witness = context->get_variable(witness_index); - ASSERT((witness == barretenberg::fr::zero()) || (witness == barretenberg::fr::one())); + bb::fr witness = context->get_variable(witness_index); + ASSERT((witness == bb::fr::zero()) || (witness == bb::fr::one())); bool_t result(context); - result.witness_bool = (witness == barretenberg::fr::one()); + result.witness_bool = (witness == bb::fr::one()); result.witness_inverted = inverted_check; result.witness_index = witness_index; context->create_bool_gate(witness_index); @@ -108,10 +106,10 @@ template field_t field_t::operator+(const f result.multiplicative_constant = other.multiplicative_constant; result.witness_index = other.witness_index; } else { - barretenberg::fr T0; - barretenberg::fr left = ctx->get_variable(witness_index); - barretenberg::fr right = ctx->get_variable(other.witness_index); - barretenberg::fr out; + bb::fr T0; + bb::fr left = ctx->get_variable(witness_index); + bb::fr right = ctx->get_variable(other.witness_index); + bb::fr out; out = left * multiplicative_constant; T0 = right * other.multiplicative_constant; out += T0; @@ -124,7 +122,7 @@ template field_t field_t::operator+(const f result.witness_index, multiplicative_constant, other.multiplicative_constant, - barretenberg::fr::neg_one(), + bb::fr::neg_one(), (additive_constant + other.additive_constant) }); } return result; @@ -205,20 +203,20 @@ template field_t field_t::operator*(const f * Output wire value: result.v (with q_o = -1) */ - barretenberg::fr T0; - barretenberg::fr q_m; - barretenberg::fr q_l; - barretenberg::fr q_r; - barretenberg::fr q_c; + bb::fr T0; + bb::fr q_m; + bb::fr q_l; + bb::fr q_r; + bb::fr q_c; q_c = additive_constant * other.additive_constant; q_r = additive_constant * other.multiplicative_constant; q_l = multiplicative_constant * other.additive_constant; q_m = multiplicative_constant * other.multiplicative_constant; - barretenberg::fr left = context->get_variable(witness_index); - barretenberg::fr right = context->get_variable(other.witness_index); - barretenberg::fr out; + bb::fr left = context->get_variable(witness_index); + bb::fr right = context->get_variable(other.witness_index); + bb::fr out; out = left * right; out *= q_m; @@ -234,7 +232,7 @@ template field_t field_t::operator*(const f .q_m = q_m, .q_l = q_l, .q_r = q_r, - .q_o = barretenberg::fr::neg_one(), + .q_o = bb::fr::neg_one(), .q_c = q_c }); } return result; @@ -253,17 +251,17 @@ template field_t field_t::divide_no_zero_ch field_t result(ctx); ASSERT(ctx || (witness_index == IS_CONSTANT && other.witness_index == IS_CONSTANT)); - barretenberg::fr additive_multiplier = barretenberg::fr::one(); + bb::fr additive_multiplier = bb::fr::one(); if (witness_index == IS_CONSTANT && other.witness_index == IS_CONSTANT) { // both inputs are constant - don't add a gate - if (!(other.additive_constant == barretenberg::fr::zero())) { + if (!(other.additive_constant == bb::fr::zero())) { additive_multiplier = other.additive_constant.invert(); } result.additive_constant = additive_constant * additive_multiplier; } else if (witness_index != IS_CONSTANT && other.witness_index == IS_CONSTANT) { // one input is constant - don't add a gate, but update scaling factors - if (!(other.additive_constant == barretenberg::fr::zero())) { + if (!(other.additive_constant == bb::fr::zero())) { additive_multiplier = other.additive_constant.invert(); } result.additive_constant = additive_constant * additive_multiplier; @@ -276,10 +274,10 @@ template field_t field_t::divide_no_zero_ch result.multiplicative_constant = 1; result.witness_index = IS_CONSTANT; } else { - barretenberg::fr q_m = other.multiplicative_constant; - barretenberg::fr q_l = other.additive_constant; - barretenberg::fr q_c = -get_value(); - barretenberg::fr out_value = get_value() / other.get_value(); + bb::fr q_m = other.multiplicative_constant; + bb::fr q_l = other.additive_constant; + bb::fr q_c = -get_value(); + bb::fr out_value = get_value() / other.get_value(); result.witness_index = ctx->add_variable(out_value); ctx->create_poly_gate({ .a = result.witness_index, .b = other.witness_index, @@ -292,17 +290,17 @@ template field_t field_t::divide_no_zero_ch } } else { // TODO SHOULD WE CARE ABOUT IF THE DIVISOR IS ZERO? - barretenberg::fr left = ctx->get_variable(witness_index); - barretenberg::fr right = ctx->get_variable(other.witness_index); - barretenberg::fr out; + bb::fr left = ctx->get_variable(witness_index); + bb::fr right = ctx->get_variable(other.witness_index); + bb::fr out; // even if LHS is constant, if divisor is not constant we need a gate to compute the inverse - // barretenberg::fr witness_multiplier = other.witness.invert(); + // bb::fr witness_multiplier = other.witness.invert(); // m1.x1 + a1 / (m2.x2 + a2) = x3 - barretenberg::fr T0; + bb::fr T0; T0 = multiplicative_constant * left; T0 += additive_constant; - barretenberg::fr T1; + bb::fr T1; T1 = other.multiplicative_constant * right; T1 += other.additive_constant; @@ -320,11 +318,11 @@ template field_t field_t::divide_no_zero_ch // qr = 0 // qo = -m1 // qc = -a1 - barretenberg::fr q_m = other.multiplicative_constant; - barretenberg::fr q_l = other.additive_constant; - barretenberg::fr q_r = barretenberg::fr::zero(); - barretenberg::fr q_o = -multiplicative_constant; - barretenberg::fr q_c = -additive_constant; + bb::fr q_m = other.multiplicative_constant; + bb::fr q_l = other.additive_constant; + bb::fr q_r = bb::fr::zero(); + bb::fr q_o = -multiplicative_constant; + bb::fr q_c = -additive_constant; ctx->create_poly_gate({ .a = result.witness_index, .b = other.witness_index, @@ -406,22 +404,20 @@ template field_t field_t::madd(const field_ // [a.add * b.add + c.add] // = a.v * b.v * [ q_m ] + a.v * [ q_1 ] + b.v * [ q_2 ] + c.v * [ q_3 ] + [ q_c ] - barretenberg::fr q_m = multiplicative_constant * to_mul.multiplicative_constant; - barretenberg::fr q_1 = multiplicative_constant * to_mul.additive_constant; - barretenberg::fr q_2 = to_mul.multiplicative_constant * additive_constant; - barretenberg::fr q_3 = to_add.multiplicative_constant; - barretenberg::fr q_c = additive_constant * to_mul.additive_constant + to_add.additive_constant; + bb::fr q_m = multiplicative_constant * to_mul.multiplicative_constant; + bb::fr q_1 = multiplicative_constant * to_mul.additive_constant; + bb::fr q_2 = to_mul.multiplicative_constant * additive_constant; + bb::fr q_3 = to_add.multiplicative_constant; + bb::fr q_c = additive_constant * to_mul.additive_constant + to_add.additive_constant; // Note: the value of a constant field_t is wholly tracked by the field_t's `additive_constant` member, which is // accounted for in the above-calculated selectors (`q_`'s). Therefore no witness (`variables[witness_index]`) // exists for constants, and so the field_t's corresponding wire value is set to `0` in the gate equation. - barretenberg::fr a = witness_index == IS_CONSTANT ? barretenberg::fr(0) : ctx->get_variable(witness_index); - barretenberg::fr b = - to_mul.witness_index == IS_CONSTANT ? barretenberg::fr(0) : ctx->get_variable(to_mul.witness_index); - barretenberg::fr c = - to_add.witness_index == IS_CONSTANT ? barretenberg::fr(0) : ctx->get_variable(to_add.witness_index); + bb::fr a = witness_index == IS_CONSTANT ? bb::fr(0) : ctx->get_variable(witness_index); + bb::fr b = to_mul.witness_index == IS_CONSTANT ? bb::fr(0) : ctx->get_variable(to_mul.witness_index); + bb::fr c = to_add.witness_index == IS_CONSTANT ? bb::fr(0) : ctx->get_variable(to_add.witness_index); - barretenberg::fr out = a * b * q_m + a * q_1 + b * q_2 + c * q_3 + q_c; + bb::fr out = a * b * q_m + a * q_1 + b * q_2 + c * q_3 + q_c; field_t result(ctx); result.witness_index = ctx->add_variable(out); @@ -434,7 +430,7 @@ template field_t field_t::madd(const field_ .a_scaling = q_1, .b_scaling = q_2, .c_scaling = q_3, - .d_scaling = -barretenberg::fr(1), + .d_scaling = -bb::fr(1), .const_scaling = q_c, }); return result; @@ -448,18 +444,16 @@ template field_t field_t::add_two(const fie (witness_index == IS_CONSTANT)) { return ((*this) + add_a + add_b).normalize(); } - barretenberg::fr q_1 = multiplicative_constant; - barretenberg::fr q_2 = add_a.multiplicative_constant; - barretenberg::fr q_3 = add_b.multiplicative_constant; - barretenberg::fr q_c = additive_constant + add_a.additive_constant + add_b.additive_constant; + bb::fr q_1 = multiplicative_constant; + bb::fr q_2 = add_a.multiplicative_constant; + bb::fr q_3 = add_b.multiplicative_constant; + bb::fr q_c = additive_constant + add_a.additive_constant + add_b.additive_constant; - barretenberg::fr a = witness_index == IS_CONSTANT ? barretenberg::fr(0) : ctx->get_variable(witness_index); - barretenberg::fr b = - add_a.witness_index == IS_CONSTANT ? barretenberg::fr(0) : ctx->get_variable(add_a.witness_index); - barretenberg::fr c = - add_b.witness_index == IS_CONSTANT ? barretenberg::fr(0) : ctx->get_variable(add_b.witness_index); + bb::fr a = witness_index == IS_CONSTANT ? bb::fr(0) : ctx->get_variable(witness_index); + bb::fr b = add_a.witness_index == IS_CONSTANT ? bb::fr(0) : ctx->get_variable(add_a.witness_index); + bb::fr c = add_b.witness_index == IS_CONSTANT ? bb::fr(0) : ctx->get_variable(add_b.witness_index); - barretenberg::fr out = a * q_1 + b * q_2 + c * q_3 + q_c; + bb::fr out = a * q_1 + b * q_2 + c * q_3 + q_c; field_t result(ctx); result.witness_index = ctx->add_variable(out); @@ -469,11 +463,11 @@ template field_t field_t::add_two(const fie .b = add_a.witness_index == IS_CONSTANT ? ctx->zero_idx : add_a.witness_index, .c = add_b.witness_index == IS_CONSTANT ? ctx->zero_idx : add_b.witness_index, .d = result.witness_index, - .mul_scaling = barretenberg::fr(0), + .mul_scaling = bb::fr(0), .a_scaling = q_1, .b_scaling = q_2, .c_scaling = q_3, - .d_scaling = -barretenberg::fr(1), + .d_scaling = -bb::fr(1), .const_scaling = q_c, }); return result; @@ -482,7 +476,7 @@ template field_t field_t::add_two(const fie template field_t field_t::normalize() const { if (witness_index == IS_CONSTANT || - ((multiplicative_constant == barretenberg::fr::one()) && (additive_constant == barretenberg::fr::zero()))) { + ((multiplicative_constant == bb::fr::one()) && (additive_constant == bb::fr::zero()))) { return *this; } @@ -491,14 +485,14 @@ template field_t field_t::normalize() const // We need a new gate to enforce that the `result` was correctly calculated from `this`. field_t result(context); - barretenberg::fr value = context->get_variable(witness_index); - barretenberg::fr out; + bb::fr value = context->get_variable(witness_index); + bb::fr out; out = value * multiplicative_constant; out += additive_constant; result.witness_index = context->add_variable(out); - result.additive_constant = barretenberg::fr::zero(); - result.multiplicative_constant = barretenberg::fr::one(); + result.additive_constant = bb::fr::zero(); + result.multiplicative_constant = bb::fr::one(); // Aim of new gate: this.v * this.mul + this.add == result.v // <=> this.v * [this.mul] + result.v * [ -1] + [this.add] == 0 @@ -510,19 +504,19 @@ template field_t field_t::normalize() const .c = result.witness_index, .a_scaling = multiplicative_constant, .b_scaling = 0, - .c_scaling = barretenberg::fr::neg_one(), + .c_scaling = bb::fr::neg_one(), .const_scaling = additive_constant }); return result; } template void field_t::assert_is_zero(std::string const& msg) const { - if (get_value() != barretenberg::fr(0)) { + if (get_value() != bb::fr(0)) { context->failure(msg); } if (witness_index == IS_CONSTANT) { - ASSERT(additive_constant == barretenberg::fr(0)); + ASSERT(additive_constant == bb::fr(0)); return; } @@ -537,23 +531,23 @@ template void field_t::assert_is_zero(std::string co .a = witness_index, .b = ctx->zero_idx, .c = ctx->zero_idx, - .q_m = barretenberg::fr(0), + .q_m = bb::fr(0), .q_l = multiplicative_constant, - .q_r = barretenberg::fr(0), - .q_o = barretenberg::fr(0), + .q_r = bb::fr(0), + .q_o = bb::fr(0), .q_c = additive_constant, }); } template void field_t::assert_is_not_zero(std::string const& msg) const { - if (get_value() == barretenberg::fr(0)) { + if (get_value() == bb::fr(0)) { context->failure(msg); // We don't return; we continue with the function, for debugging purposes. } if (witness_index == IS_CONSTANT) { - ASSERT(additive_constant != barretenberg::fr(0)); + ASSERT(additive_constant != bb::fr(0)); return; } @@ -562,7 +556,7 @@ template void field_t::assert_is_not_zero(std::strin ctx->failure(msg); } - barretenberg::fr inverse_value = (get_value() == 0) ? 0 : get_value().invert(); + bb::fr inverse_value = (get_value() == 0) ? 0 : get_value().invert(); field_t inverse(witness_t(ctx, inverse_value)); @@ -578,17 +572,17 @@ template void field_t::assert_is_not_zero(std::strin .b = inverse.witness_index, // inverse .c = ctx->zero_idx, // no output .q_m = multiplicative_constant, // a * b * mul_const - .q_l = barretenberg::fr(0), // a * 0 + .q_l = bb::fr(0), // a * 0 .q_r = additive_constant, // b * mul_const - .q_o = barretenberg::fr(0), // c * 0 - .q_c = barretenberg::fr(-1), // -1 + .q_o = bb::fr(0), // c * 0 + .q_c = bb::fr(-1), // -1 }); } template bool_t field_t::is_zero() const { if (witness_index == IS_CONSTANT) { - return bool_t(context, (get_value() == barretenberg::fr::zero())); + return bool_t(context, (get_value() == bb::fr::zero())); } // To check whether a field element, k, is zero, we use the fact that, if k > 0, @@ -605,21 +599,21 @@ template bool_t field_t::is_zero() const // This way, if (k * k') = 0, we know that k = 0. // The second check is: (is_zero * k') - is_zero = 0 field_t k = normalize(); - bool_t is_zero = witness_t(context, (k.get_value() == barretenberg::fr::zero())); + bool_t is_zero = witness_t(context, (k.get_value() == bb::fr::zero())); field_t k_inverse; if (is_zero.get_value()) { - k_inverse = witness_t(context, barretenberg::fr::one()); + k_inverse = witness_t(context, bb::fr::one()); } else { - barretenberg::fr k_inverse_value = k.get_value().invert(); + bb::fr k_inverse_value = k.get_value().invert(); k_inverse = witness_t(context, k_inverse_value); } // k * k_inverse + is_zero - 1 = 0 - barretenberg::fr q_m = barretenberg::fr::one(); - barretenberg::fr q_l = barretenberg::fr::zero(); - barretenberg::fr q_r = barretenberg::fr::zero(); - barretenberg::fr q_o = barretenberg::fr::one(); - barretenberg::fr q_c = barretenberg::fr::neg_one(); + bb::fr q_m = bb::fr::one(); + bb::fr q_l = bb::fr::zero(); + bb::fr q_r = bb::fr::zero(); + bb::fr q_o = bb::fr::one(); + bb::fr q_c = bb::fr::neg_one(); context->create_poly_gate({ .a = k.witness_index, .b = k_inverse.witness_index, @@ -631,8 +625,8 @@ template bool_t field_t::is_zero() const .q_c = q_c }); // is_zero * k_inverse - is_zero = 0 - q_o = barretenberg::fr::neg_one(); - q_c = barretenberg::fr::zero(); + q_o = bb::fr::neg_one(); + q_c = bb::fr::zero(); context->create_poly_gate({ .a = is_zero.witness_index, .b = k_inverse.witness_index, @@ -645,7 +639,7 @@ template bool_t field_t::is_zero() const return is_zero; } -template barretenberg::fr field_t::get_value() const +template bb::fr field_t::get_value() const { if (witness_index != IS_CONSTANT) { ASSERT(context != nullptr); @@ -664,11 +658,11 @@ template bool_t field_t::operator==(const f return (get_value() == other.get_value()); } - barretenberg::fr fa = get_value(); - barretenberg::fr fb = other.get_value(); - barretenberg::fr fd = fa - fb; + bb::fr fa = get_value(); + bb::fr fb = other.get_value(); + bb::fr fd = fa - fb; bool is_equal = (fa == fb); - barretenberg::fr fc = is_equal ? barretenberg::fr::one() : fd.invert(); + bb::fr fc = is_equal ? bb::fr::one() : fd.invert(); bool_t result(witness_t(ctx, is_equal)); field_t r(result); @@ -874,11 +868,11 @@ void field_t::evaluate_linear_identity(const field_t& a, const field_t& } // validate that a + b + c + d = 0 - barretenberg::fr q_1 = a.multiplicative_constant; - barretenberg::fr q_2 = b.multiplicative_constant; - barretenberg::fr q_3 = c.multiplicative_constant; - barretenberg::fr q_4 = d.multiplicative_constant; - barretenberg::fr q_c = a.additive_constant + b.additive_constant + c.additive_constant + d.additive_constant; + bb::fr q_1 = a.multiplicative_constant; + bb::fr q_2 = b.multiplicative_constant; + bb::fr q_3 = c.multiplicative_constant; + bb::fr q_4 = d.multiplicative_constant; + bb::fr q_c = a.additive_constant + b.additive_constant + c.additive_constant + d.additive_constant; ctx->create_big_add_gate({ a.witness_index == IS_CONSTANT ? ctx->zero_idx : a.witness_index, @@ -909,12 +903,12 @@ void field_t::evaluate_polynomial_identity(const field_t& a, } // validate that a * b + c + d = 0 - barretenberg::fr q_m = a.multiplicative_constant * b.multiplicative_constant; - barretenberg::fr q_1 = a.multiplicative_constant * b.additive_constant; - barretenberg::fr q_2 = b.multiplicative_constant * a.additive_constant; - barretenberg::fr q_3 = c.multiplicative_constant; - barretenberg::fr q_4 = d.multiplicative_constant; - barretenberg::fr q_c = a.additive_constant * b.additive_constant + c.additive_constant + d.additive_constant; + bb::fr q_m = a.multiplicative_constant * b.multiplicative_constant; + bb::fr q_1 = a.multiplicative_constant * b.additive_constant; + bb::fr q_2 = b.multiplicative_constant * a.additive_constant; + bb::fr q_3 = c.multiplicative_constant; + bb::fr q_4 = d.multiplicative_constant; + bb::fr q_c = a.additive_constant * b.additive_constant + c.additive_constant + d.additive_constant; ctx->create_big_mul_gate({ a.witness_index == IS_CONSTANT ? ctx->zero_idx : a.witness_index, @@ -985,7 +979,7 @@ template field_t field_t::accumulate(const // Step 2: compute output value size_t num_elements = accumulator.size(); - barretenberg::fr output = 0; + bb::fr output = 0; for (const auto& acc : accumulator) { output += acc.get_value(); } @@ -1016,8 +1010,8 @@ template field_t field_t::accumulate(const accumulator[3 * i + 2].additive_constant, }, ((i == num_gates - 1) ? false : true)); - barretenberg::fr new_total = accumulating_total.get_value() - accumulator[3 * i].get_value() - - accumulator[3 * i + 1].get_value() - accumulator[3 * i + 2].get_value(); + bb::fr new_total = accumulating_total.get_value() - accumulator[3 * i].get_value() - + accumulator[3 * i + 1].get_value() - accumulator[3 * i + 2].get_value(); accumulating_total = witness_t(ctx, new_total); } return total.normalize(); @@ -1101,7 +1095,7 @@ std::vector> field_t::decompose_into_bits( for (size_t i = 0; i < num_bits; ++i) { bool_t bit = get_bit(context, num_bits - 1 - i, val_u256); result[num_bits - 1 - i] = bit; - barretenberg::fr scaling_factor_value = fr(2).pow(static_cast(num_bits - 1 - i)); + bb::fr scaling_factor_value = fr(2).pow(static_cast(num_bits - 1 - i)); field_t scaling_factor(context, scaling_factor_value); sum = sum + (scaling_factor * bit); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.fuzzer.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.fuzzer.hpp index d392310525b..dccc80a409b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.fuzzer.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.fuzzer.hpp @@ -99,7 +99,7 @@ FastRandom VarianceRNG(0); #define OPERATION_TYPE_SIZE 1 -#define ELEMENT_SIZE (sizeof(barretenberg::fr) + 1) +#define ELEMENT_SIZE (sizeof(bb::fr) + 1) #define TWO_IN_ONE_OUT 3 #define THREE_IN_ONE_OUT 4 #define SLICE_ARGS_SIZE 6 @@ -160,7 +160,7 @@ template class FieldBase { _LAST }; - typedef barretenberg::fr Element; + typedef bb::fr Element; struct SingleArg { uint8_t in; }; @@ -327,7 +327,7 @@ template class FieldBase { * @return Mutated element */ template - inline static barretenberg::fr mutateFieldElement(barretenberg::fr e, T& rng, HavocSettings& havoc_config) + inline static bb::fr mutateFieldElement(bb::fr e, T& rng, HavocSettings& havoc_config) requires SimpleRng { // With a certain probability, we apply changes to the Montgomery form, rather than the plain form. This @@ -347,9 +347,9 @@ template class FieldBase { // Inverse conversion at the end #define INV_MONT_CONVERSION \ if (convert_to_montgomery) { \ - e = barretenberg::fr(value_data).from_montgomery_form(); \ + e = bb::fr(value_data).from_montgomery_form(); \ } else { \ - e = barretenberg::fr(value_data); \ + e = bb::fr(value_data); \ } // Pick the last value from the mutation distrivution vector @@ -367,9 +367,9 @@ template class FieldBase { e = e.to_montgomery_form(); } if (rng.next() & 1) { - value_data = e + barretenberg::fr(rng.next() & 0xff); + value_data = e + bb::fr(rng.next() & 0xff); } else { - value_data = e - barretenberg::fr(rng.next() & 0xff); + value_data = e - bb::fr(rng.next() & 0xff); } if (convert_to_montgomery) { e = e.from_montgomery_form(); @@ -379,31 +379,31 @@ template class FieldBase { MONT_CONVERSION switch (rng.next() % 9) { case 0: - e = barretenberg::fr::zero(); + e = bb::fr::zero(); break; case 1: - e = barretenberg::fr::one(); + e = bb::fr::one(); break; case 2: - e = -barretenberg::fr::one(); + e = -bb::fr::one(); break; case 3: - e = barretenberg::fr::one().sqrt().second; + e = bb::fr::one().sqrt().second; break; case 4: - e = barretenberg::fr::one().sqrt().second.invert(); + e = bb::fr::one().sqrt().second.invert(); break; case 5: - e = barretenberg::fr::get_root_of_unity(8); + e = bb::fr::get_root_of_unity(8); break; case 6: - e = barretenberg::fr(2); + e = bb::fr(2); break; case 7: - e = barretenberg::fr((barretenberg::fr::modulus - 1) / 2); + e = bb::fr((bb::fr::modulus - 1) / 2); break; case 8: - e = barretenberg::fr((barretenberg::fr::modulus)); + e = bb::fr((bb::fr::modulus)); break; default: abort(); @@ -502,9 +502,9 @@ template class FieldBase { // instruction is enabled (if it is -1,it's disabled ) class ArgSizes { public: - static constexpr size_t CONSTANT = sizeof(barretenberg::fr); - static constexpr size_t WITNESS = sizeof(barretenberg::fr); - static constexpr size_t CONSTANT_WITNESS = sizeof(barretenberg::fr); + static constexpr size_t CONSTANT = sizeof(bb::fr); + static constexpr size_t WITNESS = sizeof(bb::fr); + static constexpr size_t CONSTANT_WITNESS = sizeof(bb::fr); static constexpr size_t SQR = 2; static constexpr size_t ASSERT_EQUAL = 2; static constexpr size_t ASSERT_NOT_EQUAL = 2; @@ -587,7 +587,7 @@ template class FieldBase { Instruction instr; instr.id = static_cast(opcode); // instr.arguments.element = fr::serialize_from_buffer(Data+1); - instr.arguments.element = barretenberg::fr::serialize_from_buffer(Data); + instr.arguments.element = bb::fr::serialize_from_buffer(Data); return instr; }; if constexpr (opcode == Instruction::OPCODE::ASSERT_ZERO || @@ -767,18 +767,18 @@ template class FieldBase { } public: - barretenberg::fr base; + bb::fr base; field_t field; ExecutionHandler() = default; - ExecutionHandler(barretenberg::fr a, field_t b) + ExecutionHandler(bb::fr a, field_t b) : base(a) , field(b) {} - ExecutionHandler(barretenberg::fr a, field_t& b) + ExecutionHandler(bb::fr a, field_t& b) : base(a) , field(b) {} - ExecutionHandler(barretenberg::fr& a, field_t& b) + ExecutionHandler(bb::fr& a, field_t& b) : base(a) , field(b) {} @@ -1009,7 +1009,7 @@ template class FieldBase { #ifdef SHOW_INFORMATION std::cout << "Construct via fr" << std::endl; #endif - return construct_via_cast(barretenberg::fr::modulus - 1); + return construct_via_cast(bb::fr::modulus - 1); case 6: #if 1 /* Disabled because casting to bool_t can fail. @@ -1061,15 +1061,14 @@ template class FieldBase { // const auto bits = this->f().decompose_into_bits(num_bits); const auto bits = this->f().decompose_into_bits(); - std::vector frs(bits.size()); + std::vector frs(bits.size()); for (size_t i = 0; i < bits.size(); i++) { - frs[i] = bits[i].get_value() ? barretenberg::fr(uint256_t(1) << i) : 0; + frs[i] = bits[i].get_value() ? bb::fr(uint256_t(1) << i) : 0; } switch (VarianceRNG.next() % 2) { case 0: { - const barretenberg::fr field_from_bits = - std::accumulate(frs.begin(), frs.end(), barretenberg::fr(0)); + const bb::fr field_from_bits = std::accumulate(frs.begin(), frs.end(), bb::fr(0)); return ExecutionHandler(this->base, field_t(builder, field_from_bits)); } case 1: { @@ -1095,7 +1094,7 @@ template class FieldBase { if (this->base == 0) { return ExecutionHandler(this->base, this->f()); } else { - return ExecutionHandler(barretenberg::fr(1) / this->base, this->f().invert()); + return ExecutionHandler(bb::fr(1) / this->base, this->f().invert()); } } @@ -1449,7 +1448,7 @@ template class FieldBase { PRINT_TWO_ARG_INSTRUCTION(first_index, second_index, stack, "Dividing", "/") ExecutionHandler result; - if (barretenberg::fr((uint256_t(stack[second_index].f().get_value()) % barretenberg::fr::modulus)) == 0) { + if (bb::fr((uint256_t(stack[second_index].f().get_value()) % bb::fr::modulus)) == 0) { return 0; // This is not handled by field } // TODO: FIX THIS. I can't think of an elegant fix for this field issue right now @@ -1832,7 +1831,7 @@ template class FieldBase { (void)builder; for (size_t i = 0; i < stack.size(); i++) { auto element = stack[i]; - if (barretenberg::fr((uint256_t(element.field.get_value()) % barretenberg::fr::modulus)) != element.base) { + if (bb::fr((uint256_t(element.field.get_value()) % bb::fr::modulus)) != element.base) { std::cerr << "Failed at " << i << " with actual value " << element.base << " and value in field " << element.field.get_value() << std::endl; return false; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp index bd637520bc1..ac5f80b773e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp @@ -12,14 +12,14 @@ template class field_t { using View = field_t; field_t(Builder* parent_context = nullptr); - field_t(Builder* parent_context, const barretenberg::fr& value); + field_t(Builder* parent_context, const bb::fr& value); field_t(const int value) : context(nullptr) , witness_index(IS_CONSTANT) { - additive_constant = barretenberg::fr(value); - multiplicative_constant = barretenberg::fr(0); + additive_constant = bb::fr(value); + multiplicative_constant = bb::fr(0); } // NOLINTNEXTLINE(google-runtime-int) intended behavior @@ -27,16 +27,16 @@ template class field_t { : context(nullptr) , witness_index(IS_CONSTANT) { - additive_constant = barretenberg::fr(value); - multiplicative_constant = barretenberg::fr(0); + additive_constant = bb::fr(value); + multiplicative_constant = bb::fr(0); } field_t(const unsigned int value) : context(nullptr) , witness_index(IS_CONSTANT) { - additive_constant = barretenberg::fr(value); - multiplicative_constant = barretenberg::fr(0); + additive_constant = bb::fr(value); + multiplicative_constant = bb::fr(0); } // NOLINTNEXTLINE(google-runtime-int) intended behavior @@ -44,21 +44,21 @@ template class field_t { : context(nullptr) , witness_index(IS_CONSTANT) { - additive_constant = barretenberg::fr(value); - multiplicative_constant = barretenberg::fr(0); + additive_constant = bb::fr(value); + multiplicative_constant = bb::fr(0); } - field_t(const barretenberg::fr& value) + field_t(const bb::fr& value) : context(nullptr) , additive_constant(value) - , multiplicative_constant(barretenberg::fr(1)) + , multiplicative_constant(bb::fr(1)) , witness_index(IS_CONSTANT) {} field_t(const uint256_t& value) : context(nullptr) , additive_constant(value) - , multiplicative_constant(barretenberg::fr(1)) + , multiplicative_constant(bb::fr(1)) , witness_index(IS_CONSTANT) {} @@ -83,7 +83,7 @@ template class field_t { ~field_t() = default; static constexpr bool is_composite = false; - static constexpr uint256_t modulus = barretenberg::fr::modulus; + static constexpr uint256_t modulus = bb::fr::modulus; static field_t from_witness_index(Builder* parent_context, uint32_t witness_index); @@ -169,10 +169,10 @@ template class field_t { static field_t coset_generator(const size_t generator_idx) { - return field_t(barretenberg::fr::coset_generator(generator_idx)); + return field_t(bb::fr::coset_generator(generator_idx)); } - static field_t external_coset_generator() { return field_t(barretenberg::fr::external_coset_generator()); } + static field_t external_coset_generator() { return field_t(bb::fr::external_coset_generator()); } field_t operator-() const { @@ -245,7 +245,7 @@ template class field_t { **/ field_t normalize() const; - barretenberg::fr get_value() const; + bb::fr get_value() const; Builder* get_context() const { return context; } @@ -279,10 +279,7 @@ template class field_t { context->fix_witness(witness_index, get_value()); } - static field_t from_witness(Builder* ctx, const barretenberg::fr& input) - { - return field_t(witness_t(ctx, input)); - } + static field_t from_witness(Builder* ctx, const bb::fr& input) { return field_t(witness_t(ctx, input)); } /** * Fix a witness. The value of the witness is constrained with a selector @@ -376,8 +373,8 @@ template class field_t { * * This will add a constraint, as both zip and zap map to circuit witnesses. **/ - mutable barretenberg::fr additive_constant; - mutable barretenberg::fr multiplicative_constant; + mutable bb::fr additive_constant; + mutable bb::fr multiplicative_constant; /** * Every builder object contains a vector `variables` (a.k.a. 'witnesses'); circuit variables that can be diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp index f7670c9c7da..07490d3bc99 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp @@ -18,7 +18,7 @@ auto& engine = numeric::random::get_debug_engine(); template void ignore_unused(T&) {} // use to ignore unused variables in lambdas -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; template class stdlib_field : public testing::Test { @@ -74,8 +74,8 @@ template class stdlib_field : public testing::Test { static void generate_test_plonk_circuit(Builder& builder, size_t num_gates) { - field_ct a(public_witness_ct(&builder, barretenberg::fr::random_element())); - field_ct b(public_witness_ct(&builder, barretenberg::fr::random_element())); + field_ct a(public_witness_ct(&builder, bb::fr::random_element())); + field_ct b(public_witness_ct(&builder, bb::fr::random_element())); field_ct c(&builder); for (size_t i = 0; i < (num_gates / 4) - 4; ++i) { @@ -193,13 +193,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - field_ct a = witness_ct(&builder, barretenberg::fr::random_element()); - a *= barretenberg::fr::random_element(); - a += barretenberg::fr::random_element(); + field_ct a = witness_ct(&builder, bb::fr::random_element()); + a *= bb::fr::random_element(); + a += bb::fr::random_element(); - field_ct b = witness_ct(&builder, barretenberg::fr::random_element()); - b *= barretenberg::fr::random_element(); - b += barretenberg::fr::random_element(); + field_ct b = witness_ct(&builder, bb::fr::random_element()); + b *= bb::fr::random_element(); + b += bb::fr::random_element(); // numerator constant field_ct out = field_ct(&builder, b.get_value()) / a; @@ -394,7 +394,7 @@ template class stdlib_field : public testing::Test { uint256_t(0x1122334455667788, 0x8877665544332211, 0xaabbccddeeff9933, 0x1122112211221122)); field_ct c_2(&builder, uint256_t(0xaabbccddeeff9933, 0x8877665544332211, 0x1122334455667788, 0x1122112211221122)); - field_ct c_3(&builder, barretenberg::fr::one()); + field_ct c_3(&builder, bb::fr::one()); field_ct c_4 = c_1 + c_2; a = a * c_4 + c_4; // add some constant terms in to validate our normalization check works @@ -619,13 +619,11 @@ template class stdlib_field : public testing::Test { constexpr uint256_t modulus_minus_one = fr::modulus - 1; const fr p_lo = modulus_minus_one.slice(0, 130); - std::vector test_elements = { - barretenberg::fr::random_element(), - 0, - -1, - barretenberg::fr(static_cast(engine.get_random_uint8())), - barretenberg::fr((static_cast(1) << 130) + 1 + p_lo) - }; + std::vector test_elements = { bb::fr::random_element(), + 0, + -1, + bb::fr(static_cast(engine.get_random_uint8())), + bb::fr((static_cast(1) << 130) + 1 + p_lo) }; for (auto a_expected : test_elements) { field_ct a = witness_ct(&builder, a_expected); @@ -716,13 +714,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - barretenberg::fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -735,14 +733,14 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = 0; field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - EXPECT_EQ(result.get_value(), barretenberg::fr(1)); + EXPECT_EQ(result.get_value(), bb::fr(1)); info("num gates = ", builder.get_num_gates()); bool check_result = builder.check_circuit(); @@ -753,7 +751,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = 1; field_ct base = witness_ct(&builder, base_val); @@ -773,13 +771,13 @@ template class stdlib_field : public testing::Test { const size_t num_gates_start = builder.num_gates; - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base(&builder, base_val); field_ct exponent(&builder, exponent_val); field_ct result = base.pow(exponent); - barretenberg::fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -791,13 +789,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - barretenberg::fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -810,13 +808,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base = witness_ct(&builder, base_val); field_ct exponent(&builder, exponent_val); field_ct result = base.pow(exponent); - barretenberg::fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); info("num gates = ", builder.get_num_gates()); @@ -829,14 +827,14 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint64_t exponent_val = engine.get_random_uint32(); exponent_val += (uint64_t(1) << 32); field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - barretenberg::fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_NE(result.get_value(), expected); EXPECT_EQ(builder.failed(), true); @@ -847,7 +845,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - barretenberg::fr value(engine.get_random_uint256()); + bb::fr value(engine.get_random_uint256()); field_ct value_ct = witness_ct(&builder, value); field_ct first_copy = witness_ct(&builder, value_ct.get_value()); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp index 2ba2e1f6826..75373813e1f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp @@ -18,7 +18,7 @@ using witness_ct = stdlib::witness_t; namespace stdlib_cycle_group_tests { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp index f1790af9271..2810657e787 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp @@ -59,8 +59,8 @@ field_t logic::create_logic_constraint( auto left((uint256_t)a.get_value()); auto right((uint256_t)b.get_value()); - field_pt a_accumulator(barretenberg::fr::zero()); - field_pt b_accumulator(barretenberg::fr::zero()); + field_pt a_accumulator(bb::fr::zero()); + field_pt b_accumulator(bb::fr::zero()); field_pt res(ctx, 0); for (size_t i = 0; i < num_chunks; ++i) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp index 1c3ab427b90..ab21c3d3fed 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp @@ -24,7 +24,7 @@ auto& engine = numeric::random::get_debug_engine(); template void ignore_unused(T&) {} // use to ignore unused variables in lambdas -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; template class LogicTest : public testing::Test {}; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp index c6b81b6d139..72106bfa130 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp @@ -8,7 +8,7 @@ #include "../circuit_builders/circuit_builders.hpp" namespace test_stdlib_dynamic_array { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp index 920cf8bbdcd..614362fa4ef 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp @@ -24,13 +24,13 @@ TEST(ram_table, ram_table_init_read_consistency) std::vector table_values; const size_t table_size = 10; for (size_t i = 0; i < table_size; ++i) { - table_values.emplace_back(witness_ct(&builder, barretenberg::fr::random_element())); + table_values.emplace_back(witness_ct(&builder, bb::fr::random_element())); } ram_table_ct table(table_values); field_ct result(0); - barretenberg::fr expected(0); + bb::fr expected(0); for (size_t i = 0; i < 10; ++i) { field_ct index(witness_ct(&builder, (uint64_t)i)); @@ -56,7 +56,7 @@ TEST(ram_table, ram_table_read_write_consistency) Builder builder; const size_t table_size = 10; - std::vector table_values(table_size); + std::vector table_values(table_size); ram_table_ct table(&builder, table_size); @@ -64,12 +64,12 @@ TEST(ram_table, ram_table_read_write_consistency) table.write(i, 0); } field_ct result(0); - barretenberg::fr expected(0); + bb::fr expected(0); const auto update = [&]() { for (size_t i = 0; i < table_size / 2; ++i) { - table_values[2 * i] = barretenberg::fr::random_element(); - table_values[2 * i + 1] = barretenberg::fr::random_element(); + table_values[2 * i] = bb::fr::random_element(); + table_values[2 * i + 1] = bb::fr::random_element(); // init with both constant and variable values table.write(2 * i, table_values[2 * i]); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp index d59c1af82af..6778b188234 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.cpp @@ -2,7 +2,7 @@ #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp index 2c716b3a5cc..8f23652699a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp @@ -6,7 +6,7 @@ #include "rom_table.hpp" namespace test_stdlib_rom_array { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; // Defining ultra-specific types for local testing. @@ -26,13 +26,13 @@ TEST(rom_table, rom_table_read_write_consistency) std::vector table_values; const size_t table_size = 10; for (size_t i = 0; i < table_size; ++i) { - table_values.emplace_back(witness_ct(&builder, barretenberg::fr::random_element())); + table_values.emplace_back(witness_ct(&builder, bb::fr::random_element())); } rom_table_ct table(table_values); field_ct result(0); - barretenberg::fr expected(0); + bb::fr expected(0); for (size_t i = 0; i < 10; ++i) { field_ct index(witness_ct(&builder, (uint64_t)i)); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp index 83b122b9bf9..39ea56eb5b9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/twin_rom_table.cpp @@ -2,7 +2,7 @@ #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.cpp index 32c83fe8277..37c4e149003 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.cpp @@ -2,7 +2,7 @@ #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp index cabe42dfeda..8369cee02b0 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp @@ -8,7 +8,7 @@ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" namespace test_stdlib_packed_byte_array { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; namespace { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp index 9ac460857c2..3b956bb1766 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.cpp @@ -12,7 +12,7 @@ namespace stdlib { using plookup::ColumnIdx; using plookup::MultiTableId; -using namespace barretenberg; +using namespace bb; template plookup::ReadData> plookup_read::get_lookup_accumulators(const MultiTableId id, @@ -23,7 +23,7 @@ plookup::ReadData> plookup_read::get_lookup_accumulato auto key_a = key_a_in.normalize(); auto key_b = key_b_in.normalize(); Builder* ctx = key_a.get_context() ? key_a.get_context() : key_b.get_context(); - const plookup::ReadData lookup_data = + const plookup::ReadData lookup_data = plookup::get_lookup_accumulators(id, key_a.get_value(), key_b.get_value(), is_2_to_1_lookup); const bool is_key_a_constant = key_a.is_constant(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp index e199c2b817b..2db53e2351c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp @@ -10,7 +10,7 @@ #include namespace test_stdlib_plookups { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; using namespace plookup; @@ -28,15 +28,15 @@ auto& engine = numeric::random::get_debug_engine(); // { // Builder builder = Builder(); -// barretenberg::fr input_value = fr::random_element(); +// bb::fr input_value = fr::random_element(); // field_ct input_hi = witness_ct(&builder, uint256_t(input_value).slice(126, 256)); // field_ct input_lo = witness_ct(&builder, uint256_t(input_value).slice(0, 126)); // const auto lookup_hi = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_LEFT_HI, input_hi); // const auto lookup_lo = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_LEFT_LO, input_lo); -// std::vector expected_x; -// std::vector expected_y; +// std::vector expected_x; +// std::vector expected_y; // const size_t num_lookups_hi = // (128 + crypto::pedersen_hash::lookup::BITS_PER_TABLE) / crypto::pedersen_hash::lookup::BITS_PER_TABLE; @@ -46,7 +46,7 @@ auto& engine = numeric::random::get_debug_engine(); // EXPECT_EQ(num_lookups_lo, lookup_lo[ColumnIdx::C1].size()); // const size_t num_lookups = num_lookups_hi + num_lookups_lo; -// std::vector expected_scalars; +// std::vector expected_scalars; // expected_x.resize(num_lookups); // expected_y.resize(num_lookups); // expected_scalars.resize(num_lookups); @@ -105,15 +105,15 @@ auto& engine = numeric::random::get_debug_engine(); // { // Builder builder = Builder(); -// barretenberg::fr input_value = fr::random_element(); +// bb::fr input_value = fr::random_element(); // field_ct input_hi = witness_ct(&builder, uint256_t(input_value).slice(126, 256)); // field_ct input_lo = witness_ct(&builder, uint256_t(input_value).slice(0, 126)); // const auto lookup_hi = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_RIGHT_HI, input_hi); // const auto lookup_lo = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_RIGHT_LO, input_lo); -// std::vector expected_x; -// std::vector expected_y; +// std::vector expected_x; +// std::vector expected_y; // const size_t num_lookups_hi = // (128 + crypto::pedersen_hash::lookup::BITS_PER_TABLE) / crypto::pedersen_hash::lookup::BITS_PER_TABLE; @@ -123,7 +123,7 @@ auto& engine = numeric::random::get_debug_engine(); // EXPECT_EQ(num_lookups_lo, lookup_lo[ColumnIdx::C1].size()); // const size_t num_lookups = num_lookups_hi + num_lookups_lo; -// std::vector expected_scalars; +// std::vector expected_scalars; // expected_x.resize(num_lookups); // expected_y.resize(num_lookups); // expected_scalars.resize(num_lookups); @@ -187,8 +187,8 @@ TEST(stdlib_plookup, uint32_xor) uint256_t left_value = (engine.get_random_uint256() & 0xffffffffULL); uint256_t right_value = (engine.get_random_uint256() & 0xffffffffULL); - field_ct left = witness_ct(&builder, barretenberg::fr(left_value)); - field_ct right = witness_ct(&builder, barretenberg::fr(right_value)); + field_ct left = witness_ct(&builder, bb::fr(left_value)); + field_ct right = witness_ct(&builder, bb::fr(right_value)); const auto lookup = plookup_read::get_lookup_accumulators(MultiTableId::UINT32_XOR, left, right, true); @@ -212,9 +212,9 @@ TEST(stdlib_plookup, uint32_xor) } for (size_t i = 0; i < num_lookups; ++i) { - EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), barretenberg::fr(left_expected[i])); - EXPECT_EQ(lookup[ColumnIdx::C2][i].get_value(), barretenberg::fr(right_expected[i])); - EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), barretenberg::fr(out_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), bb::fr(left_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C2][i].get_value(), bb::fr(right_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), bb::fr(out_expected[i])); } bool result = builder.check_circuit(); @@ -231,17 +231,17 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) uint256_t left_value = (engine.get_random_uint256() & 0xffffffffULL); uint256_t right_value = (engine.get_random_uint256() & 0xffffffffULL); - field_ct left = witness_ct(&builder, barretenberg::fr(left_value)); - field_ct right = witness_ct(&builder, barretenberg::fr(right_value)); + field_ct left = witness_ct(&builder, bb::fr(left_value)); + field_ct right = witness_ct(&builder, bb::fr(right_value)); const auto lookup = plookup_read::get_lookup_accumulators(MultiTableId::BLAKE_XOR_ROTATE_16, left, right, true); const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 2) { @@ -262,9 +262,7 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) * out_coefficients must be (a5/a4, a4/a3, a3/a2, a2/a1, a1/a0). Note that these are stored in reverse orde * for simplicity. */ - std::vector out_coefficients{ - (1 << 6), (barretenberg::fr(1) / barretenberg::fr(1 << 22)), (1 << 2), (1 << 6), (1 << 6) - }; + std::vector out_coefficients{ (1 << 6), (bb::fr(1) / bb::fr(1 << 22)), (1 << 2), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -283,10 +281,10 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) * while defining the table we had set the coefficient of s0 to 1, so to correct that, we need to multiply by a * constant. */ - auto mul_constant = barretenberg::fr(1 << 16); - barretenberg::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + auto mul_constant = bb::fr(1 << 16); + bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 16); - EXPECT_EQ(barretenberg::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -302,17 +300,17 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) uint256_t left_value = (engine.get_random_uint256() & 0xffffffffULL); uint256_t right_value = (engine.get_random_uint256() & 0xffffffffULL); - field_ct left = witness_ct(&builder, barretenberg::fr(left_value)); - field_ct right = witness_ct(&builder, barretenberg::fr(right_value)); + field_ct left = witness_ct(&builder, bb::fr(left_value)); + field_ct right = witness_ct(&builder, bb::fr(right_value)); const auto lookup = plookup_read::get_lookup_accumulators(MultiTableId::BLAKE_XOR_ROTATE_8, left, right, true); const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 1) { @@ -327,10 +325,8 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) right_expected[i] = right_slices[i]; } - auto mul_constant = barretenberg::fr(1 << 24); - std::vector out_coefficients{ - (barretenberg::fr(1) / mul_constant), (1 << 4), (1 << 6), (1 << 6), (1 << 6) - }; + auto mul_constant = bb::fr(1 << 24); + std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 4), (1 << 6), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -344,9 +340,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), out_expected[i]); } - barretenberg::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 8); - EXPECT_EQ(barretenberg::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -362,17 +358,17 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) uint256_t left_value = (engine.get_random_uint256() & 0xffffffffULL); uint256_t right_value = (engine.get_random_uint256() & 0xffffffffULL); - field_ct left = witness_ct(&builder, barretenberg::fr(left_value)); - field_ct right = witness_ct(&builder, barretenberg::fr(right_value)); + field_ct left = witness_ct(&builder, bb::fr(left_value)); + field_ct right = witness_ct(&builder, bb::fr(right_value)); const auto lookup = plookup_read::get_lookup_accumulators(MultiTableId::BLAKE_XOR_ROTATE_7, left, right, true); const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 1) { @@ -387,10 +383,8 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) right_expected[i] = right_slices[i]; } - auto mul_constant = barretenberg::fr(1 << 25); - std::vector out_coefficients{ - (barretenberg::fr(1) / mul_constant), (1 << 5), (1 << 6), (1 << 6), (1 << 6) - }; + auto mul_constant = bb::fr(1 << 25); + std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 5), (1 << 6), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -404,9 +398,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), out_expected[i]); } - barretenberg::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 7); - EXPECT_EQ(barretenberg::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -422,8 +416,8 @@ TEST(stdlib_plookup, blake2s_xor) uint256_t left_value = (engine.get_random_uint256() & 0xffffffffULL); uint256_t right_value = (engine.get_random_uint256() & 0xffffffffULL); - field_ct left = witness_ct(&builder, barretenberg::fr(left_value)); - field_ct right = witness_ct(&builder, barretenberg::fr(right_value)); + field_ct left = witness_ct(&builder, bb::fr(left_value)); + field_ct right = witness_ct(&builder, bb::fr(right_value)); const auto lookup = plookup_read::get_lookup_accumulators(MultiTableId::BLAKE_XOR, left, right, true); @@ -449,9 +443,9 @@ TEST(stdlib_plookup, blake2s_xor) // t5 = a5 // // output = (t0 - 2^12 t2) * 2^{32 - 12} + t2 - barretenberg::fr lookup_output = lookup[ColumnIdx::C3][2].get_value(); - barretenberg::fr t2_term = barretenberg::fr(1 << 12) * lookup[ColumnIdx::C3][2].get_value(); - lookup_output += barretenberg::fr(1 << 20) * (lookup[ColumnIdx::C3][0].get_value() - t2_term); + bb::fr lookup_output = lookup[ColumnIdx::C3][2].get_value(); + bb::fr t2_term = bb::fr(1 << 12) * lookup[ColumnIdx::C3][2].get_value(); + lookup_output += bb::fr(1 << 20) * (lookup[ColumnIdx::C3][0].get_value() - t2_term); for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * (1 << 6); @@ -463,12 +457,12 @@ TEST(stdlib_plookup, blake2s_xor) // The following checks if the xor output rotated by 12 can be computed correctly from basic blake2s_xor. // auto xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 12); - EXPECT_EQ(barretenberg::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); for (size_t i = 0; i < num_lookups; ++i) { - EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), barretenberg::fr(left_expected[i])); - EXPECT_EQ(lookup[ColumnIdx::C2][i].get_value(), barretenberg::fr(right_expected[i])); - EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), barretenberg::fr(out_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), bb::fr(left_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C2][i].get_value(), bb::fr(right_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), bb::fr(out_expected[i])); } bool result = builder.check_circuit(); @@ -485,8 +479,8 @@ TEST(stdlib_plookup, uint32_and) uint256_t left_value = (engine.get_random_uint256() & 0xffffffffULL); uint256_t right_value = (engine.get_random_uint256() & 0xffffffffULL); - field_ct left = witness_ct(&builder, barretenberg::fr(left_value)); - field_ct right = witness_ct(&builder, barretenberg::fr(right_value)); + field_ct left = witness_ct(&builder, bb::fr(left_value)); + field_ct right = witness_ct(&builder, bb::fr(right_value)); const auto lookup = plookup_read::get_lookup_accumulators(MultiTableId::UINT32_AND, left, right, true); const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); @@ -508,9 +502,9 @@ TEST(stdlib_plookup, uint32_and) } for (size_t i = 0; i < num_lookups; ++i) { - EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), barretenberg::fr(left_expected[i])); - EXPECT_EQ(lookup[ColumnIdx::C2][i].get_value(), barretenberg::fr(right_expected[i])); - EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), barretenberg::fr(out_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), bb::fr(left_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C2][i].get_value(), bb::fr(right_expected[i])); + EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), bb::fr(out_expected[i])); } bool result = builder.check_circuit(); @@ -527,7 +521,7 @@ TEST(stdlib_plookup, secp256k1_generator) uint64_t wnaf_entries[18] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); + bb::wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); std::vector naf_values; for (size_t i = 0; i < 17; ++i) { @@ -553,10 +547,10 @@ TEST(stdlib_plookup, secp256k1_generator) accumulators.emplace_back(t1 - t2); } field_ct accumulator_field = field_ct::accumulate(accumulators); - EXPECT_EQ(accumulator_field.get_value(), barretenberg::fr(input_value) + barretenberg::fr(skew)); + EXPECT_EQ(accumulator_field.get_value(), bb::fr(input_value) + bb::fr(skew)); for (size_t i = 0; i < 256; ++i) { - field_ct index(witness_ct(&builder, barretenberg::fr(i))); + field_ct index(witness_ct(&builder, bb::fr(i))); const auto xlo = plookup_read::read_pair_from_table(MultiTableId::SECP256K1_XLO, index); const auto xhi = plookup_read::read_pair_from_table(MultiTableId::SECP256K1_XHI, index); const auto ylo = plookup_read::read_pair_from_table(MultiTableId::SECP256K1_YLO, index); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.cpp index 64ec0dc142a..2fa749da2d9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.cpp @@ -186,7 +186,7 @@ template bool_t safe_uint_t::is_zero() cons return value.is_zero(); } -template barretenberg::fr safe_uint_t::get_value() const +template bb::fr safe_uint_t::get_value() const { return value.get_value(); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.fuzzer.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.fuzzer.hpp index 2242f273905..77438c40730 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.fuzzer.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.fuzzer.hpp @@ -9,7 +9,7 @@ // the input should fail bool circuit_should_fail = false; -using fr = barretenberg::fr; +using fr = bb::fr; #define HAVOC_TESTING #include "barretenberg/common/fuzzer.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.hpp index f357e32efba..b61e5757f9c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.hpp @@ -33,8 +33,8 @@ template class safe_uint_t { public: // The following constant should be small enough that any thing with this bitnum is smaller than the modulus - static constexpr size_t MAX_BIT_NUM = barretenberg::fr::modulus.get_msb(); - static constexpr uint256_t MAX_VALUE = barretenberg::fr::modulus - 1; + static constexpr size_t MAX_BIT_NUM = bb::fr::modulus.get_msb(); + static constexpr uint256_t MAX_VALUE = bb::fr::modulus - 1; static constexpr size_t IS_UNSAFE = 143; // weird constant to make it hard to use accidentally // Make sure our uint256 values don't wrap - add_two function sums three of these static_assert((uint512_t)MAX_VALUE * 3 < (uint512_t)1 << 256); @@ -56,7 +56,7 @@ template class safe_uint_t { // When initialzing a constant, we can set the max value to the constant itself (rather than the usually larger // 2^n-1) - safe_uint_t(const barretenberg::fr& const_value) + safe_uint_t(const bb::fr& const_value) : value(const_value) , current_max(const_value) {} @@ -64,12 +64,12 @@ template class safe_uint_t { // When initialzing a constant, we can set the max value to the constant itself (rather than the usually larger // 2^n-1) safe_uint_t(const uint256_t& const_value) - : value(barretenberg::fr(const_value)) - , current_max(barretenberg::fr(const_value)) + : value(bb::fr(const_value)) + , current_max(bb::fr(const_value)) {} safe_uint_t(const unsigned int& const_value) - : value(barretenberg::fr(const_value)) - , current_max(barretenberg::fr(const_value)) + : value(bb::fr(const_value)) + , current_max(bb::fr(const_value)) {} safe_uint_t(const safe_uint_t& other) @@ -77,7 +77,7 @@ template class safe_uint_t { , current_max(other.current_max) {} - static safe_uint_t create_constant_witness(Builder* parent_context, barretenberg::fr const& value) + static safe_uint_t create_constant_witness(Builder* parent_context, bb::fr const& value) { witness_t out(parent_context, value); @@ -177,7 +177,7 @@ template class safe_uint_t { **/ safe_uint_t normalize() const; - barretenberg::fr get_value() const; + bb::fr get_value() const; Builder* get_context() const { return value.context; } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp index cf54c1182f8..eaf84cfd8ae 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp @@ -23,7 +23,7 @@ auto& engine = numeric::random::get_debug_engine(); } namespace test_stdlib_safe_uint { -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; template void ignore_unused(T&) {} // use to ignore unused variables in lambdas diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/arithmetic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/arithmetic.cpp index 92d356245f1..3312830d752 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/arithmetic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/arithmetic.cpp @@ -1,7 +1,7 @@ #include "../circuit_builders/circuit_builders.hpp" #include "uint.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace proof_system::plonk { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/comparison.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/comparison.cpp index 5fc9af26baa..5078aa04b48 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/comparison.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/comparison.cpp @@ -1,7 +1,7 @@ #include "../circuit_builders/circuit_builders.hpp" #include "uint.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/logic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/logic.cpp index 831b20ff9f6..bcea0e3c2be 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/logic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/logic.cpp @@ -1,7 +1,7 @@ #include "../circuit_builders/circuit_builders.hpp" #include "uint.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace proof_system::plonk { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/arithmetic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/arithmetic.cpp index 04bd7dfa93e..1fda18bb48a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/arithmetic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/arithmetic.cpp @@ -1,7 +1,7 @@ #include "../../circuit_builders/circuit_builders.hpp" #include "uint.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace proof_system::plonk { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/comparison.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/comparison.cpp index e3dfc045961..149f63896f6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/comparison.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/comparison.cpp @@ -1,7 +1,7 @@ #include "../../circuit_builders/circuit_builders.hpp" #include "uint.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp index 9db84cae2dd..215e95d837d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp @@ -1,7 +1,7 @@ #include "../../circuit_builders/circuit_builders.hpp" #include "uint.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { @@ -286,7 +286,7 @@ uint_plookup uint_plookup::logic_operator(cons } uint_plookup result(ctx); // result.accumulators.resize(num_accumulators()); - field_t scaling_factor(context, barretenberg::fr(1ULL << bits_per_limb)); + field_t scaling_factor(context, bb::fr(1ULL << bits_per_limb)); // N.B. THIS LOOP ONLY WORKS IF THE LOGIC TABLE SLICE SIZE IS HALF THAT OF `bits_per_limb` for (size_t i = 0; i < num_accumulators(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/uint.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/uint.cpp index 97ab8fa4df8..3f00bd8472c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/uint.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/uint.cpp @@ -1,7 +1,7 @@ #include "uint.hpp" #include "../../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; namespace proof_system::plonk { namespace stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp index 5bcfc4991b1..c1ac6526961 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.cpp @@ -1,7 +1,7 @@ #include "uint.hpp" #include "../circuit_builders/circuit_builders.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system; namespace proof_system::plonk { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp index ac0938e3d34..e3415543c20 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp @@ -3,7 +3,7 @@ #include #include -using namespace barretenberg; +using namespace bb; using namespace proof_system::plonk; using namespace proof_system; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/witness/witness.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/witness/witness.hpp index 1d3dea5890c..3cc38a644db 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/witness/witness.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/witness/witness.hpp @@ -11,7 +11,7 @@ template class witness_t { public: witness_t() = default; - witness_t(Builder* parent_context, const barretenberg::fr& in) + witness_t(Builder* parent_context, const bb::fr& in) { context = parent_context; witness = in; @@ -22,9 +22,9 @@ template class witness_t { { context = parent_context; if (in) { - barretenberg::fr::__copy(barretenberg::fr::one(), witness); + bb::fr::__copy(bb::fr::one(), witness); } else { - barretenberg::fr::__copy(barretenberg::fr::zero(), witness); + bb::fr::__copy(bb::fr::zero(), witness); } witness_index = context->add_variable(witness); } @@ -32,18 +32,18 @@ template class witness_t { witness_t(Builder* parent_context, IntegralOrEnum auto const in) { context = parent_context; - witness = barretenberg::fr{ static_cast(in), 0, 0, 0 }.to_montgomery_form(); + witness = bb::fr{ static_cast(in), 0, 0, 0 }.to_montgomery_form(); witness_index = context->add_variable(witness); } - static witness_t create_constant_witness(Builder* parent_context, const barretenberg::fr& in) + static witness_t create_constant_witness(Builder* parent_context, const bb::fr& in) { witness_t out(parent_context, in); parent_context->assert_equal_constant(out.witness_index, in); return out; } - barretenberg::fr witness; + bb::fr witness; uint32_t witness_index = IS_CONSTANT; Builder* context = nullptr; }; @@ -55,10 +55,10 @@ template class public_witness_t : public witness_t { using witness_t::witness_index; public_witness_t() = default; - public_witness_t(Builder* parent_context, const barretenberg::fr& in) + public_witness_t(Builder* parent_context, const bb::fr& in) { context = parent_context; - barretenberg::fr::__copy(in, witness); + bb::fr::__copy(in, witness); witness_index = context->add_public_variable(witness); } @@ -66,9 +66,9 @@ template class public_witness_t : public witness_t { { context = parent_context; if (in) { - barretenberg::fr::__copy(barretenberg::fr::one(), witness); + bb::fr::__copy(bb::fr::one(), witness); } else { - barretenberg::fr::__copy(barretenberg::fr::zero(), witness); + bb::fr::__copy(bb::fr::zero(), witness); } witness_index = context->add_public_variable(witness); } @@ -76,7 +76,7 @@ template class public_witness_t : public witness_t { template public_witness_t(Builder* parent_context, T const in) { context = parent_context; - witness = barretenberg::fr{ static_cast(in), 0, 0, 0 }.to_montgomery_form(); + witness = bb::fr{ static_cast(in), 0, 0, 0 }.to_montgomery_form(); witness_index = context->add_public_variable(witness); } }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/native_aggregation_state.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/native_aggregation_state.hpp index 529c1dfb0cf..21036437197 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/native_aggregation_state.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/native_aggregation_state.hpp @@ -15,9 +15,9 @@ namespace recursion { * has_data: indicates if this aggregation state contain past (P0, P1) */ struct native_aggregation_state { - typename barretenberg::g1::affine_element P0 = barretenberg::g1::affine_one; - typename barretenberg::g1::affine_element P1 = barretenberg::g1::affine_one; - std::vector public_inputs; + typename bb::g1::affine_element P0 = bb::g1::affine_one; + typename bb::g1::affine_element P1 = bb::g1::affine_one; + std::vector public_inputs; std::vector proof_witness_indices; bool has_data = false; 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..842310d0674 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp @@ -17,7 +17,7 @@ namespace proof_system::plonk::stdlib::recursion::honk { template class Transcript { public: using field_ct = field_t; - using FF = barretenberg::fr; + using FF = bb::fr; using BaseTranscript = proof_system::honk::BaseTranscript; using StdlibTypes = utility::StdlibTypesUtility; 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..860da39467a 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 @@ -13,7 +13,7 @@ namespace proof_system::plonk::stdlib::recursion::honk { using Builder = UltraCircuitBuilder; using UltraFlavor = ::proof_system::honk::flavor::Ultra; using UltraRecursiveFlavor = ::proof_system::honk::flavor::UltraRecursive_; -using FF = barretenberg::fr; +using FF = bb::fr; using BaseTranscript = ::proof_system::honk::BaseTranscript; /** @@ -26,7 +26,7 @@ template auto generate_mock_proof_data(auto prover { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; - using Univariate = typename barretenberg::Univariate; + using Univariate = typename bb::Univariate; // Create some mock data to be added to the transcript in several mock rounds uint32_t data = 25; @@ -68,7 +68,7 @@ template void perform_mock_verifier_transcript_ope { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; - using Univariate = typename barretenberg::Univariate; + using Univariate = typename bb::Univariate; // round 0 transcript.template receive_from_prover("data"); @@ -124,12 +124,12 @@ TEST(RecursiveHonkTranscript, InterfacesMatch) */ TEST(RecursiveHonkTranscript, ReturnValuesMatch) { - using FF = barretenberg::fr; - using Commitment = barretenberg::g1::affine_element; + using FF = bb::fr; + using Commitment = bb::g1::affine_element; using field_ct = field_t; - using fq_ct = bigfield; - using element_ct = element; + using fq_ct = bigfield; + using element_ct = element; Builder builder; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index 5263c6b90c0..2e6a67f41ca 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -124,7 +124,7 @@ template class GoblinRecursiveVerifierTest : public testi }; public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } /** * @brief Create inner circuit and call check_circuit on it diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 765759e1722..bbffb595050 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -32,7 +32,7 @@ class RecursiveMergeVerifierTest : public testing::Test { using VerifierCommitmentKey = ::proof_system::honk::pcs::VerifierCommitmentKey; public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } /** * @brief Test recursive merge verification for the ops generated by a sample circuit diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp index 49b8882d759..3c966a4dcc3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -103,7 +103,7 @@ template class RecursiveVerifierTest : public testing::Te }; public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } /** * @brief Create inner circuit and call check_circuit on it diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp index 15af56a604f..b010f865225 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp @@ -19,8 +19,8 @@ template class Transcript { public: using field_pt = field_t; using witness_pt = witness_t; - using fq_pt = bigfield; - using group_pt = element; + using fq_pt = bigfield; + using group_pt = element; using Key = verification_key>; Transcript(Builder* in_context, const transcript::Manifest& input_manifest) @@ -151,7 +151,7 @@ template class Transcript { { uint256_t x = element.x.get_value().lo; uint256_t y = element.y.get_value().lo; - barretenberg::g1::affine_element converted{ barretenberg::fq(x), barretenberg::fq(y) }; + bb::g1::affine_element converted{ bb::fq(x), bb::fq(y) }; transcript_base.add_element(element_name, converted.to_buffer()); group_keys.push_back(element_name); group_values.push_back(element); @@ -159,7 +159,7 @@ template class Transcript { void add_field_element_vector(const std::string& element_name, const std::vector& elements) { - std::vector values; + std::vector values; for (size_t i = 0; i < elements.size(); ++i) { values.push_back(elements[i].get_value()); } @@ -310,8 +310,7 @@ template class Transcript { if (cache_idx != -1) { return field_values[static_cast(cache_idx)]; } - barretenberg::fr value = - barretenberg::fr::serialize_from_buffer(&(transcript_base.get_element(element_name))[0]); + bb::fr value = bb::fr::serialize_from_buffer(&(transcript_base.get_element(element_name))[0]); field_pt result(witness_pt(context, value)); field_keys.push_back(element_name); field_values.push_back(result); @@ -324,7 +323,7 @@ template class Transcript { if (cache_idx != -1) { return field_vector_values[static_cast(cache_idx)]; } - std::vector values = many_from_buffer(transcript_base.get_element(element_name)); + std::vector values = many_from_buffer(transcript_base.get_element(element_name)); std::vector result; for (auto& value : values) { @@ -366,17 +365,17 @@ template class Transcript { if (cache_idx != -1) { return group_values[static_cast(cache_idx)]; } - barretenberg::g1::affine_element value = - barretenberg::g1::affine_element::serialize_from_buffer(&(transcript_base.get_element(element_name))[0]); + bb::g1::affine_element value = + bb::g1::affine_element::serialize_from_buffer(&(transcript_base.get_element(element_name))[0]); group_pt result = convert_g1(context, value); group_keys.push_back(element_name); group_values.push_back(result); return result; } - static fq_pt convert_fq(Builder* ctx, const barretenberg::fq& input) { return fq_pt::from_witness(ctx, input); }; + static fq_pt convert_fq(Builder* ctx, const bb::fq& input) { return fq_pt::from_witness(ctx, input); }; - static group_pt convert_g1(Builder* ctx, const barretenberg::g1::affine_element& input) + static group_pt convert_g1(Builder* ctx, const bb::g1::affine_element& input) { return group_pt::from_witness(ctx, input); }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp index 4f969db4452..b1d8d0d31e6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp @@ -15,8 +15,8 @@ using bool_t = stdlib::bool_t; using uint32 = stdlib::uint; using witness_t = stdlib::witness_t; using byte_array = stdlib::byte_array; -using fq_t = stdlib::bigfield; -using group_t = stdlib::element; +using fq_t = stdlib::bigfield; +using group_t = stdlib::element; using transcript_ct = Transcript; namespace { @@ -56,9 +56,9 @@ transcript::Manifest create_manifest(const size_t num_public_inputs) } // namespace struct TestData { - std::vector g1_elements; - std::vector fr_elements; - std::vector public_input_elements; + std::vector g1_elements; + std::vector fr_elements; + std::vector public_input_elements; size_t num_public_inputs; }; @@ -66,14 +66,14 @@ TestData get_test_data() { TestData data; for (size_t i = 0; i < 32; ++i) { - data.g1_elements.push_back(barretenberg::g1::affine_element(barretenberg::g1::element::random_element())); - data.fr_elements.push_back(barretenberg::fr::random_element()); + data.g1_elements.push_back(bb::g1::affine_element(bb::g1::element::random_element())); + data.fr_elements.push_back(bb::fr::random_element()); } - data.fr_elements[2] = barretenberg::fr(0); - data.fr_elements[3] = barretenberg::fr(0); + data.fr_elements[2] = bb::fr(0); + data.fr_elements[3] = bb::fr(0); data.num_public_inputs = 13; for (size_t i = 0; i < data.num_public_inputs; ++i) { - data.public_input_elements.push_back(barretenberg::fr::random_element()); + data.public_input_elements.push_back(bb::fr::random_element()); } return data; } @@ -132,8 +132,8 @@ transcript_ct get_circuit_transcript(Builder* context, const TestData& data) { transcript_ct transcript(context, create_manifest(data.num_public_inputs)); uint256_t circuit_size_value = uint256_t(4) + (uint256_t(3) << 8) + (uint256_t(2) << 16) + (uint256_t(1) << 24); - field_t circuit_size(stdlib::witness_t(context, barretenberg::fr(circuit_size_value))); - field_t public_input_size(stdlib::witness_t(context, barretenberg::fr(data.num_public_inputs))); + field_t circuit_size(stdlib::witness_t(context, bb::fr(circuit_size_value))); + field_t public_input_size(stdlib::witness_t(context, bb::fr(data.num_public_inputs))); transcript.add_field_element("circuit_size", circuit_size); transcript.add_field_element("public_input_size", public_input_size); @@ -191,8 +191,8 @@ TEST(stdlib_transcript, validate_transcript) const auto check_challenge = [&normal_transcript, &recursive_transcript](const std::string& challenge_name, const size_t challenge_idx = 0) { field_t result = recursive_transcript.get_challenge_field_element(challenge_name, challenge_idx); - barretenberg::fr expected = - barretenberg::fr::serialize_from_buffer(&normal_transcript.get_challenge(challenge_name, challenge_idx)[0]); + bb::fr expected = + bb::fr::serialize_from_buffer(&normal_transcript.get_challenge(challenge_name, challenge_idx)[0]); EXPECT_EQ(result.get_value(), expected); }; @@ -204,27 +204,26 @@ TEST(stdlib_transcript, validate_transcript) expected_u256 *= uint256_t(256); expected_u256 += uint256_t(expected_raw[i]); } - EXPECT_EQ(result.get_value(), barretenberg::fr(expected_u256)); + EXPECT_EQ(result.get_value(), bb::fr(expected_u256)); }; const auto check_field_element = [&normal_transcript, &recursive_transcript](const std::string& element_name) { field_t result = recursive_transcript.get_field_element(element_name); - barretenberg::fr expected = - barretenberg::fr::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); + bb::fr expected = bb::fr::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); EXPECT_EQ(result.get_value(), expected); }; const auto check_group_element = [&normal_transcript, &recursive_transcript](const std::string& element_name) { group_t recursive_value = recursive_transcript.get_circuit_group_element(element_name); - barretenberg::g1::affine_element expected = - barretenberg::g1::affine_element::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); - barretenberg::g1::affine_element result{ recursive_value.x.get_value().lo, recursive_value.y.get_value().lo }; + bb::g1::affine_element expected = + bb::g1::affine_element::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); + bb::g1::affine_element result{ recursive_value.x.get_value().lo, recursive_value.y.get_value().lo }; EXPECT_EQ(result, expected); }; const auto check_public_inputs = [&normal_transcript, &recursive_transcript]() { std::vector result = recursive_transcript.get_field_element_vector("public_inputs"); - std::vector expected = many_from_buffer(normal_transcript.get_element("public_inputs")); + std::vector expected = many_from_buffer(normal_transcript.get_element("public_inputs")); EXPECT_EQ(result.size(), expected.size()); for (size_t i = 0; i < result.size(); ++i) { EXPECT_EQ(result[i].get_value(), expected[i]); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp index 975a833037c..e59dc814481 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp @@ -40,12 +40,12 @@ template struct PedersenPreimageB field_pt hash() { // we can only use relaxed range checks in pedersen::compress iff bits_per_element < modulus bits - static_assert(bits_per_element < uint256_t(barretenberg::fr::modulus).get_msb()); + static_assert(bits_per_element < uint256_t(bb::fr::modulus).get_msb()); if (current_bit_counter != 0) { const uint256_t down_shift = uint256_t(1) << uint256_t((bits_per_element - current_bit_counter)); for (auto& x : work_element) { - x = x / barretenberg::fr(down_shift); + x = x / bb::fr(down_shift); } preimage_data.push_back(field_pt::accumulate(work_element)); } @@ -116,7 +116,7 @@ template struct PedersenPreimageB size_t new_bit_counter = current_bit_counter + num_bits; field_pt hi = element; const size_t leftovers = bits_per_element - new_bit_counter; - field_pt buffer_shift = field_pt(context, barretenberg::fr(uint256_t(1) << ((uint64_t)leftovers))); + field_pt buffer_shift = field_pt(context, bb::fr(uint256_t(1) << ((uint64_t)leftovers))); work_element.emplace_back(hi * buffer_shift); current_bit_counter = new_bit_counter; if (current_bit_counter == bits_per_element) { @@ -128,16 +128,16 @@ template struct PedersenPreimageB return; } const size_t lo_bits = num_bits - hi_bits; - field_pt lo = witness_t(context, barretenberg::fr(element_u256.slice(0, lo_bits))); - field_pt hi = witness_t(context, barretenberg::fr(element_u256.slice(lo_bits, 256))); + field_pt lo = witness_t(context, bb::fr(element_u256.slice(0, lo_bits))); + field_pt hi = witness_t(context, bb::fr(element_u256.slice(lo_bits, 256))); lo.create_range_constraint(lo_bits); hi.create_range_constraint(hi_bits); - field_pt shift(context, barretenberg::fr(uint256_t(1ULL) << static_cast(lo_bits))); + field_pt shift(context, bb::fr(uint256_t(1ULL) << static_cast(lo_bits))); if (!element.is_constant() || !lo.is_constant() || !hi.is_constant()) { lo.add_two(hi * shift, -element).assert_equal(0); } - constexpr uint256_t modulus = barretenberg::fr::modulus; + constexpr uint256_t modulus = bb::fr::modulus; constexpr size_t modulus_bits = modulus.get_msb(); // If our input is a full field element we must validate the sum of our slices is < p @@ -174,8 +174,7 @@ template struct PedersenPreimageB work_element.emplace_back(hi); preimage_data.push_back(field_pt::accumulate(work_element)); field_t lo_shift( - context, - barretenberg::fr(uint256_t(1ULL) << ((bits_per_element - static_cast(current_bit_counter))))); + context, bb::fr(uint256_t(1ULL) << ((bits_per_element - static_cast(current_bit_counter))))); work_element = std::vector(); work_element.emplace_back(lo * lo_shift); } @@ -197,7 +196,7 @@ template struct evaluation_domain { return domain; } - static evaluation_domain from_witness(Builder* ctx, const barretenberg::evaluation_domain& input) + static evaluation_domain from_witness(Builder* ctx, const bb::evaluation_domain& input) { evaluation_domain domain; domain.root = witness_t(ctx, input.root); @@ -210,7 +209,7 @@ template struct evaluation_domain { return domain; } - static evaluation_domain from_constants(Builder* ctx, const barretenberg::evaluation_domain& input) + static evaluation_domain from_constants(Builder* ctx, const bb::evaluation_domain& input) { evaluation_domain domain; domain.root = field_t(ctx, input.root); @@ -293,7 +292,7 @@ template struct verification_key { key->polynomial_manifest = input_key->polynomial_manifest; // Circuit types: - key->n = witness_t(ctx, barretenberg::fr(input_key->circuit_size)); + key->n = witness_t(ctx, bb::fr(input_key->circuit_size)); key->num_public_inputs = witness_t(ctx, input_key->num_public_inputs); key->domain = evaluation_domain::from_witness(ctx, input_key->domain); key->contains_recursive_proof = input_key->contains_recursive_proof; @@ -343,7 +342,7 @@ template struct verification_key { field_t key_index(witness_t(context, 0)); std::vector> compressed_keys; for (size_t i = 0; i < keys_in_set.size(); ++i) { - barretenberg::fr compressed = hash_native(keys_in_set[i]); + bb::fr compressed = hash_native(keys_in_set[i]); compressed_keys.emplace_back(compressed); if (compressed == circuit_key_compressed.get_value()) { key_index = witness_t(context, i); @@ -361,7 +360,7 @@ template struct verification_key { } else { bool_t is_valid(false); for (const auto& key : keys_in_set) { - barretenberg::fr compressed = hash_native(key); + bb::fr compressed = hash_native(key); is_valid = is_valid || (circuit_key_compressed == compressed); } @@ -402,8 +401,7 @@ template struct verification_key { return hashed_key; } - static barretenberg::fr hash_native(const std::shared_ptr& key, - const size_t hash_index = 0) + static bb::fr hash_native(const std::shared_ptr& key, const size_t hash_index = 0) { std::vector preimage_data; @@ -441,7 +439,7 @@ template struct verification_key { // Native data: - std::shared_ptr> reference_string; + std::shared_ptr> reference_string; PolynomialManifest polynomial_manifest; // Used to check in the circuit if a proof contains any aggregated state. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp index 351c7364eca..019bc0cd006 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp @@ -23,7 +23,7 @@ template class VerificationKeyFixture : public testing::Test using Curve = proof_system::plonk::stdlib::bn254; using RecursVk = proof_system::plonk::stdlib::recursion::verification_key; - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } /** * @brief generate a random vk data for use in tests @@ -55,7 +55,7 @@ TYPED_TEST(VerificationKeyFixture, VkDataVsRecursionHashNative) verification_key_data vk_data = TestFixture::rand_vk_data(); verification_key_data vk_data_copy = vk_data; - auto file_crs = std::make_unique>("../srs_db/ignition"); + auto file_crs = std::make_unique>("../srs_db/ignition"); auto file_verifier = file_crs->get_verifier_crs(); auto native_vk = std::make_shared(std::move(vk_data_copy), file_verifier); @@ -75,7 +75,7 @@ TYPED_TEST(VerificationKeyFixture, HashVsHashNative) verification_key_data vk_data = TestFixture::rand_vk_data(); - auto file_crs = std::make_unique>("../srs_db/ignition"); + auto file_crs = std::make_unique>("../srs_db/ignition"); auto file_verifier = file_crs->get_verifier_crs(); auto native_vk = std::make_shared(std::move(vk_data), file_verifier); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp index 8f176122105..cea520713a9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp @@ -36,7 +36,7 @@ template class stdlib_verifier : public testing::Test { using inner_scalar_field = typename inner_curve::ScalarFieldNative; using outer_scalar_field = typename outer_curve::BaseFieldNative; - using pairing_target_field = barretenberg::fq12; + using pairing_target_field = bb::fq12; // These constexpr definitions are to allow for the following: An Ultra Pedersen hash evaluates to a // different value from the Standard version of the Pedersen hash. Therefore, the fiat-shamir @@ -282,8 +282,7 @@ template class stdlib_verifier : public testing::Test { * @return boolean result */ - static bool check_recursive_proof_public_inputs(OuterBuilder& builder, - const barretenberg::pairing::miller_lines* lines) + static bool check_recursive_proof_public_inputs(OuterBuilder& builder, const bb::pairing::miller_lines* lines) { if (builder.contains_recursive_proof && builder.recursive_proof_public_input_indices.size() == 16) { const auto& inputs = builder.public_inputs; @@ -321,8 +320,7 @@ template class stdlib_verifier : public testing::Test { { x1, y1 }, }; - pairing_target_field result = - barretenberg::pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); + pairing_target_field result = bb::pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); return (result == pairing_target_field::one()); } @@ -334,14 +332,13 @@ template class stdlib_verifier : public testing::Test { static void check_pairing(const circuit_outputs& circuit_output) { - auto g2_lines = barretenberg::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); g1::affine_element P[2]; P[0].x = outer_scalar_field(circuit_output.aggregation_state.P0.x.get_value().lo); P[0].y = outer_scalar_field(circuit_output.aggregation_state.P0.y.get_value().lo); P[1].x = outer_scalar_field(circuit_output.aggregation_state.P1.x.get_value().lo); P[1].y = outer_scalar_field(circuit_output.aggregation_state.P1.y.get_value().lo); - pairing_target_field inner_proof_result = - barretenberg::pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); + pairing_target_field inner_proof_result = bb::pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); EXPECT_EQ(inner_proof_result, pairing_target_field::one()); } @@ -350,12 +347,12 @@ template class stdlib_verifier : public testing::Test { info("number of gates in recursive verification circuit = ", outer_circuit.get_num_gates()); bool result = outer_circuit.check_circuit(); EXPECT_EQ(result, expected_result); - auto g2_lines = barretenberg::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); EXPECT_EQ(check_recursive_proof_public_inputs(outer_circuit, g2_lines), true); } public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } static void test_inner_circuit() { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp b/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp index b758ba1fbb9..a4c199d01ab 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp @@ -45,8 +45,8 @@ using uint16_ct = stdlib::uint16; using uint32_ct = stdlib::uint32; using uint64_ct = stdlib::uint64; using bit_array_ct = stdlib::bit_array; -using fq_ct = stdlib::bigfield; -using biggroup_ct = stdlib::element; +using fq_ct = stdlib::bigfield; +using biggroup_ct = stdlib::element; using pedersen_commitment = stdlib::pedersen_commitment; using cycle_group_ct = stdlib::cycle_group; using bn254 = stdlib::bn254; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp index 451ef2c8e97..9e44f205c46 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp @@ -25,12 +25,12 @@ namespace proof_system::plonk::stdlib::recursion::utility { */ template class StdlibTypesUtility { using field_ct = field_t; - using fq_ct = bigfield; - using element_ct = element; - using FF = barretenberg::fr; - using Commitment = barretenberg::g1::affine_element; - template using Univariate = barretenberg::Univariate; - template using Univariate_ct = barretenberg::Univariate; + using fq_ct = bigfield; + using element_ct = element; + using FF = bb::fr; + using Commitment = bb::g1::affine_element; + template using Univariate = bb::Univariate; + template using Univariate_ct = bb::Univariate; public: /** diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp index 8c5e91b2e23..cde5de07b30 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp @@ -102,7 +102,7 @@ template class ProverInstance_ { void construct_databus_polynomials(Circuit&) requires IsGoblinFlavor; - void add_table_column_selector_poly_to_proving_key(barretenberg::polynomial& small, const std::string& tag); + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); void add_plookup_memory_records_to_wire_4(FF); }; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp index 6fb7eeab3ed..d6f7dd1a57f 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp @@ -11,7 +11,7 @@ namespace instance_tests { template class InstanceTests : public testing::Test { using FF = typename Flavor::FF; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using Builder = typename Flavor::CircuitBuilder; public: diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp index 9971f0447ea..df110ef178d 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp @@ -88,7 +88,7 @@ template class SumcheckProver { const std::vector& gate_challenges) { - barretenberg::PowPolynomial pow_univariate(gate_challenges); + bb::PowPolynomial pow_univariate(gate_challenges); pow_univariate.compute_values(); std::vector multivariate_challenge; @@ -174,7 +174,7 @@ template class SumcheckProver { template class SumcheckVerifier { public: - using Utils = barretenberg::RelationUtils; + using Utils = bb::RelationUtils; using FF = typename Flavor::FF; using ClaimedEvaluations = typename Flavor::AllValues; using Transcript = typename Flavor::Transcript; @@ -208,7 +208,7 @@ template class SumcheckVerifier { { bool verified(true); - barretenberg::PowPolynomial pow_univariate(gate_challenges); + bb::PowPolynomial pow_univariate(gate_challenges); // All but final round. // target_total_sum is initialized to zero then mutated in place. @@ -223,7 +223,7 @@ template class SumcheckVerifier { // Obtain the round univariate from the transcript std::string round_univariate_label = "Sumcheck:univariate_" + std::to_string(round_idx); auto round_univariate = - transcript->template receive_from_prover>( + transcript->template receive_from_prover>( round_univariate_label); bool checked = round.check_sum(round_univariate); diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 6f83fbdd2e6..00dfabe6b49 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -22,9 +22,9 @@ const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; namespace test_sumcheck_round { -barretenberg::Polynomial random_poly(size_t size) +bb::Polynomial random_poly(size_t size) { - auto poly = barretenberg::Polynomial(size); + auto poly = bb::Polynomial(size); for (auto& coeff : poly) { coeff = FF::random_element(); } @@ -42,7 +42,7 @@ ProverPolynomials construct_ultra_full_polynomials(auto& input_polynomials) class SumcheckTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; TEST_F(SumcheckTests, PolynomialNormalization) @@ -53,7 +53,7 @@ TEST_F(SumcheckTests, PolynomialNormalization) // Randomly construct the prover polynomials that are input to Sumcheck. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = random_poly(multivariate_n); } @@ -116,7 +116,7 @@ TEST_F(SumcheckTests, PolynomialNormalization) // full polynomials at challenge u via the evaluate_mle() function std::vector u_challenge = { u_0, u_1, u_2 }; for (auto [full_poly, claimed_eval] : zip_view(full_polynomials.get_all(), output.claimed_evaluations.get_all())) { - barretenberg::Polynomial poly(full_poly); + bb::Polynomial poly(full_poly); auto v_expected = poly.evaluate_mle(u_challenge); EXPECT_EQ(v_expected, claimed_eval); } @@ -129,7 +129,7 @@ TEST_F(SumcheckTests, Prover) // Randomly construct the prover polynomials that are input to Sumcheck. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = random_poly(multivariate_n); } @@ -176,9 +176,9 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) // Construct prover polynomials where each is the zero polynomial. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> zero_polynomials; + std::array, NUM_POLYNOMIALS> zero_polynomials; for (auto& poly : zero_polynomials) { - poly = barretenberg::Polynomial(multivariate_n); + poly = bb::Polynomial(multivariate_n); } auto full_polynomials = construct_ultra_full_polynomials(zero_polynomials); diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 0d6bc37092c..fac33a1e47c 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -52,7 +52,7 @@ namespace proof_system::honk::sumcheck { template class SumcheckProverRound { - using Utils = barretenberg::RelationUtils; + using Utils = bb::RelationUtils; using Relations = typename Flavor::Relations; using SumcheckTupleOfTuplesOfUnivariates = typename Flavor::SumcheckTupleOfTuplesOfUnivariates; using RelationSeparator = typename Flavor::RelationSeparator; @@ -90,7 +90,7 @@ template class SumcheckProverRound { size_t edge_idx) { for (auto [extended_edge, multivariate] : zip_view(extended_edges.get_all(), multivariates.get_all())) { - barretenberg::Univariate edge({ multivariate[edge_idx], multivariate[edge_idx + 1] }); + bb::Univariate edge({ multivariate[edge_idx], multivariate[edge_idx + 1] }); extended_edge = edge.template extend_to(); } } @@ -101,10 +101,10 @@ template class SumcheckProverRound { * univariate accumulators to be zero. */ template - barretenberg::Univariate compute_univariate( + bb::Univariate compute_univariate( ProverPolynomialsOrPartiallyEvaluatedMultivariates& polynomials, const proof_system::RelationParameters& relation_parameters, - const barretenberg::PowPolynomial& pow_polynomial, + const bb::PowPolynomial& pow_polynomial, const RelationSeparator alpha) { // Compute the constant contribution of pow polynomials for each edge. This is the product of the partial @@ -121,8 +121,7 @@ template class SumcheckProverRound { // on a specified minimum number of iterations per thread. This eventually leads to the use of a single thread. // For now we use a power of 2 number of threads simply to ensure the round size is evenly divided. size_t min_iterations_per_thread = 1 << 6; // min number of iterations for which we'll spin up a unique thread - size_t num_threads = - barretenberg::thread_utils::calculate_num_threads_pow2(round_size, min_iterations_per_thread); + size_t num_threads = bb::thread_utils::calculate_num_threads_pow2(round_size, min_iterations_per_thread); size_t iterations_per_thread = round_size / num_threads; // actual iterations per thread // Construct univariate accumulator containers; one per thread @@ -158,7 +157,7 @@ template class SumcheckProverRound { } // Batch the univariate contributions from each sub-relation to obtain the round univariate - return batch_over_relations>( + return batch_over_relations>( univariate_accumulators, alpha, pow_polynomial); } @@ -169,7 +168,7 @@ template class SumcheckProverRound { template static ExtendedUnivariate batch_over_relations(ContainerOverSubrelations& univariate_accumulators, const RelationSeparator& challenge, - const barretenberg::PowPolynomial& pow_polynomial) + const bb::PowPolynomial& pow_polynomial) { auto running_challenge = FF(1); Utils::scale_univariates(univariate_accumulators, challenge, running_challenge); @@ -193,11 +192,11 @@ template class SumcheckProverRound { template static void extend_and_batch_univariates(const TupleOfTuplesOfUnivariates& tuple, ExtendedUnivariate& result, - const barretenberg::PowPolynomial& pow_polynomial) + const bb::PowPolynomial& pow_polynomial) { ExtendedUnivariate extended_random_polynomial; // Random poly R(X) = (1-X) + X.zeta_pow - auto random_polynomial = barretenberg::Univariate({ 1, pow_polynomial.current_element() }); + auto random_polynomial = bb::Univariate({ 1, pow_polynomial.current_element() }); extended_random_polynomial = random_polynomial.template extend_to(); auto extend_and_sum = [&](Element& element) { @@ -253,7 +252,7 @@ template class SumcheckProverRound { }; template class SumcheckVerifierRound { - using Utils = barretenberg::RelationUtils; + using Utils = bb::RelationUtils; using Relations = typename Flavor::Relations; using TupleOfArraysOfValues = typename Flavor::TupleOfArraysOfValues; using RelationSeparator = typename Flavor::RelationSeparator; @@ -278,7 +277,7 @@ template class SumcheckVerifierRound { Utils::zero_elements(relation_evaluations); }; - bool check_sum(barretenberg::Univariate& univariate) + bool check_sum(bb::Univariate& univariate) { // S^{l}(0) = ( (1−0) + 0⋅ζ^{ 2^l } ) ⋅ T^{l}(0) = T^{l}(0) // S^{l}(1) = ( (1−1) + 1⋅ζ^{ 2^l } ) ⋅ T^{l}(1) = ζ^{ 2^l } ⋅ T^{l}(1) @@ -306,8 +305,7 @@ template class SumcheckVerifierRound { * @param round_challenge u_l * @return FF sigma_{l+1} = S^l(u_l) */ - FF compute_next_target_sum(barretenberg::Univariate& univariate, - FF& round_challenge) + FF compute_next_target_sum(bb::Univariate& univariate, FF& round_challenge) { // Evaluate T^{l}(u_{l}) target_total_sum = univariate.evaluate(round_challenge); @@ -325,7 +323,7 @@ template class SumcheckVerifierRound { // kill the pow_univariat FF compute_full_honk_relation_purported_value(ClaimedEvaluations purported_evaluations, const proof_system::RelationParameters& relation_parameters, - const barretenberg::PowPolynomial& pow_polynomial, + const bb::PowPolynomial& pow_polynomial, const RelationSeparator alpha) { Utils::template accumulate_relation_evaluations<>( diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index c2e62341a53..af1f4a78f4c 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -7,12 +7,12 @@ using namespace proof_system::honk; using namespace proof_system::honk::sumcheck; -using barretenberg::BarycentricData; -using barretenberg::Univariate; +using bb::BarycentricData; +using bb::Univariate; using Flavor = flavor::Ultra; using FF = typename Flavor::FF; -using Utils = barretenberg::RelationUtils; +using Utils = bb::RelationUtils; namespace test_sumcheck_round { @@ -43,7 +43,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) Utils::scale_univariates(tuple_of_tuples, challenge, running_challenge); // Use extend_and_batch_univariates to extend to MAX_LENGTH then accumulate - barretenberg::PowPolynomial pow_polynomial({ 1 }); + bb::PowPolynomial pow_polynomial({ 1 }); auto result = Univariate(); SumcheckProverRound::extend_and_batch_univariates(tuple_of_tuples, result, pow_polynomial); @@ -74,7 +74,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) TEST(SumcheckRound, TuplesOfEvaluationArrays) { using Flavor = proof_system::honk::flavor::Ultra; - using Utils = barretenberg::RelationUtils; + using Utils = bb::RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index e734829460c..a809c4b801f 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -10,9 +10,9 @@ namespace proof_system::honk { template -concept Loggable = (std::same_as || std::same_as || - std::same_as || - std::same_as || std::same_as); +concept Loggable = (std::same_as || std::same_as || + std::same_as || std::same_as || + std::same_as); // class TranscriptManifest; class TranscriptManifest { diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index 2f140e4b69a..5a22fd4fe02 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -1,11 +1,11 @@ #include "barretenberg/transcript/transcript.hpp" #include -namespace barretenberg::honk_transcript_tests { +namespace bb::honk_transcript_tests { -using FF = barretenberg::fr; -using Fr = barretenberg::fr; -using Fq = barretenberg::fq; +using FF = bb::fr; +using Fr = bb::fr; +using Fq = bb::fq; using Transcript = proof_system::honk::BaseTranscript; /** @@ -48,4 +48,4 @@ TEST(BaseTranscript, TwoProversTwoFields) EXPECT_EQ(received_b, elt_b); } -} // namespace barretenberg::honk_transcript_tests +} // namespace bb::honk_transcript_tests 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..4f8aa24410e 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -28,7 +28,7 @@ class GoblinTranslatorComposer { std::shared_ptr verification_key; // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; + std::shared_ptr> crs_factory_; // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; @@ -39,7 +39,7 @@ class GoblinTranslatorComposer { size_t mini_circuit_dyadic_size = 0; // The size of the small circuit that contains non-range constraint relations // We only need the standard crs factory. GoblinTranslator is not supposed to be used with Grumpkin - GoblinTranslatorComposer() { crs_factory_ = barretenberg::srs::get_crs_factory(); } + GoblinTranslatorComposer() { crs_factory_ = bb::srs::get_crs_factory(); } GoblinTranslatorComposer(std::shared_ptr p_key, std::shared_ptr v_key) : proving_key(std::move(p_key)) 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..6c766285f15 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 @@ -19,7 +19,7 @@ namespace { auto& engine = numeric::random::get_debug_engine(); } -std::vector add_variables(auto& circuit_constructor, std::vector variables) +std::vector add_variables(auto& circuit_constructor, std::vector variables) { std::vector res; for (size_t i = 0; i < variables.size(); i++) { @@ -39,7 +39,7 @@ void ensure_non_zero(auto& polynomial) class GoblinTranslatorComposerTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; /** @@ -48,9 +48,9 @@ class GoblinTranslatorComposerTests : public ::testing::Test { */ TEST_F(GoblinTranslatorComposerTests, Basic) { - using G1 = barretenberg::g1::affine_element; - using Fr = barretenberg::fr; - using Fq = barretenberg::fq; + using G1 = bb::g1::affine_element; + using Fr = bb::fr; + using Fq = bb::fq; auto P1 = G1::random_element(); auto P2 = G1::random_element(); 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..406e94190e9 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -3,7 +3,7 @@ #include "barretenberg/sumcheck/sumcheck.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::honk::sumcheck; namespace proof_system::honk { 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..44120b73e34 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp @@ -12,7 +12,7 @@ class GoblinTranslatorVerifier { using Commitment = typename Flavor::Commitment; using VerificationKey = typename Flavor::VerificationKey; using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; - using TranslationEvaluations = barretenberg::TranslationEvaluations; + using TranslationEvaluations = bb::TranslationEvaluations; using Transcript = typename Flavor::Transcript; BF evaluation_input_x = 0; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp index e9adb253f0c..de6377f3ebe 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -20,7 +20,7 @@ auto& engine = numeric::random::get_debug_engine(); class DataBusComposerTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } using Curve = curve::BN254; using FF = Curve::ScalarField; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index 52bc8aa9a03..23941c0b1bb 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -18,7 +18,7 @@ auto& engine = numeric::random::get_debug_engine(); class GoblinUltraHonkComposerTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } using Curve = curve::BN254; using FF = Curve::ScalarField; @@ -204,7 +204,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) // Compute the commitments to the aggregate op queue directly and check that they match those that were computed // iteratively during transcript aggregation by the provers and stored in the op queue. size_t aggregate_op_queue_size = op_queue->current_ultra_ops_size; - auto crs_factory = std::make_shared>("../srs_db/ignition"); + auto crs_factory = std::make_shared>("../srs_db/ignition"); auto commitment_key = std::make_shared(aggregate_op_queue_size, crs_factory); size_t idx = 0; for (auto& result : op_queue->ultra_ops_commitments) { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 5f7cc775fbf..5d2b327d065 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -10,7 +10,7 @@ using namespace proof_system::honk; class GoblinUltraTranscriptTests : public ::testing::Test { public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } using Flavor = proof_system::honk::flavor::GoblinUltra; using FF = Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index ebf18518afa..a0788340ec7 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -5,7 +5,7 @@ namespace proof_system::honk { template MergeVerifier_::MergeVerifier_() : transcript(std::make_shared()) - , pcs_verification_key(std::make_unique(0, barretenberg::srs::get_crs_factory())){}; + , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())){}; /** * @brief Verify proper construction of the aggregate Goblin ECC op queue polynomials T_i^(j), j = 1,2,3,4. diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index f2f14ab43b4..5eb362767fb 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -19,19 +19,19 @@ using ProverPolynomials = Flavor::ProverPolynomials; using RelationParameters = proof_system::RelationParameters; using WitnessCommitments = typename Flavor::WitnessCommitments; using CommitmentKey = Flavor::CommitmentKey; -using PowPolynomial = barretenberg::PowPolynomial; +using PowPolynomial = bb::PowPolynomial; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; -namespace barretenberg::protogalaxy_tests { +namespace bb::protogalaxy_tests { namespace { auto& engine = numeric::random::get_debug_engine(); } // TODO(https://github.com/AztecProtocol/barretenberg/issues/744): make testing utility with functionality shared // amongst test files in the proof system -barretenberg::Polynomial get_random_polynomial(size_t size) +bb::Polynomial get_random_polynomial(size_t size) { - auto poly = barretenberg::Polynomial(size); + auto poly = bb::Polynomial(size); for (auto& coeff : poly) { coeff = FF::random_element(); } @@ -89,7 +89,7 @@ void decide_and_verify(std::shared_ptr& accumulator, UltraComposer& co class ProtoGalaxyTests : public ::testing::Test { public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; TEST_F(ProtoGalaxyTests, FullHonkEvaluationsValidCircuit) @@ -144,7 +144,7 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) const size_t log_instance_size(3); const size_t instance_size(1 << log_instance_size); - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = get_random_polynomial(instance_size); } @@ -189,13 +189,12 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) TEST_F(ProtoGalaxyTests, CombinerQuotient) { auto compressed_perturbator = FF(2); // F(\alpha) in the paper - auto combiner = - barretenberg::Univariate(std::array{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }); + auto combiner = bb::Univariate(std::array{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }); auto combiner_quotient = ProtoGalaxyProver::compute_combiner_quotient(compressed_perturbator, combiner); // K(i) = (G(i) - ( L_0(i) * F(\alpha)) / Z(i), i = {2,.., 13} for ProverInstances::NUM = 2 // K(i) = (G(i) - (1 - i) * F(\alpha)) / i * (i - 1) - auto expected_evals = barretenberg::Univariate(std::array{ + auto expected_evals = bb::Univariate(std::array{ (FF(22) - (FF(1) - FF(2)) * compressed_perturbator) / (FF(2) * FF(2 - 1)), (FF(23) - (FF(1) - FF(3)) * compressed_perturbator) / (FF(3) * FF(3 - 1)), (FF(24) - (FF(1) - FF(4)) * compressed_perturbator) / (FF(4) * FF(4 - 1)), @@ -349,4 +348,4 @@ TEST_F(ProtoGalaxyTests, TamperedAccumulatorPolynomial) decide_and_verify(second_accumulator, composer, false); } -} // namespace barretenberg::protogalaxy_tests \ No newline at end of file +} // namespace bb::protogalaxy_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index 5cc43dad5fc..ee4f7a754fb 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -237,7 +237,7 @@ template void create_some_ecc_op_queue_gates(auto& circuit_bui class RelationCorrectnessTests : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; /** @@ -376,7 +376,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) using Flavor = flavor::GoblinTranslator; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; using namespace proof_system::honk::permutation_library; auto& engine = numeric::random::get_debug_engine(); auto circuit_size = Flavor::MINI_CIRCUIT_SIZE * Flavor::CONCATENATION_INDEX; @@ -494,7 +494,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) using Flavor = flavor::GoblinTranslator; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; auto& engine = numeric::random::get_debug_engine(); const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; @@ -575,7 +575,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; auto& engine = numeric::random::get_debug_engine(); @@ -678,7 +678,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes using BF = typename Flavor::BF; using ProverPolynomials = typename Flavor::ProverPolynomials; using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; auto& engine = numeric::random::get_debug_engine(); auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; @@ -1052,7 +1052,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) using ProverPolynomials = typename Flavor::ProverPolynomials; using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; using GroupElement = typename Flavor::GroupElement; - using Polynomial = barretenberg::Polynomial; + using Polynomial = bb::Polynomial; constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index 09815ab23c8..f26c426aa6f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -24,7 +24,7 @@ namespace test_sumcheck_round { class SumcheckTestsRealCircuit : public ::testing::Test { protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 460e301afea..37110a3b657 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -41,7 +41,7 @@ template class UltraComposer_ { // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; - UltraComposer_() { crs_factory_ = barretenberg::srs::get_crs_factory(); } + UltraComposer_() { crs_factory_ = bb::srs::get_crs_factory(); } explicit UltraComposer_(std::shared_ptr crs_factory) : crs_factory_(std::move(crs_factory)) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 0f1e0e274a8..2d20c530f85 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -24,7 +24,7 @@ namespace { auto& engine = numeric::random::get_debug_engine(); } -std::vector add_variables(auto& circuit_builder, std::vector variables) +std::vector add_variables(auto& circuit_builder, std::vector variables) { std::vector res; for (size_t i = 0; i < variables.size(); i++) { @@ -54,10 +54,10 @@ void ensure_non_zero(auto& polynomial) class UltraHonkComposerTests : public ::testing::Test { public: - using fr = barretenberg::fr; + using fr = bb::fr; protected: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; /** @@ -142,7 +142,7 @@ TEST_F(UltraHonkComposerTests, XorConstraint) circuit_builder.create_gates_from_plookup_accumulators( plookup::MultiTableId::UINT32_XOR, lookup_accumulators, left_witness_index, right_witness_index); - auto composer = UltraComposer(barretenberg::srs::get_crs_factory()); + auto composer = UltraComposer(bb::srs::get_crs_factory()); prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } @@ -150,7 +150,7 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) { auto circuit_builder = proof_system::UltraCircuitBuilder(); - barretenberg::fr input_value = fr::random_element(); + bb::fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -671,7 +671,7 @@ TEST_F(UltraHonkComposerTests, composed_range_constraint) TEST_F(UltraHonkComposerTests, non_native_field_multiplication) { - using fq = barretenberg::fq; + using fq = bb::fq; auto circuit_builder = proof_system::UltraCircuitBuilder(); fq a = fq::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 6e8b19a0891..6a4c689de2b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -10,7 +10,7 @@ using namespace proof_system::honk; class UltraTranscriptTests : public ::testing::Test { public: - static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } using Flavor = proof_system::honk::flavor::Ultra; using FF = Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 637806709e8..3ed94a01607 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -3,7 +3,7 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::honk::sumcheck; namespace proof_system::honk { @@ -23,7 +23,7 @@ UltraVerifier_::UltraVerifier_(const std::shared_ptr& transc template UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) : key(verifier_key) - , pcs_verification_key(std::make_unique(0, barretenberg::srs::get_crs_factory())) + , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) , transcript(std::make_shared()) {} diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp index b925d5e01c2..8d18b0a354b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp @@ -5,7 +5,7 @@ using Flavor = proof_system::honk::flavor::AvmMiniFlavor; using FF = Flavor::FF; -using Row = proof_system::AvmMiniFullRow; +using Row = proof_system::AvmMiniFullRow; namespace avm_trace { diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp index f9458a7389d..ccb2c16fbc1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp @@ -28,7 +28,7 @@ class AvmMiniComposer { std::shared_ptr verification_key; // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; + std::shared_ptr> crs_factory_; // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; @@ -37,7 +37,7 @@ class AvmMiniComposer { bool contains_recursive_proof = false; bool computed_witness = false; - AvmMiniComposer() { crs_factory_ = barretenberg::srs::get_crs_factory(); } + AvmMiniComposer() { crs_factory_ = bb::srs::get_crs_factory(); } AvmMiniComposer(std::shared_ptr p_key, std::shared_ptr v_key) : proving_key(std::move(p_key)) @@ -58,7 +58,7 @@ class AvmMiniComposer { AvmMiniProver create_prover(CircuitConstructor& circuit_constructor); AvmMiniVerifier create_verifier(CircuitConstructor& circuit_constructor); - void add_table_column_selector_poly_to_proving_key(barretenberg::polynomial& small, const std::string& tag); + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); void compute_commitment_key(size_t circuit_size) { diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 157e4a8bc0d..8a3d126e37e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -5,7 +5,7 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::honk::sumcheck; namespace proof_system::honk { diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp index ad7877b7073..5c6cb453508 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp @@ -28,7 +28,7 @@ class ToyComposer { std::shared_ptr verification_key; // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; + std::shared_ptr> crs_factory_; // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; @@ -37,7 +37,7 @@ class ToyComposer { bool contains_recursive_proof = false; bool computed_witness = false; - ToyComposer() { crs_factory_ = barretenberg::srs::get_crs_factory(); } + ToyComposer() { crs_factory_ = bb::srs::get_crs_factory(); } ToyComposer(std::shared_ptr p_key, std::shared_ptr v_key) : proving_key(std::move(p_key)) @@ -58,7 +58,7 @@ class ToyComposer { ToyProver create_prover(CircuitConstructor& circuit_constructor); ToyVerifier create_verifier(CircuitConstructor& circuit_constructor); - void add_table_column_selector_poly_to_proving_key(barretenberg::polynomial& small, const std::string& tag); + void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag); void compute_commitment_key(size_t circuit_size) { diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp index 6fac55b463c..65b389eaede 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp @@ -5,7 +5,7 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace barretenberg; +using namespace bb; using namespace proof_system::honk::sumcheck; namespace proof_system::honk { diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp index c8f61b2dc59..46ed56f37f3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp @@ -21,7 +21,7 @@ class AvmMiniArithmeticTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp index 36673853057..eba7e312f21 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp @@ -21,7 +21,7 @@ class AvmMiniControlFlowTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp index e3798357e15..79a3b03c96a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp @@ -21,7 +21,7 @@ class AvmMiniMemoryTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - barretenberg::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; diff --git a/barretenberg/ts/src/bindgen/mappings.ts b/barretenberg/ts/src/bindgen/mappings.ts index 2b6c2ffa6df..834a3c0fe88 100644 --- a/barretenberg/ts/src/bindgen/mappings.ts +++ b/barretenberg/ts/src/bindgen/mappings.ts @@ -2,8 +2,8 @@ const typeMap: { [key: string]: string } = { in_ptr: 'Ptr', out_ptr: 'Ptr', - 'barretenberg::fr::in_buf': 'Fr', - 'barretenberg::fr::vec_in_buf': 'Fr[]', + 'bb::fr::in_buf': 'Fr', + 'bb::fr::vec_in_buf': 'Fr[]', 'fr::in_buf': 'Fr', 'fr::out_buf': 'Fr', 'fr::vec_in_buf': 'Fr[]',