{{ message }}
Adding deterministic miller rabin primality test - #1453
Merged
cclauss merged 2 commits intoOct 25, 2019
Merged
Conversation
Member
Contributor
Author
|
Any idea what I did wrong with the tests? I put them under test_miller_rabin, which runs under main. That's a good point. My thought process was that since this test is deterministic for most computable numbers, it can be used as a general fast primality test. I also don't have any additional implementation that made me think of putting it in the cipher folder. If you think it's best, I'm happy to move it, because I'm not convinced it belongs in maths :) |
Member
|
I am not sure on the test thing. It has been bugging me for a while now. I am no expert on pytest discovery rules but perhaps @codecalec could give us guidance on why is works in his PRs. |
Member
cclauss
reviewed
Oct 25, 2019
cclauss
approved these changes
Oct 25, 2019
stokhos
pushed a commit
to stokhos/Python
that referenced
this pull request
Jan 3, 2021
* Adding deterministic miller rabin primality test * Moved to ciphers directory and renamed for clarity. Changed docstring to add test
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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's a miller-rabin primality test in the cipher folder, but I figured a deterministic one for "small" numbers would be interesting. Deterministic (meaning True is prime) for n < ~ 3.32 e 24, probabilistic for larger. With Miller Rabin, a False is always composite- no false negatives.
See https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test for details.