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

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

Open
HarryR opened this issue Dec 5, 2018 · 0 comments

Comments

@HarryR
Copy link

HarryR commented Dec 5, 2018

Instigated from: HarryR/ethsnarks#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:

  • r1cs_variable_assignment<FieldT> full_variable_assignment() const;
  • r1cs_primary_input<FieldT> primary_input() const;
  • r1cs_auxiliary_input<FieldT> auxiliary_input() const;
  • r1cs_constraint_system<FieldT> get_constraint_system() const;

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:

  • const r1cs_variable_assignment<FieldT>& full_variable_assignment() const;
  • const r1cs_primary_input<FieldT>& primary_input() const;
  • const r1cs_auxiliary_input<FieldT>& auxiliary_input() const;
  • const r1cs_constraint_system<FieldT>& get_constraint_system() const;

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. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant