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

fix: bbmalloc linker error #459

Merged
merged 1 commit into from
May 19, 2023
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
14 changes: 7 additions & 7 deletions cpp/src/barretenberg/env/crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

const int NUM_POINTS_IN_TRANSCRIPT = 5040001;


extern "C" {
/**
* @brief In WASM, loads the verifier reference string.
* Used in native code to quickly create an in-memory reference string.
*/
uint8_t* env_load_verifier_crs() {
uint8_t* env_load_verifier_crs()
{
std::ifstream transcript;
transcript.open("../srs_db/ignition/monomial/transcript00.dat", std::ifstream::binary);
// We need two g2 points, each 64 bytes.
Expand All @@ -22,7 +22,7 @@ uint8_t* env_load_verifier_crs() {
transcript.seekg(28 + NUM_POINTS_IN_TRANSCRIPT * 64);
transcript.read((char*)g2_points.data(), (std::streamsize)g2_points_size);
transcript.close();
auto* g2_points_copy = (uint8_t*)bbmalloc(g2_points_size);
auto* g2_points_copy = (uint8_t*)aligned_alloc(64, g2_points_size);
memcpy(g2_points_copy, g2_points.data(), g2_points_size);
return g2_points_copy;
}
Expand All @@ -33,20 +33,20 @@ uint8_t* env_load_verifier_crs() {
* In native code, not intended to be used.
* @param num_points The number of points to load.
*/
uint8_t* env_load_prover_crs(size_t num_points) {
uint8_t* env_load_prover_crs(size_t num_points)
{
// Note: This implementation is only meant to be instructive.
// This should only be used in c-binds to implement the C++ abstractions.
std::ifstream transcript;
transcript.open("../srs_db/ignition/monomial/transcript00.dat", std::ifstream::binary);
// Each g1 point is 64 bytes.
size_t g1_points_size = (num_points) * 64;
size_t g1_points_size = (num_points)*64;
std::vector<uint8_t> g1_points(g1_points_size);
transcript.seekg(28);
transcript.read((char*)g1_points.data(), (std::streamsize)g1_points_size);
transcript.close();
auto* g1_points_copy = (uint8_t*)bbmalloc(g1_points_size);
auto* g1_points_copy = (uint8_t*)aligned_alloc(64, g1_points_size);
memcpy(g1_points_copy, g1_points.data(), g1_points_size);
return g1_points_copy;
}

}