From 67e88d21a12e79ecc5d5f07cab341f25d6350ccc Mon Sep 17 00:00:00 2001 From: Aaron Feickert <66188213+AaronFeickert@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:24:32 -0500 Subject: [PATCH] Allocate range proof verifier vectors --- src/libspark/bpplus.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libspark/bpplus.cpp b/src/libspark/bpplus.cpp index 0241045795..7254d1c0c2 100644 --- a/src/libspark/bpplus.cpp +++ b/src/libspark/bpplus.cpp @@ -305,6 +305,8 @@ bool BPPlus::verify(const std::vector>& 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(); @@ -331,8 +333,14 @@ bool BPPlus::verify(const std::vector>& 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; @@ -341,6 +349,8 @@ bool BPPlus::verify(const std::vector>& unpadded_C, co // Set up final multiscalar multiplication and common scalars std::vector points; std::vector scalars; + points.reserve(final_size); + scalars.reserve(final_size); Scalar G_scalar, H_scalar; // Interleave the Gi and Hi scalars