Skip to content

Commit

Permalink
Templatize: everything builds and links
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed May 24, 2023
1 parent c6feea1 commit 12cc9db
Show file tree
Hide file tree
Showing 64 changed files with 725 additions and 5,724 deletions.
2 changes: 0 additions & 2 deletions cpp/.clangd
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Diagnostics:
- readability-function-cognitive-complexity
# It is often nicer to not be explicit
- google-explicit-constructor
CheckOptions:
- cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: True

--- # this divider is necessary
# Disable some checks for Google Test/Bench
Expand Down
7 changes: 4 additions & 3 deletions cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <chrono>
#include "barretenberg/common/assert.hpp"
#include <cstdlib>
#include "barretenberg/ecc/curves/bn254/scalar_multiplication/scalar_multiplication.hpp"
#include "barretenberg/ecc/curves/bn254/bn254.hpp"
#include "barretenberg/ecc/curves/scalar_multiplication/scalar_multiplication.hpp"
#include "barretenberg/srs/reference_string/file_reference_string.hpp"
#include "barretenberg/polynomials/polynomial_arithmetic.hpp"

Expand Down Expand Up @@ -63,9 +64,9 @@ const auto init = []() {

int pippenger()
{
scalar_multiplication::pippenger_runtime_state state(NUM_POINTS);
scalar_multiplication::pippenger_runtime_state<curve::BN254> state(NUM_POINTS);
std::chrono::steady_clock::time_point time_start = std::chrono::steady_clock::now();
g1::element result = scalar_multiplication::pippenger_unsafe(
g1::element result = scalar_multiplication::pippenger_unsafe<curve::BN254>(
&scalars[0], reference_string->get_monomial_points(), NUM_POINTS, state);
std::chrono::steady_clock::time_point time_end = std::chrono::steady_clock::now();
std::chrono::microseconds diff = std::chrono::duration_cast<std::chrono::microseconds>(time_end - time_start);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/barretenberg/dsl/acir_proofs/acir_proofs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ size_t init_verification_key(void* pippenger, uint8_t const* g2x, uint8_t const*
auto proving_key = std::make_shared<plonk::proving_key>(std::move(pk_data), crs);

auto crs_factory = std::make_unique<PippengerReferenceStringFactory>(
reinterpret_cast<scalar_multiplication::Pippenger*>(pippenger), g2x);
reinterpret_cast<scalar_multiplication::Pippenger<curve::BN254>*>(pippenger), g2x);
proving_key->reference_string = crs_factory->get_prover_crs(proving_key->circuit_size);

acir_format::Composer composer(proving_key, nullptr);
Expand Down Expand Up @@ -108,7 +108,7 @@ size_t new_proof(void* pippenger,
auto witness = from_buffer<std::vector<fr>>(witness_buf);

auto crs_factory = std::make_unique<PippengerReferenceStringFactory>(
reinterpret_cast<scalar_multiplication::Pippenger*>(pippenger), g2x);
reinterpret_cast<scalar_multiplication::Pippenger<curve::BN254>*>(pippenger), g2x);
proving_key->reference_string = crs_factory->get_prover_crs(proving_key->circuit_size);

acir_format::Composer composer(proving_key, nullptr);
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#include "../bn254/fr.hpp"
#include "../bn254/fq.hpp"
#include "../bn254/g1.hpp"
#include "../bn254/g2.hpp"

namespace curve {
class BN254 {
public:
using ScalarField = barretenberg::fr;
using BaseField = barretenberg::fq;
using ProjectiveElement = typename barretenberg::g1::element;
using Group = typename barretenberg::g1;
using Element = typename barretenberg::g1::element;
using AffineElement = typename barretenberg::g1::affine_element;
};
} // namespace curve
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "scalar_multiplication.hpp"
#include "pippenger.hpp"
#include "../bn254.hpp"
#include "../../scalar_multiplication/scalar_multiplication.hpp"
#include "../../scalar_multiplication/pippenger.hpp"
#include "barretenberg/common/mem.hpp"

using namespace barretenberg;
Expand All @@ -21,19 +22,19 @@ WASM_EXPORT void bbfree(void* ptr)

WASM_EXPORT void* new_pippenger(uint8_t* points, size_t num_points)
{
auto ptr = new scalar_multiplication::Pippenger(points, num_points);
auto ptr = new scalar_multiplication::Pippenger<curve::BN254>(points, num_points);
return ptr;
}

WASM_EXPORT void delete_pippenger(void* pippenger)
{
delete reinterpret_cast<scalar_multiplication::Pippenger*>(pippenger);
delete reinterpret_cast<scalar_multiplication::Pippenger<curve::BN254>*>(pippenger);
}

WASM_EXPORT void pippenger_unsafe(void* pippenger_ptr, void* scalars_ptr, size_t from, size_t range, void* result_ptr)
{
scalar_multiplication::pippenger_runtime_state state(range);
auto pippenger = reinterpret_cast<scalar_multiplication::Pippenger*>(pippenger_ptr);
scalar_multiplication::pippenger_runtime_state<curve::BN254> state(range);
auto pippenger = reinterpret_cast<scalar_multiplication::Pippenger<curve::BN254>*>(pippenger_ptr);
auto scalars = reinterpret_cast<fr*>(scalars_ptr);
auto result = reinterpret_cast<g1::element*>(result_ptr);
*result = pippenger->pippenger_unsafe(scalars, from, range);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 12cc9db

Please sign in to comment.