Test whether is a probable prime for BigInt.#7051
Test whether is a probable prime for BigInt.#7051shove70 wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @shove70! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#7051" |
|
Since this is proposed for a public facing function, I think it is important to document the nature of the probabilistic test. Specifically, that it is the miller-rabin primality test that is being used, and the role the Once in place, backward compatibility will become a valuable characteristic. For this reason, it might be better to expose the API with a name specific to the miller-rabin primality test rather than the more generic |
@jondegenhardt, Thank you very much for your suggestion. From the point of view of the powerful D language standard library, we really need to consider it more fully. I agree with you very much. There's only one concern: when users use this function, will I'll think it over and ask for more guidance. |
One possibility might be the approach taken for exposing random number generators in If you choose this approach you might consider dropping the |
Thand you. |
Whatever makes sense. I'm not an expert on primality tests. My only reason for wondering about the It probably a minor thing though. Whatever test you introduce in |
|
For background - Here's a Perl library supporting a general |
|
@jondegenhardt,I see what you mean. There are two options:
To sum up, I take your first suggestion. |
bbb19c1 to
4039f0c
Compare
|
@n8sh, excuse me, "auto-tester" hangs up for a long time, it seems that there is no work, Is this a code problem I submitted or something else? |
|
IDK why, it should say pending 10. |
|
I'll give it a push and see if it starts up again. |
|
@thewilsonator, @n8sh, Thanks. |
d160fdd to
23bf6ba
Compare
32b2e83 to
5045166
Compare
830a723 to
1b7af6b
Compare
3e9362b to
51c78eb
Compare
|
https://issues.dlang.org/show_bug.cgi?id=19997 (In reply to shove from comment #1)
|
827b2ee to
091c232
Compare
|
Excuse me, Hope this PR can be approved and merged. BigInt is not a built-in type. It is a type simulated by using uint as a "digit" and uint[]. Because of this, we can't manipulate its numbers as easily as we can control int, long, etc. BigInt.data.data is this uint[], but BigInt.data is private, and BigInt.data.data is private too. |
n8sh
left a comment
There was a problem hiding this comment.
New public symbols need to be approved by @atilaneves or @andralex, so it cannot be merged until one of them looks at it. From a technical perspective this PR seems fine.
You really, really should not do crypto with It would be great if we had a fixed-size integer type. Sociomantic also had this need (https://github.com/sociomantic-tsunami/ocean/blob/v4.x.x/src/ocean/math/WideUInt.d). |
Thanks. |
|
WideUInt is fixed in size at compile time, i.e. backed by a static array, so all operations can be made to take the same number of primitive operations and thus the same amount of time. BigInt is dynamically sized, backed by a dynamic array, and thus operations can take a variable amount of time, which is bad because timing attacks. |
|
Oh, I see! Thanks! @thewilsonator @Geod24 @n8sh... |
6e6698f to
626bc8e
Compare
No description provided.