Expand cases for generating a witness in prepare inputs #452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue(s)
Resolves issue with not being able to use inputs to gadgets that had been set through a conditional statement.
Description
While writing the account circuit I was performing this conditional:
Which was later used by this intrinsic gadget:
When compiling this would lead to the error below:
We require that inputs to intrinsic gadgets be transformed into witnesses, however, we were not handling the case where the inputs to the function are a result of a conditional instruction. The result of this conditional does not have a witness associated with it.
Summary of changes
I simply added extra logic to
prepare_inputs
for cases other than aNodeObj::Obj
. In the case that the NodeId is in the arithmetic cache, but does not yet have a witness generate, we simply generate a new witness for this instruction withgenerate_witness
.Dependency additions / changes
(If applicable.)
Test additions / changes
I added a little extra logic to our
scalar_mul
test. If you runnargo compile
on this test using a nargo build from the current master you should see the error that I mentioned above. The test passes as expected with the current changes. You can also change the input ofa
for thescalar_mul
test to see how the inputs tostd::fixed_based::scalar_mul
are changed.Checklist
cargo fmt
with default settings.Additional context
(If applicable.)