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

Support compressed and uncompressed point serialization #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dtebbs
Copy link
Contributor

@dtebbs dtebbs commented May 22, 2020

Allows compressed / uncompressed points to be used in different situations, independently of the build configuration.

{
g.X = tX;
g.Y = tY;
g.Z = alt_bn128_Fq::one();
Copy link
Collaborator

@AntoineRondelet AntoineRondelet Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we check that the point is on the curve first?
Seems to me that the deserialization logic of a point in the affine space should be:

  1. Recover x, y
  2. Check that the tuple (x, y) is on the curve, i.e. satisfies the curve equation
  3. Either do the "safe subgroup membership test" or mult by cofactor to make sure we have a point in G1 and not a point (which may be of low order) in the E/Fq group

Do I miss something? (Note: this code initially originates from the library, and has just been moved around in this PR - so this question applies to the current state of the library, as in master, for the deserialization of uncompressed points)

Copy link
Collaborator

@AntoineRondelet AntoineRondelet Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, it seems to me that, the same assumption is made in the deserialization of compressed points, since I can read here that the sqrt function does not terminate if the element is a quadratic non-residue in the field: https://github.com/scipr-lab/libff/blob/master/libff/algebra/fields/fp.hpp#L108

We can "skip" the bullet 3. above here since cofactor = 1, but why skipping bullet 2.? I'd be in favor to test for quadratic residuity using Euler's criterion (and the euler exponent defined here: https://github.com/scipr-lab/libff/blob/master/libff/algebra/fields/fp.hpp#L54) first, and only proceed if the test is valid.

These functions act as I/O with the backend of the library, so I would be in favor to make no assumption about their input, and the parsed points.
As such, I would be in favor to add these checks. @dtebbs @madars @ValarDragon thoughts?
This is related to #50

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