8000 Better use of unchecked methods · Issue #9 · NP-Eng/ligero · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Better use of unchecked methods #9

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

Open
Antonio95 opened this issue Aug 2, 2024 · 0 comments
Open

Better use of unchecked methods #9

Antonio95 opened this issue Aug 2, 2024 · 0 comments

Comments

@Antonio95
Copy link
Contributor

Right now, some ArithmeticCircuit operations have unchecked variants, such as the method add and its counterpart add_unchecked. Unchecked methods simply don't check whether the operands one passes are already in the circuit. For instance, add(a, b) would panic if a and b are not (the indices of nodes) in the circuit.

This is a very cheap check, since it only compares the inputs (which are secretly usizes) to the length of the node vector. However, if one adds many gates (e.g. by calling existing_node.pow(something_big)), it is unnecessary to check that condition for each (multiplication, in this case) gate - hence why the unchecked methods were introduced.

There are two things to polish in relation to this:

  • Since we ended up deciding that a node can actually depend on nodes that come after it in the node list, the checked methods might no longer make sense. Having said that, this kind of forward-dependency will likely only happen when converting Expressions to ArithmeticCircuits. It is unlikely that a user creating the circuit with circuit methods, such as add, will introduce nodes with forward-dependencies (unless they are coding a circuit whose description they have obtained some other way). One way or another, let's think whether to keep the check and/or differentiation between checked and unchecked methods.
  • If we do keep them, let's be a bit finer and more consistent in when we use which (in the already-existing functionality).
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
0