firoorg / firo

The privacy-focused cryptocurrency
https://firo.org
MIT License
720 stars 354 forks source link

Spark range proof verifier unnecessarily reallocates #1430

Closed AaronFeickert closed 7 months ago

AaronFeickert commented 7 months ago

Spark range proofs are verified in batches. To do this, the verifier sets up two large vectors, one for scalars and the other for group elements, for use in a single multiscalar multiplication operation.

However, these vectors don't have their sizes reserved in advance. This means there is likely a fair amount of unnecessary reallocation as elements are pushed.

The solution is to reserve the correct number of elements for each vector.