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

feat: add as_witness builtin function in order to constrain a witness to be equal to a variable #4641

Merged
merged 3 commits into from
May 21, 2024

Conversation

TomAFrench
Copy link
Member

Description

Problem*

Quick fix to #4629

Summary*

This PR adds a as_witness function which takes a Field and instructs the compiler to lay down an opcode which constrains a witness to be equal to this value.

This prevents the issue in #4629 where we collect ever growing expressions which need to be broken down multiple times while reshaping the circuit. Doing this during acirgen instead allows us to avoid this repetition.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.
    Feature is experimental

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@TomAFrench TomAFrench requested a review from jfecher March 26, 2024 14:59
@TomAFrench
Copy link
Member Author

I've confirmed that this works on @zac-williamson's poseidon circuit. Happy to bikeshed on naming.

@jfecher
Copy link
Contributor

jfecher commented Mar 26, 2024

I'd like to hold off on this unless @zac-williamson really needs a fix today for this. I just don't see regular users being able to debug to the point where they can identify the exact point to add as_witness if it is needed.

@TomAFrench
Copy link
Member Author

Happy to hold off on this if it's not urgent, just good to have this in our back pocket.

@TomAFrench
Copy link
Member Author

@jfecher can you approve?

@jfecher jfecher enabled auto-merge May 21, 2024 15:34
@jfecher jfecher added this pull request to the merge queue May 21, 2024
Merged via the queue into master with commit faf5bd8 May 21, 2024
40 of 41 checks passed
@jfecher jfecher deleted the tf/force-witness branch May 21, 2024 16:32
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request May 21, 2024
…ic definition (noir-lang/noir#5041)

feat: Implement turbofish operator (noir-lang/noir#3542)
feat: add `as_witness` builtin function in order to constrain a witness to be equal to a variable  (noir-lang/noir#4641)
chore(experimental): Elaborate impls & non-trait impls (noir-lang/noir#5007)
feat: add native rust implementation of schnorr signature verification (noir-lang/noir#5053)
chore: Release Noir(0.30.0) (noir-lang/noir#4981)
TomAFrench added a commit to AztecProtocol/aztec-packages that referenced this pull request May 21, 2024
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix(frontend): Call trait method with mut self from generic definition
(noir-lang/noir#5041)
feat: Implement turbofish operator
(noir-lang/noir#3542)
feat: add `as_witness` builtin function in order to constrain a witness
to be equal to a variable (noir-lang/noir#4641)
chore(experimental): Elaborate impls & non-trait impls
(noir-lang/noir#5007)
feat: add native rust implementation of schnorr signature verification
(noir-lang/noir#5053)
chore: Release Noir(0.30.0)
(noir-lang/noir#4981)
END_COMMIT_OVERRIDE

---------

Co-authored-by: TomAFrench <tom@tomfren.ch>
AztecBot added a commit that referenced this pull request May 21, 2024
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix(frontend): Call trait method with mut self from generic definition
(#5041)
feat: Implement turbofish operator
(#3542)
feat: add `as_witness` builtin function in order to constrain a witness
to be equal to a variable (#4641)
chore(experimental): Elaborate impls & non-trait impls
(#5007)
feat: add native rust implementation of schnorr signature verification
(#5053)
chore: Release Noir(0.30.0)
(#4981)
END_COMMIT_OVERRIDE

---------

Co-authored-by: TomAFrench <tom@tomfren.ch>
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

Successfully merging this pull request may close these issues.

None yet

2 participants