-
Notifications
You must be signed in to change notification settings - Fork 244
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
Sha512 cannot hash slices #3687
Comments
What use case do you see for using an unconstrained hash result? It is expected for this to fail as |
# Description ## Problem\* Resolves #3687 ## Summary\* This simply adds a secondary message to clarify that using a slice length will lead to the `Could not determine loop bound at compile-time` error. I was thinking of disabling this earlier during type check but we don't necessarily know that we will have a slice until codegen as arrays and slices are polymorphic with one another. I also thought about making a separate runtime error to check during loop unrolling but we are not necessarily going to still have the `ArrayLen` call codegen'd in SSA and will instead have the call's results for the loop condition, so this isn't a basic check and some more logic would be needed. The best option for a specific error check seems to be during `codegen_for` before we codegen the end range. We can check whether we are making a slice ArrayLen call for the end range. These changes all felt a bit much as the error is quite clear except for this one error case and thus a secondary message felt sufficient. If we would like the error to be more specific for the failure case then I can look at adding logic that triggers an error for a slice length loop bound. An example of the error now: <img width="1013" alt="Screenshot 2024-02-05 at 5 10 39 PM" src="https://github.com/noir-lang/noir/assets/43554004/45bc240b-90a7-47b0-974d-d60e7c9a2079"> ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
Aim
Hashing a slice with sha512 in
0.19.2
causes unconstrained comptime issues on noir0.19.2+47f0130c0d154f1b70eb23f376783beb3f23ad72
Expected Behavior
Hashing slices should be fine, or a code path for hashing unbounded items should be unconstrained.
Bug
Hashing a slice in a test causes:
[simple4x] Testing test_sha512_broken_slices... error: Could not determine loop bound at compile-time
To Reproduce
Installation Method
Compiled from source
Nargo Version
0.19.2+47f0130c0d154f1b70eb23f376783beb3f23ad72
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: