-
Notifications
You must be signed in to change notification settings - Fork 27
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
Clean up and include discrete logarithm functions into fmpz_mod #85
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
760a155
Clean up and simplify fmpz_mod
GiacomoPope 3fe7a63
Add discrete log solver to fmpz_mod
GiacomoPope f5ee217
Merge branch 'add_fmpz_mod' of https://github.com/GiacomoPope/python-…
GiacomoPope 46b749a
Clean up imports
GiacomoPope 258b64b
Clearer comments
GiacomoPope 1050cb8
Clearer mathematics for subgroup testing
GiacomoPope 473315a
modify fragile doctest
GiacomoPope e83e649
Speed up conversion to fmpz_mod
GiacomoPope 3d29848
insane print debugging
GiacomoPope 679d609
Initalise memory
GiacomoPope 1da5e63
Cleanup
GiacomoPope 88d704e
Modify equality check for contexts
GiacomoPope b873979
Add TODO
GiacomoPope 20e5d49
Store ph-dlog precomputation on ctx
GiacomoPope e866add
Allow base dlog to also be precomputed
GiacomoPope bb25d9d
Change memory management for precomutations
GiacomoPope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
from flint.flint_base.flint_base cimport flint_scalar | ||
from flint.flintlib.fmpz cimport fmpz_t | ||
from flint.flintlib.fmpz_mod cimport fmpz_mod_ctx_t | ||
from flint.flintlib.fmpz_mod cimport ( | ||
fmpz_mod_ctx_t, | ||
fmpz_mod_discrete_log_pohlig_hellman_t | ||
) | ||
|
||
|
||
cdef class fmpz_mod_ctx: | ||
cdef fmpz_mod_ctx_t val | ||
|
||
cdef fmpz_mod_discrete_log_pohlig_hellman_t L | ||
cdef bint _dlog_precomputed | ||
cdef any_as_fmpz_mod(self, obj) | ||
cdef _precompute_dlog_prime(self) | ||
|
||
cdef class fmpz_mod(flint_scalar): | ||
cdef fmpz_mod_ctx ctx | ||
cdef fmpz_t val | ||
|
||
cdef any_as_fmpz_mod(self, obj) | ||
|
||
cdef bint base_dlog_precomputed | ||
cdef fmpz_t x_g |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In memory terms the first element of L is an
fmpz_mod_ctx_t
which would end up being a copy ofval
. If we include the structL
inline here then we don't needval
.I think it is better though to just have a pointer like
If the pointer is set to NULL in
__cinit__
then there is no need for a separate_dlog_computed
variable. The_precompute_dlog_prime
method can just check for NULL and then call malloc etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not addressed this yet. So you think I should set the pointer to
NULL
for__cinit__
and then when I do the normal discrete log stuff then I want to work with the pointerself.ctx.L
?I guess I can also do something similar for
x_g
with a pointer?EDIT: hmmm, I'm not sure how to dereference the pointer for the dlog call... I'm pretty stupid with the cython pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's like
f(L[0])
. You can't usef(*L)
because that means something else in Python.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh got it! The real issue was my
malloc
which was poorly written before.Seems to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(There was no
flint_malloc
which I could see, so I did it this way, but we could maybe write a small function to do this?)