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 ToConstraintFieldGadget bounds to CurveVar and FieldVar #144

Merged

Conversation

winderica
Copy link
Contributor

@winderica winderica commented Apr 4, 2024

Description

This PR adds the requirement that structs that implement CurveVar or FieldVar should also implement ToConstraintFieldGadget, which could be convenient e.g. when we want to extract the underlying FpVars from a generic CurveVar without specifying + ToConstraintFieldGadget<...> every time.

Since both implementations of CurveVar (i.e., SW ProjectiveVar and TE AffineVar) and all implementations of FieldVar (i.e., FpVar, QuadExtVar, CubicExtVar, and EmulatedFpVar) already implement ToConstraintFieldGadget as well, this PR does not introduce any change in the behavior of existing code.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests (N/A)
  • Updated relevant documentation in the code (N/A)
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@winderica winderica requested a review from a team as a code owner April 4, 2024 21:32
@winderica winderica requested review from z-tech, mmagician and weikengchen and removed request for a team April 4, 2024 21:32
@winderica winderica force-pushed the to_constraint_field_for_curve_var branch from 0ae335b to b5956aa Compare April 4, 2024 21:36
@winderica winderica changed the title Require CurveVar and FieldVar to impl ToConstraintFieldGadget Add ToConstraintFieldGadget bounds to CurveVar and FieldVar Apr 4, 2024
@Pratyush
Copy link
Member

Pratyush commented May 8, 2024

I think a semantically cleaner version of this would be to add x() and y() operations to the CurveVar trait.

@winderica
Copy link
Contributor Author

@Pratyush Yeah that makes sense! Will add these methods, as well as xy(), to CurveVar.

But I still think adding ToConstraintFieldGadget to CurveVar is beneficial. x() and y() are called more likely for exposing the details of the point, while a developer may invoke to_constraint_field() without caring about the implementation details (e.g., whether the result contains infinity, which is true for SW points but not for TE points). What do you think?

@Pratyush Pratyush merged commit f742abd into arkworks-rs:master Oct 17, 2024
11 checks passed
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.

2 participants