Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(bb): rearrange namespaces #4147

Merged
merged 53 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7286f87
refactor: proof_system=>bb
ludamad0 Jan 18, 2024
3329c32
refactor: plonk::stdlib => stdlib
ludamad0 Jan 18, 2024
751d6e3
remove redundant lines
ludamad0 Jan 18, 2024
e01edd7
refactor: more deplonking
ludamad0 Jan 18, 2024
eaeaa8f
Flatten namespaces
ludamad0 Jan 18, 2024
e1a4dd8
fix: fuzzing
ludamad0 Jan 18, 2024
87751ec
More condensing namespaces
ludamad0 Jan 18, 2024
87c60ad
More condensing namespaces
ludamad0 Jan 18, 2024
711ede0
shortening
ludamad0 Jan 18, 2024
55b16ca
namespace standardization
ludamad0 Jan 18, 2024
2f1f0ad
plookup in bb
ludamad0 Jan 19, 2024
9d292f1
crypto as bb::crypto
ludamad0 Jan 19, 2024
673be48
remove test namespaces
ludamad0 Jan 19, 2024
96822cd
Test namespace removal
ludamad0 Jan 19, 2024
7316725
Test namespace removal
ludamad0 Jan 19, 2024
3377abe
acir namespace simplification
ludamad0 Jan 19, 2024
25ccd58
acir namespace simplification
ludamad0 Jan 19, 2024
492c028
acir namespace simplification
ludamad0 Jan 19, 2024
df92cc0
remove rest of test namespaces
ludamad0 Jan 19, 2024
e3492fa
numeric namespace passes
ludamad0 Jan 19, 2024
89044d3
numeric namespace passes
ludamad0 Jan 19, 2024
5cf65f7
numeric namespace passes
ludamad0 Jan 19, 2024
d614a79
namespace randomness simplification
ludamad0 Jan 19, 2024
f10f22f
blake2s namespace gone
ludamad0 Jan 19, 2024
7a71095
Missing files
ludamad0 Jan 19, 2024
7d22216
ecdsa prefix
ludamad0 Jan 19, 2024
e5863c7
namespace simplification
ludamad0 Jan 19, 2024
aaf29f9
ecdsa namespace gone
ludamad0 Jan 19, 2024
1242848
schnorr prefix
ludamad0 Jan 19, 2024
9936ba6
schnorr namespace gone
ludamad0 Jan 19, 2024
8d66268
fix: builder
ludamad0 Jan 22, 2024
f70ff6c
fix typed test
ludamad0 Jan 22, 2024
03fca1a
Merge commit '14d39edbe1a6753849581a664184d4e98baf923d' into ad/refac…
ludamad0 Jan 22, 2024
431bb6a
Fix join split
ludamad Jan 22, 2024
7d74e64
Fix join split
ludamad Jan 22, 2024
1ead4a9
Fix join spliut
ludamad Jan 22, 2024
2b104ec
fix schnorr forward declares
ludamad Jan 22, 2024
b95b435
fix: build
ludamad0 Jan 22, 2024
9a36398
fix: build
ludamad0 Jan 22, 2024
eb25f5f
Standardize tests
ludamad0 Jan 22, 2024
6cda77c
fix: build
ludamad0 Jan 22, 2024
6e0acb2
Remove bb:: prefixes in tests
ludamad0 Jan 22, 2024
cf41943
build fix
ludamad0 Jan 22, 2024
78823cb
fix: fuzzer
ludamad0 Jan 22, 2024
a33236d
Merge remote-tracking branch 'origin/master' into ad/refactor/bb/flatten
ludamad0 Jan 22, 2024
94756a7
post-merge fixes
ludamad0 Jan 22, 2024
eebb62e
fix: small fix
ludamad0 Jan 22, 2024
415af1e
fix: revert helpers.test.*
ludamad0 Jan 22, 2024
4002336
fix: revert helpers.test.*
ludamad0 Jan 22, 2024
cfc6295
More namespace cleanup
ludamad0 Jan 23, 2024
d93a4fe
array utilities in bb
ludamad0 Jan 23, 2024
8cc49aa
Merge remote-tracking branch 'origin/master' into ad/refactor/bb/flatten
ludamad0 Jan 23, 2024
506d45e
Fix merge
ludamad0 Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "get_bn254_crs.hpp"
#include "barretenberg/bb/file_io.hpp"

namespace {
std::vector<uint8_t> download_bn254_g1_data(size_t num_points)
{
size_t g1_end = num_points * 64 - 1;
Expand All @@ -26,8 +27,10 @@ std::vector<uint8_t> download_bn254_g2_data()
std::string command = "curl -s '" + url + "'";
return exec_pipe(command);
}
} // namespace

std::vector<bb::g1::affine_element> get_bn254_g1_data(const std::filesystem::path& path, size_t num_points)
namespace bb {
std::vector<g1::affine_element> get_bn254_g1_data(const std::filesystem::path& path, size_t num_points)
{
std::filesystem::create_directories(path);

Expand All @@ -37,9 +40,9 @@ std::vector<bb::g1::affine_element> get_bn254_g1_data(const std::filesystem::pat
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<bb::g1::affine_element>(num_points);
auto points = std::vector<g1::affine_element>(num_points);
for (size_t i = 0; i < num_points; ++i) {
points[i] = from_buffer<bb::g1::affine_element>(data, i * 64);
points[i] = from_buffer<g1::affine_element>(data, i * 64);
}
return points;
}
Expand All @@ -48,14 +51,14 @@ std::vector<bb::g1::affine_element> get_bn254_g1_data(const std::filesystem::pat
auto data = download_bn254_g1_data(num_points);
write_file(g1_path, data);

auto points = std::vector<bb::g1::affine_element>(num_points);
auto points = std::vector<g1::affine_element>(num_points);
for (size_t i = 0; i < num_points; ++i) {
points[i] = from_buffer<bb::g1::affine_element>(data, i * 64);
points[i] = from_buffer<g1::affine_element>(data, i * 64);
}
return points;
}

bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path)
g2::affine_element get_bn254_g2_data(const std::filesystem::path& path)
{
std::filesystem::create_directories(path);

Expand All @@ -64,10 +67,11 @@ bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path)

if (g2_file_size == 128) {
auto data = read_file(g2_path);
return from_buffer<bb::g2::affine_element>(data.data());
return from_buffer<g2::affine_element>(data.data());
}

auto data = download_bn254_g2_data();
write_file(g2_path, data);
return from_buffer<bb::g2::affine_element>(data.data());
return from_buffer<g2::affine_element>(data.data());
}
} // namespace bb
6 changes: 4 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
#include <fstream>
#include <ios>

std::vector<bb::g1::affine_element> 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);
namespace bb {
std::vector<g1::affine_element> get_bn254_g1_data(const std::filesystem::path& path, size_t num_points);
g2::affine_element get_bn254_g2_data(const std::filesystem::path& path);
} // namespace bb
8 changes: 6 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "get_grumpkin_crs.hpp"

namespace {
std::vector<uint8_t> download_grumpkin_g1_data(size_t num_points)
{
size_t g1_start = 28;
Expand All @@ -19,7 +20,9 @@ std::vector<uint8_t> download_grumpkin_g1_data(size_t num_points)

return data;
}
} // namespace

namespace bb {
std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points)
{
std::filesystem::create_directories(path);
Expand All @@ -35,7 +38,7 @@ std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::file
auto data = read_file(file, 28 + num_points * 64);
auto points = std::vector<curve::Grumpkin::AffineElement>(num_points);
auto size_of_points_in_bytes = num_points * 64;
bb::srs::IO<curve::Grumpkin>::read_affine_elements_from_buffer(
srs::IO<curve::Grumpkin>::read_affine_elements_from_buffer(
points.data(), (char*)data.data(), size_of_points_in_bytes);
return points;
}
Expand All @@ -52,6 +55,7 @@ std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::file
new_size_file.close();

auto points = std::vector<curve::Grumpkin::AffineElement>(num_points);
bb::srs::IO<curve::Grumpkin>::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size());
srs::IO<curve::Grumpkin>::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size());
return points;
}
} // namespace bb
6 changes: 5 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
#include <fstream>
#include <ios>

std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points);
namespace bb {

std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points);

}
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ acir_format::WitnessVector get_witness(std::string const& witness_path)
return acir_format::witness_buf_to_witness_data(witness_data);
}

acir_format::acir_format get_constraint_system(std::string const& bytecode_path)
acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path)
{
auto bytecode = get_bytecode(bytecode_path);
return acir_format::circuit_buf_to_acir_format(bytecode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ using Fr = Curve::ScalarField;
*/
void parallel_for_field_element_addition(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
size_t num_cpus = get_num_cpus();
std::vector<std::vector<Fr>> copy_vector(num_cpus);
for (size_t i = 0; i < num_cpus; i++) {
Expand Down Expand Up @@ -72,7 +72,7 @@ void parallel_for_field_element_addition(State& state)
*/
void ff_addition(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
std::vector<Fr> copy_vector(2);
for (size_t j = 0; j < 2; j++) {
copy_vector.emplace_back(Fr::random_element(&engine));
Expand All @@ -97,7 +97,7 @@ void ff_addition(State& state)
*/
void ff_multiplication(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
std::vector<Fr> copy_vector(2);
for (size_t j = 0; j < 2; j++) {
copy_vector.emplace_back(Fr::random_element(&engine));
Expand All @@ -122,7 +122,7 @@ void ff_multiplication(State& state)
*/
void ff_sqr(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
std::vector<Fr> copy_vector(2);
for (size_t j = 0; j < 2; j++) {
copy_vector.emplace_back(Fr::random_element(&engine));
Expand All @@ -147,7 +147,7 @@ void ff_sqr(State& state)
*/
void ff_invert(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
auto element = Fr::random_element(&engine);

for (auto _ : state) {
Expand All @@ -168,7 +168,7 @@ void ff_invert(State& state)
*/
void ff_to_montgomery(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
auto element = Fr::random_element(&engine);

for (auto _ : state) {
Expand All @@ -188,7 +188,7 @@ void ff_to_montgomery(State& state)
*/
void ff_from_montgomery(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
auto element = Fr::random_element(&engine);

for (auto _ : state) {
Expand All @@ -209,7 +209,7 @@ void ff_from_montgomery(State& state)
*/
void ff_reduce(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
auto element = Fr::random_element(&engine);

for (auto _ : state) {
Expand All @@ -230,7 +230,7 @@ void ff_reduce(State& state)
*/
void projective_point_addition(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
std::vector<Curve::Element> copy_vector(2);
for (size_t j = 0; j < 2; j++) {
copy_vector.emplace_back(Curve::Element::random_element(&engine));
Expand All @@ -255,7 +255,7 @@ void projective_point_addition(State& state)
*/
void projective_point_accidental_doubling(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
std::vector<Curve::Element> copy_vector(2);
for (size_t j = 0; j < 2; j++) {
copy_vector.emplace_back(Curve::Element::random_element(&engine));
Expand All @@ -280,7 +280,7 @@ void projective_point_accidental_doubling(State& state)
*/
void projective_point_doubling(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
std::vector<Curve::Element> copy_vector(2);
for (size_t j = 0; j < 2; j++) {
copy_vector.emplace_back(Curve::Element::random_element(&engine));
Expand All @@ -305,7 +305,7 @@ void projective_point_doubling(State& state)
*/
void scalar_multiplication(State& state)
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
Curve::Element element = Curve::Element::random_element(&engine);
Fr scalar = Fr::random_element(&engine);

Expand Down Expand Up @@ -347,7 +347,7 @@ void cycle_waste(State& state)
void sequential_copy(State& state)
{

numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
for (auto _ : state) {
state.PauseTiming();
size_t num_cycles = 1 << static_cast<size_t>(state.range(0));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <benchmark/benchmark.h>

#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp"
#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp"
#include "barretenberg/eccvm/eccvm_composer.hpp"
#include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include <benchmark/benchmark.h>

#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp"
#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp"
#include "barretenberg/goblin/goblin.hpp"
#include "barretenberg/goblin/mock_circuits.hpp"
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::vector<OpeningClaim> opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNO

void ipa_open(State& state) noexcept
{
numeric::random::Engine& engine = numeric::random::get_debug_engine();
numeric::RNG& engine = numeric::get_debug_randomness();
for (auto _ : state) {
state.PauseTiming();
size_t n = 1 << static_cast<size_t>(state.range(0));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp"
#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp"
#include "barretenberg/plonk/composer/standard_composer.hpp"
#include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp"

Expand All @@ -13,8 +13,8 @@ using StandardPlonk = bb::plonk::StandardComposer;
static void construct_proof_standard_power_of_2(State& state) noexcept
{
auto log2_of_gates = static_cast<size_t>(state.range(0));
bench_utils::construct_proof_with_specified_num_iterations<bb::plonk::StandardComposer>(
state, &bench_utils::generate_basic_arithmetic_circuit<bb::StandardCircuitBuilder>, log2_of_gates);
bb::mock_proofs::construct_proof_with_specified_num_iterations<bb::plonk::StandardComposer>(
state, &bb::mock_proofs::generate_basic_arithmetic_circuit<bb::StandardCircuitBuilder>, log2_of_gates);
}

BENCHMARK(construct_proof_standard_power_of_2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <benchmark/benchmark.h>

#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp"
#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp"
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "barretenberg/ultra_honk/ultra_composer.hpp"

Expand All @@ -23,7 +23,7 @@ void fold_one(State& state) noexcept

const auto construct_instance = [&]() {
Builder builder;
bench_utils::generate_basic_arithmetic_circuit(builder, log2_num_gates);
bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates);
return composer.create_instance(builder);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using namespace benchmark;

namespace {
auto& engine = numeric::random::get_debug_engine();
auto& engine = bb::numeric::get_debug_randomness();
}

using FF = bb::fr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <benchmark/benchmark.h>

namespace {
auto& engine = numeric::random::get_debug_engine();
auto& engine = bb::numeric::get_debug_randomness();
}

using namespace bb::honk::sumcheck;
Expand Down
Loading