Skip to content
Merged
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions cpp/src/barretenberg/crypto/pedersen_hash/pedersen_lookup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "./pedersen_lookup.hpp"

#include <mutex>

#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"

namespace crypto {
Expand All @@ -10,6 +12,12 @@ std::array<std::vector<grumpkin::g1::affine_element>, NUM_PEDERSEN_TABLES> peder
std::vector<grumpkin::g1::affine_element> pedersen_iv_table;
std::array<grumpkin::g1::affine_element, NUM_PEDERSEN_TABLES> generators;

// Mutex is not available in the WASM context.
// WASM runs in a single-thread so this is acceptable.
#if !defined(__wasm__)
std::mutex init_mutex;
#endif

static bool inited = false;

void init_single_lookup_table(const size_t index)
Expand Down Expand Up @@ -66,6 +74,11 @@ void init()
{
ASSERT(BITS_PER_TABLE < BITS_OF_BETA);
ASSERT(BITS_PER_TABLE + BITS_OF_BETA < BITS_ON_CURVE);

#if !defined(__wasm__)
const std::lock_guard<std::mutex> lock(init_mutex);
#endif

if (inited) {
return;
}
Expand Down