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

Allocate range proof verifier vectors #1431

Merged
merged 1 commit into from
Apr 16, 2024
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
10 changes: 10 additions & 0 deletions src/libspark/bpplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ bool BPPlus::verify(const std::vector<std::vector<GroupElement>>& unpadded_C, co
std::size_t N_proofs = proofs.size();
std::size_t max_M = 0; // maximum number of padded aggregated values across all proofs

std::size_t final_size = 0; // size of each vector used in final multiscalar multiplication

// Check aggregated input consistency
for (std::size_t k = 0; k < N_proofs; k++) {
std::size_t unpadded_M = unpadded_C[k].size();
Expand All @@ -331,8 +333,14 @@ bool BPPlus::verify(const std::vector<std::vector<GroupElement>>& unpadded_C, co
if (log2(N*M) != rounds) {
return false;
}

// Update the final vector size: B, A1, A, (C_j), (L), (R)
final_size += 3 + M + 2 * rounds;
}

// Update the final vector size: G, H, (Gi), (Hi)
final_size += 2 + 2 * max_M * N;

// Check the bounds on the batch
if (max_M*N > Gi.size() || max_M*N > Hi.size()) {
return false;
Expand All @@ -341,6 +349,8 @@ bool BPPlus::verify(const std::vector<std::vector<GroupElement>>& unpadded_C, co
// Set up final multiscalar multiplication and common scalars
std::vector<GroupElement> points;
std::vector<Scalar> scalars;
points.reserve(final_size);
scalars.reserve(final_size);
Scalar G_scalar, H_scalar;

// Interleave the Gi and Hi scalars
Expand Down
Loading