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

Make Short Weierstrass random sampling result in an element with unknown discrete log #188

Merged
merged 3 commits into from
Jan 27, 2021

Conversation

kobigurk
Copy link
Contributor

@kobigurk kobigurk commented Jan 27, 2021

Description

Short Weierstrass random sampling is currently not safe as a method for sampling random elements with unknown discrete log. The PR duplicates the Twisted Edwards random sampling behavior which is safe.

I have not added new tests nor documentation.

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
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@kobigurk kobigurk changed the title fix: make sw random sampling the same as twisted edwards Make Short Weierstrass random sampling result in an element with unknown discrete log Jan 27, 2021
Copy link
Member

@Pratyush Pratyush left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@weikengchen
Copy link
Member

My main concern is a probably stupid question: for SW curves, for a random x, is it guaranteed that we can find a point on the curve? I have this concern since the get_point_from_x for SW curves is Optional.

@weikengchen
Copy link
Member

(this same stupid question also goes to the TE one)

@Pratyush
Copy link
Member

Pratyush commented Jan 27, 2021

That's why the loop is there, no? If the x coordinate is invalid, we just keep sampling until we find a valid one. Since validity is decided by a square root, and since half of the elements of a prime field have square roots, in expectation we only need two iterations of the loop.

@weikengchen
Copy link
Member

oh got it. I did not notice that loop.

@weikengchen weikengchen merged commit 2c814ab into arkworks-rs:master Jan 27, 2021
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.

3 participants