Skip to content

Commit

Permalink
Remove USE_TURBO
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Apr 17, 2023
1 parent 4a97bf3 commit 2994b29
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 46 deletions.
8 changes: 1 addition & 7 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ option(SERIALIZE_CANARY "Build with serialize canary" OFF)
option(ENABLE_ASAN "Address sanitizer for debugging tricky memory corruption" OFF)
option(ENABLE_HEAVY_TESTS "Enable heavy tests when collecting coverage" OFF)
option(INSTALL_BARRETENBERG "Enable installation of barretenberg. (Projects embedding barretenberg may want to turn this OFF.)" ON)
option(USE_TURBO "Enable the use of TurboPlonk in barretenberg." OFF)

if(USE_TURBO)
message(STATUS "Building barretenberg for TurboPlonk Composer.")
add_definitions(-DUSE_TURBO)
else()
message(STATUS "Building barretenberg for UltraPlonk Composer.")
endif()
message(STATUS "Building barretenberg for UltraPlonk Composer.")

if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
message(STATUS "Compiling for ARM.")
Expand Down
5 changes: 1 addition & 4 deletions cpp/src/barretenberg/dsl/acir_format/pedersen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ void create_pedersen_constraint(Composer& composer, const PedersenConstraint& in
field_ct scalar_as_field = field_ct::from_witness_index(&composer, scalar);
scalars.push_back(scalar_as_field);
}
#ifdef USE_TURBO
auto point = pedersen_commitment::commit(scalars);
#else

// TODO: Does Noir need additive homomorphic Pedersen hash? If so, using plookup version won't help.
auto point = stdlib::pedersen_plookup_commitment<Composer>::commit(scalars);
#endif

composer.assert_equal(point.x.witness_index, input.result_x);
composer.assert_equal(point.y.witness_index, input.result_y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,17 @@ WASM_EXPORT void join_split__release_key()

WASM_EXPORT uint32_t join_split__get_new_proving_key_data(uint8_t** output)
{
// Computing the size of the serialized key is non trivial. We know it's ~331mb.
// Allocate a buffer large enough to hold it, and abort if we overflow.
// This is to keep memory usage down.
#ifdef USE_TURBO
size_t total_buf_len = 350 * 1024 * 1024;
auto raw_buf = (uint8_t*)malloc(total_buf_len);
auto raw_buf_end = raw_buf;
write(raw_buf_end, *get_proving_key());
*output = raw_buf;
auto len = static_cast<uint32_t>(raw_buf_end - raw_buf);
if (len > total_buf_len) {
info("Buffer overflow serializing proving key.");
std::abort();
}
return len;
#else
// Computing the size of the serialized key is non trivial. We know it's ~331mb.
// Allocate a buffer large enough to hold it, and abort if we overflow.
// This is to keep memory usage down.

auto proving_key = get_proving_key();
auto buffer = to_buffer(*proving_key);
auto raw_buf = (uint8_t*)malloc(buffer.size());
memcpy(raw_buf, (void*)buffer.data(), buffer.size());
*output = raw_buf;

return static_cast<uint32_t>(buffer.size());
#endif
}

WASM_EXPORT void join_split__init_verification_key(void* pippenger, uint8_t const* g2x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,8 @@ bool verify_proof(plonk::proof const& proof)
{
Verifier verifier(verification_key, Composer::create_manifest(verification_key->num_public_inputs));

#ifdef USE_TURBO
std::unique_ptr<plonk::KateCommitmentScheme<plonk::turbo_settings>> kate_commitment_scheme =
std::make_unique<plonk::KateCommitmentScheme<plonk::turbo_settings>>();
#else
std::unique_ptr<plonk::KateCommitmentScheme<plonk::ultra_settings>> kate_commitment_scheme =
std::make_unique<plonk::KateCommitmentScheme<plonk::ultra_settings>>();
#endif
verifier.commitment_scheme = std::move(kate_commitment_scheme);

return verifier.verify_proof(proof);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,17 +802,12 @@ TEST_F(join_split_tests, test_0_input_notes_and_detect_circuit_change)

EXPECT_TRUE(result.valid);

// The below part detects any changes in the join-split circuit
#ifdef USE_TURBO
constexpr uint32_t CIRCUIT_GATE_COUNT = 59175;
constexpr uint32_t GATES_NEXT_POWER_OF_TWO = 65536;
const uint256_t VK_HASH("095cbe8f1b09690713d5161708b5ea77119575884e3cfab14f7364b9f1ba7faa");
#else
// The below part detects any changes in the join-split circuit

constexpr uint32_t CIRCUIT_GATE_COUNT = 185573;
constexpr uint32_t GATES_NEXT_POWER_OF_TWO = 524288;
const uint256_t VK_HASH("13eb88883e80efb9bf306af2962cd1a49e9fa1b0bfb2d4b563b95217a17bcc74");

#endif
auto number_of_gates_js = result.number_of_gates;
auto vk_hash_js = get_verification_key()->sha256_hash();

Expand Down Expand Up @@ -2625,11 +2620,8 @@ TEST_F(join_split_tests, serialized_proving_key_size)
{
uint8_t* ptr;
auto len = join_split__get_new_proving_key_data(&ptr);
#ifdef USE_TURBO
EXPECT_LE(len, 2 * 170 * 1024 * 1024);
#else

EXPECT_LE(len, 2315258552);
#endif
}

} // namespace join_split_example::proofs::join_split
3 changes: 1 addition & 2 deletions cpp/src/barretenberg/plonk/proof_system/constants.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#pragma once
#include <cstdint>
#include "barretenberg/proof_system/types/composer_type.hpp"

namespace proof_system::plonk {

// limb size when simulating a non-native field using bigfield class
// (needs to be a universal constant to be used by native verifier)
static constexpr uint64_t NUM_LIMB_BITS_IN_FIELD_SIMULATION = 68;

static constexpr uint32_t NUM_QUOTIENT_PARTS = 4;
} // namespace proof_system::plonk

0 comments on commit 2994b29

Please sign in to comment.