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

Add a range constraint builtin that does not type check the field #4015

Closed
kevaundray opened this issue Jan 11, 2024 · 1 comment · Fixed by #4016
Closed

Add a range constraint builtin that does not type check the field #4015

kevaundray opened this issue Jan 11, 2024 · 1 comment · Fixed by #4016
Labels
enhancement New feature or request

Comments

@kevaundray
Copy link
Contributor

Problem

Given that our range constraints do not allow us to apply range constraints greater than 128 bits, it would be good to have an unsafe way to do arithmetics on fields.

Happy Case

Add the following method to the stdlib:

    #[builtin(apply_range_constraint)]
    fn __apply_range_constraint(_self: Self, _bit_size: u32) {}

    pub fn apply_range_constraint(self: Self, bit_size: u32) {
        crate::assert_constant(bit_size);
        self.__apply_range_constraint(bit_size);
    }

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@kevaundray kevaundray added enhancement New feature or request P-LOW labels Jan 11, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jan 11, 2024
@TomAFrench
Copy link
Member

Or.... implement Ord on Fields!

github-merge-queue bot pushed a commit that referenced this issue Jan 12, 2024
# Description


resolves #4015 

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*



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

---------

Co-authored-by: Tom French <[email protected]>
Co-authored-by: Tom French <[email protected]>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants