[Feat]: Add an 'in' instruction in the VM.#2950
Open
usagi32 wants to merge 1 commit intoProvableHQ:stagingfrom
Open
[Feat]: Add an 'in' instruction in the VM.#2950usagi32 wants to merge 1 commit intoProvableHQ:stagingfrom
usagi32 wants to merge 1 commit intoProvableHQ:stagingfrom
Conversation
d0cd
reviewed
Oct 8, 2025
| }; | ||
|
|
||
| // Check if the array contains the value. | ||
| let output = (0..array.len()).any(|index| val.is_equal(&array[index]).eject_value()); |
Collaborator
There was a problem hiding this comment.
I do not believe that this is sufficiently constrained. Generally, eject_value needs to be used with care in a circuit. One safe way to implement this is to construct an "or" expression over all of the equality operations, e.g, (val == arr[0] || val == arr[1] || ... || val == arr[k])
9cef564 to
2e6edbd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
for this issue in leo ProvableHQ/leo#28721
This PR adds a new 'in' instruction support at the synthesizer level. Without this developers would have to do a verbose unroll of the entire array and also instruction costs would increase for contracts for multiple checks, so this saves that.
Some notes:
If this PR is approved, I would also add the support in leo as well.
Test Plan
Added new tests