scipr-lab / libsnark

C++ library for zkSNARKs
Other
1.81k stars 572 forks source link

Many libsnark::protoboard methods return by value rather than const references #136

Open HarryR opened 5 years ago

HarryR commented 5 years ago

Instigated from: https://github.com/HarryR/ethsnarks/issues/99

Several frequently used methods in libsnark::protoboard return by value rather than by reference, this copies all of the data every time they're called:

It is unnecessary to perform a full copy of any of this data, and with very large constraint systems there's a significant overhead introduced by the copy constructor.

I will verify whether these can be changed to:

An alternative would be to change the visibility of properties of libsnark::protoboard from private to public or protected. This is the least-effort solution which requires no changes to dependent code.

I will check which one is the best option, and submit a pull request. 👍