arkworks-rs / snark

Interfaces for Relations and SNARKs for these relations
https://www.arkworks.rs
Apache License 2.0
770 stars 207 forks source link

Allow creation of group element by raw X and Y coordinates #299

Closed dark64 closed 3 years ago

dark64 commented 3 years ago

This PR adds from_xy_checked function to AffineCurve trait which can be used to create a point from raw X and Y coordinates. This function returns a Result as on-curve check is performed.

We are in process of adding zexe as a backend to ZoKrates project and this is currently a block for us. As we work with raw x and y coordinates we need to have a way to construct associated G1Affine and G2Affine types from PairingEngine trait. This change would enables us to do so.

As a reference, this is supported for bellman in the pairing_ce crate. Any feedback is appreciated on this.

Pratyush commented 3 years ago

Do you think it makes sense to instead try to construct these by deserializing from the relevant bytes? I feel like that's less error prone and less likely to cause bugs.

dark64 commented 3 years ago

I managed to do this using the FromBytes trait. I guess my proposed change is not needed after all, so I'm closing this. Thanks for the help! :+1: