Skip to content

Commit

Permalink
fix: Truncate SRS size to the amount of points that we have downloaded (
Browse files Browse the repository at this point in the history
#1862)

related to #1861 

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
kevaundray authored Aug 29, 2023
1 parent e04d1df commit 0a7058c
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ inline std::vector<barretenberg::g1::affine_element> get_g1_data(const std::file
vinfo("using cached crs at: ", path);
auto data = read_file(path / "g1.dat");
auto points = std::vector<barretenberg::g1::affine_element>(num_points);

auto size_of_points_in_bytes = num_points * 64;
if (data.size() < size_of_points_in_bytes) {
vinfo("data is smaller than expected!", data.size(), size_of_points_in_bytes);
}
size_t actual_buffer_size = std::min(data.size(), size_of_points_in_bytes);

barretenberg::srs::IO<curve::BN254>::read_affine_elements_from_buffer(
points.data(), (char*)data.data(), num_points * 64);
points.data(), (char*)data.data(), actual_buffer_size);
return points;
}

Expand Down

0 comments on commit 0a7058c

Please sign in to comment.