You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bn254 field library does not have eq, gte, nor lte functions. It is possible to compare equality of fields with == however, I believe the following syntax is useful:
let a:Field = 1;let b:Field = 1;let is_equal = a.eq(b);
Also the syntax:
let a:Field = 0;let b:Field = 1;let is_lte = a.lte(b);
let a:Field = 1;let b:Field = 0;let is_gte = a.gte(b);
would be super useful to have.
Why?
Since these functions are not implemented it requires the circuit developer to add extra complexity to their circuit, which is bad devEx.
Proposed change
This functionality was proposed in this PR: #7572, however the PR was closed due to lack of consensus among the core team regarding the best path forward to implement this functionality.
It would be even better to be able to use the operators <= and >= with fields natively.
Would be great if the Noir team could reach a consensus regarding how to add this basic functionality.
Leave constructive feedback and a path forward regarding how to implement basic functionality to improve developer experience and engage constructively with developers looking to use Noir in a production environment.
Workaround
None
Would you like to submit a PR for this Issue?
Open to creating a draft PR.
The text was updated successfully, but these errors were encountered:
It would be even better to be able to use the operators <= and >= with fields natively.
DevEx is not the only concern when comparing fields. Safety is also one of Noir's main tenets. We have not exposed < and > natively on fields thus far like we do integer types due to these safety concerns. Finite fields do not have an inherent ordering, which can lead to vulnerabilities especially for developers unfamiliar with finite field arithmetic.
We expose lt for advanced users who desire to perform arithmetic logic on fields. However, we would like to move away from a free function (due to it not being very user friendly as you mentioned). Adding more of these methods when they will possibly be deprecated in the future will just lead to more breaking changes down the line.
We definitely want to improve DevEx for field comparisons, but it has taken a backseat to other priorities.
@vezenovm I agree that using free functions isn’t the best approach for handling field comparisons. Instead, by converting field elements to their canonical integer representations, we can directly compare the integers. I’m open to working on this improvement and can open a draft PR to implement the changes.
Problem
The
bn254
field library does not haveeq
,gte
, norlte
functions. It is possible to compare equality of fields with==
however, I believe the following syntax is useful:Also the syntax:
would be super useful to have.
Why?
Since these functions are not implemented it requires the circuit developer to add extra complexity to their circuit, which is bad devEx.
Proposed change
This functionality was proposed in this PR: #7572, however the PR was closed due to lack of consensus among the core team regarding the best path forward to implement this functionality.
It would be even better to be able to use the operators
<=
and>=
with fields natively.Would be great if the Noir team could reach a consensus regarding how to add this basic functionality.
@TomAFrench @critesjosh @zac-williamson
Happy Case
Leave constructive feedback and a path forward regarding how to implement basic functionality to improve developer experience and engage constructively with developers looking to use Noir in a production environment.
Workaround
None
Would you like to submit a PR for this Issue?
Open to creating a draft PR.
The text was updated successfully, but these errors were encountered: