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

Schoof's Algorithm #19071

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

abhinav-anand-addepar
Copy link
Member

  • ntheory
    • Implement schoof's algorithm

@sympy-bot
Copy link

Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- BEGIN RELEASE NOTES -->
* ntheory
  * Implement schoof's algorithm
<!-- END RELEASE NOTES -->

@codecov
Copy link

codecov bot commented Apr 4, 2020

Codecov Report

Merging #19071 into master will increase coverage by 0.088%.
The diff coverage is 89.454%.

@@              Coverage Diff              @@
##            master    #19071       +/-   ##
=============================================
+ Coverage   75.730%   75.819%   +0.088%     
=============================================
  Files          647       650        +3     
  Lines       168733    169202      +469     
  Branches     39767     39873      +106     
=============================================
+ Hits        127783    128288      +505     
+ Misses       35389     35338       -51     
- Partials      5561      5576       +15     

@abhinav-anand-addepar abhinav-anand-addepar changed the title [WIP] Schoof's Algorithm Schoof's Algorithm Apr 8, 2020
short_com["p9"] = exp(y2, p, fl)
short_com["alpha2"] = alpha**2 % fl
short_com["beta2"] = beta**2 % fl
short_com["p5p4"] = short_com["p4"]*short_com["p5"] % fl
Copy link
Member

Choose a reason for hiding this comment

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

It think it could be cleaner to just use variables for these, and pass them through to the various functions as parameters.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will make the changes.

References
==========

[1] http://jjmcgee.asp.radford.edu/SchoofsAlgorithm06.pdf
Copy link
Member

Choose a reason for hiding this comment

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

Is the code here all based on this reference or are there other references too? If the code here is based on some pseudocode from a paper, that is fine, but you should indicate that so that it is clear where we can look to understand the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this is based on the pseudocode from the referenced paper.

@asmeurer
Copy link
Member

I think this needs a lot more tests. We should aim for full coverage of the code, particularly all the different if blocks. Also if there is any way to verify the that the tests themselves are correct we should do that.

from .factor_ import divisors
from .residue_ntheory import polynomial_congruence




Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

X = symbols('X')
Y = symbols('Y')
div = {}
if domain != QQ:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if domain != QQ:
if domain is not QQ:

QQ should be a unique object.

Division Polynomials of an elliptic curve over finite fields.

"""
from sympy import simplify
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from sympy import simplify
from sympy import _simplify

Comment on lines +319 to +327
l = 1
i = 1
p = self.modulus
X = self.X
Y = self.Y
L = []
m = 1
f2 = {}
y2 = poly(X**3 + self._a4*X+self._a6, X, modulus=p)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
l = 1
i = 1
p = self.modulus
X = self.X
Y = self.Y
L = []
m = 1
f2 = {}
y2 = poly(X**3 + self._a4*X+self._a6, X, modulus=p)
l, i, m = 1, 1, 1
p, X, Y = self.modulus, self.X, self.Y
L, f2 = [], {}
y2 = poly(X**3 + self._a4*X+self._a6, X, modulus=p)

Comment on lines +422 to +423
p1 = short_com["p3"]
p1 = poly(X, X, modulus=p) - p1
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
p1 = short_com["p3"]
p1 = poly(X, X, modulus=p) - p1
p1 = poly(X, X, modulus=p) - short_com["p3"]

return p_16 % f(l)


def f(k):
Copy link
Member

Choose a reason for hiding this comment

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

A more descriptive function name?

@czgdp1807
Copy link
Member

@abh2k Was this PR a part of your GSoC project?

@abhinav-anand-addepar
Copy link
Member Author

@abh2k Was this PR a part of your GSoC project?

No.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants